How to use High-Level (s3) Commands with the AWS CLI?

Today lesson, we will learn how to manage Amazon S3 buckets and objects using high-level AWS s3 commands. Check the more detail on AWS S3 doc.

1. Create a Bucket

$ aws s3 mb s3://<bucket-name>

2. List Your Buckets

$ aws s3 ls s3://<bucket-name>/<sub-bucket-name>

3. Delete a empty Bucket

$ aws s3 rb s3://<bucket-name>

4. Delete a non-empty Bucket

$ aws s3 rb s3://<bucket-name> --force

5. Copies a local object into a bucket

$ aws s3 cp file.txt s3://<bucket-name>/

6. Sync the object from a source to destination

$ aws s3 sync <source> <target> [--options]

7. Sync the object from local to s3 bucket without delete option

$ aws s3 sync . s3://<bucket-name>/path

8. Sync the object from local to s3 bucket with delete option (delete from s3)

$ aws s3 sync . s3://<bucket-name>/path --delete delete: s3://<bucket-name>/path/test.txt

9. Sync the object from local to s3 bucket with delete option (delete from local)

$ aws s3 sync s3://<bucket-name>/path . --delete delete: MySubdirectory\test.txt

That’s it. I hope this will help. 🙂
Photo: https://www.brandeps.com

Leave a Reply

Your email address will not be published. Required fields are marked *