Skip to content

Instantly share code, notes, and snippets.

@katronai
Last active March 17, 2017 08:57
Show Gist options
  • Save katronai/29fbf96f4505ee640a00b88e62643ed5 to your computer and use it in GitHub Desktop.
Save katronai/29fbf96f4505ee640a00b88e62643ed5 to your computer and use it in GitHub Desktop.
AWS CLI commands
#Get configuration
aws configure list
#Get profile credentials
aws configure get myprofile.aws_access_key_id
aws configure get myprofile.aws_secret_access_key
#List all s3 buckets
aws s3 ls --profile myprofile
#List all objects and folders under a bucket
aws s3 ls s3://mybucket --profile myprofile
#Number of objects under a directory
aws s3 ls s3://mybucket/path --recursive --profile myproile | wc -l
#Download whole directory from S3 into a local dir
aws s3 sync s3://mybucket/path localdir
#Delete a bucket
aws s3 rb s3://mybucket --force --profile myprofile
#Delete an object
aws s3 rm s3://mybucket/path/myfile.txt --profile myprofile
#Delete a directory and its contents
aws s3 rm s3://mybucket/path --recursive --profile myprofile
#Empty a bucket
aws s3 rm s3://mybucket --recursive --profile myprofile
#Empty a bucket with key name prefix (eg: doc)
aws s3 rm s3://mybucket/doc --recursive --profile myprofile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment