1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-04-22 16:42:10 +02:00
tldr/pages/common/aws-s3api.md
Shivam e1fddf2546
aws-s3api: add --region to create-bucket example (#8825)
* aws-s3api: add command for creating bucket outside us-east-1

* aws-s3api: add command for creating bucket in specific region

* aws-s3api: change region to variable
2022-10-11 07:59:46 +05:30

1.3 KiB

aws s3api

Create and delete Amazon S3 buckets and edit bucket properties. More information: https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3api/index.html.

  • Create bucket in a specific region:

aws s3api create-bucket --bucket {{bucket_name}} --region {{region}} --create-bucket-configuration LocationConstraint={{region}}

  • Delete a bucket:

aws s3api delete-bucket --bucket {{bucket_name}}

  • List buckets:

aws s3api list-buckets

  • 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}}}'

  • Add an object to a bucket:

aws s3api put-object --bucket {{bucket_name}} --key {{object_key}} --body {{path/to/file}}

  • 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_file}}

  • Apply an Amazon S3 bucket policy to a specified bucket:

aws s3api put-bucket-policy --bucket {{bucket_name}} --policy file://{{path/to/bucket_policy.json}}

  • Download the Amazon S3 bucket policy from a specified bucket:

aws s3api get-bucket-policy --bucket {{bucket_name}} --query Policy --output {{json|table|text|yaml|yaml-stream}} > {{path/to/bucket_policy}}