CmdID

CmdID / Commands

aws-s3api

Create and delete Amazon S3 buckets and edit bucket properties. tldr-pages

On several platforms

Opens CmdID with your command. It is read in your browser and sent nowhere.

Several platforms

from tldr-pages, CC BY 4.0

Create bucket in a specific region

aws s3api create-bucket --bucket bucket_name --region region --create-bucket-configuration LocationConstraint=regionIdentify
--bucketThe name of the bucket to create. AWS CLI reference
--regionThe region to use. AWS CLI reference
--create-bucket-configurationThe configuration information for the bucket. AWS CLI reference

Delete a bucket

aws s3api delete-bucket --bucket bucket_nameIdentify
--bucketSpecifies the bucket being deleted. AWS CLI reference

List buckets

aws s3api list-bucketsIdentify

List the objects inside of a bucket and only show each object's key and size

aws s3api list-objects --bucket bucket_name --query 'Contents[].{Key: Key, Size: Size}'Identify
--bucketThe name of the bucket containing the objects. AWS CLI reference
--queryA JMESPath query to use in filtering the response data. AWS CLI reference

Add an object to a bucket

aws s3api put-object --bucket bucket_name --key object_key --body path/to/fileIdentify
--bucketThe bucket name to which the PUT action was initiated. AWS CLI reference
--keyObject key for which the PUT action was initiated. AWS CLI reference
--bodyObject data. AWS CLI reference

Download object from a bucket (The output file is always the last argument)

aws s3api get-object --bucket bucket_name --key object_key path/to/output_fileIdentify
--bucketThe bucket name containing the object. AWS CLI reference
--keyKey of the object to get. AWS CLI reference

Apply an Amazon S3 bucket policy to a specified bucket

aws s3api put-bucket-policy --bucket bucket_name --policy file://path/to/bucket_policy.jsonIdentify
--bucketThe name of the bucket. AWS CLI reference
--policyThe bucket policy as a JSON document. AWS CLI reference

Download the Amazon S3 bucket policy from a specified bucket

aws s3api get-bucket-policy --bucket bucket_name --query Policy --output json >path/to/bucket_policyIdentify
--bucketThe bucket name to get the bucket policy for. AWS CLI reference
--queryA JMESPath query to use in filtering the response data. AWS CLI reference
--outputThe formatting style for command output. AWS CLI reference