Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aws-s3api: add page #6132

Merged
merged 11 commits into from
Jun 23, 2021
36 changes: 36 additions & 0 deletions pages/common/aws-s3api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# aws s3api

> Create and delete s3 buckets, and edit bucket properties.
258204 marked this conversation as resolved.
Show resolved Hide resolved
> More information: <https://docs.aws.amazon.com/cli/latest/reference/s3api/>.
258204 marked this conversation as resolved.
Show resolved Hide resolved

- Create a bucket:

`aws s3api create-bucket --bucket my-bucket`

- 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:
258204 marked this conversation as resolved.
Show resolved Hide resolved

`aws s3api list-objects --bucket {{bucket_name}} --query 'Contents[].{Key: Key, Size: Size}'`
258204 marked this conversation as resolved.
Show resolved Hide resolved

- 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}}`
bl-ue marked this conversation as resolved.
Show resolved Hide resolved

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

`aws s3api get-bucket-policy --bucket {{bucket_name}} --query Policy --output text > {{path/to/bucket_policy.json}}``
bl-ue marked this conversation as resolved.
Show resolved Hide resolved