Skip to content

Instantly share code, notes, and snippets.

@9horses
Created October 31, 2022 21:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 9horses/99d12f402badc1049dcac96b9bc14067 to your computer and use it in GitHub Desktop.
Save 9horses/99d12f402badc1049dcac96b9bc14067 to your computer and use it in GitHub Desktop.
aws cli cheatsheet for ec2 management
# disable client side paging
export AWS_PAGER=""
# list EC2 instances in default region
aws ec2 describe-instances --query "Reservations[*].Instances[*].{IP:PublicIpAddress,ID:InstanceId,Type:InstanceType,State:State.Name,Name:Tags[0].Value}" --output=table
# list EC2 instances in a specific region
aws ec2 describe-instances --query "Reservations[*].Instances[*].{IP:PublicIpAddress,ID:InstanceId,Type:InstanceType,State:State.Name,Name:Tags[0].Value}" --output=table --region=us-east-1
# start an EC2 instance
aws ec2 start-instances --instance-ids=i-01234567890123456
# stop an EC2 instance
aws ec2 stop-instances --instance-ids=i-01234567890123456
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment