Useful AWS CLI commands

Escape White space…etc


On Mac using Homebrew

brew install awscli

To use CLI, you need Access Key ID and Secrete Access ID assigned to an IAM user. Create user with at least programmatic access. Use aws configure to set configuration. Use aws iam get-user to confirm logged in user.


    • Don’t forget that any CLI command interacting with S3 starts with
      aws s3api
    • Useful links:
    • To get help at the command line:
      • aws s3api command help

        substitute command with the command in question such as get-object

    • Run this AWS Command Line Interface (AWS CLI) command to get the Amazon S3 canonical ID for your account:
      aws s3api list-buckets --query Owner.ID
    • Run this command to get the Amazon S3 canonical ID of the account that owns a certain object
      aws s3api list-objects --bucket awsexamplebucket

      Note: the bucket parameter refers to the root bucket name off the main directory. It should has not quotes and no subdirectory.

    • The object owner can grant you full control of the object by running this command:
      aws s3api put-object-acl --bucket awsexamplebucket --key exampleobject.jpg --acl bucket-owner-full-control
    • To get an object:
      aws s3api get-object --bucket bucketname --key keyname outfilename
    • To list object with prefix foldername
      aws s3api list-objects --bucket bucketName --prefix folderName