Skip to content

Instantly share code, notes, and snippets.

@som-poddar
Last active January 15, 2019 21:26
Show Gist options
  • Save som-poddar/3d5794b81a4df7aad7752bf124ae7497 to your computer and use it in GitHub Desktop.
Save som-poddar/3d5794b81a4df7aad7752bf124ae7497 to your computer and use it in GitHub Desktop.
AWS Cli Example

EC2

All instances with max-output

aws ec2 describe-instances --max-items 1

List tags and their names

aws ec2 describe-instances --query 'Reservations[*].Instances[*].Tags[?Key==`Name`]'
aws ec2 describe-instances --query 'Reservations[*].Instances[*].Tags[?Value==`staging-playback-api`]'

List instances with select fields and filter

aws ec2 describe-instances --query 'Reservations[*].Instances[*].[PrivateIpAddress,InstanceType,State[?Name==`running`],LaunchTime,Tags[?Value==`staging-playback-api`]]'

S3

List objects

aws s3 ls  s3://example-bucket/63cd00b66674376b51cfd81b55de6fd5  --recursive
aws s3 ls  s3://example-bucket/63cd00b66674376b51cfd81b55de6fd5  --recursive --profile private-profile
aws s3 ls  s3://example-bucket/fdaacac564c5f93178d407e2ce6a9d60  --recursive --profile private-profile | grep mp4

Copy Objects

aws s3 ls  s3://example-bucket/63cd00b66674376b51cfd81b55de6fd5  --recursive
aws s3 cp  s3://example-bucket/63cd00b66674376b51cfd81b55de6fd5/file.json .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment