An Interest In:
Web News this Week
- April 19, 2024
- April 18, 2024
- April 17, 2024
- April 16, 2024
- April 15, 2024
- April 14, 2024
- April 13, 2024
Using s3 commands with aws cli
This write up describes some of the commands you can use to manage your s3 buckets and objects using aws s3 command line interface.
create a bucket
To create an s3 bucket with the command line, we use s3 mb.
Note that the name given to an s3 bucket must be globally unique. It can contain letter or number, and cannot contain a period next to a hyphen or another period.
syntax
$ aws s3 mb [--options]
example
aws s3 mb s3://bucket-name
2. list buckets and objects
$ aws s3 ls
Using this command without an option attached list all buckets.
To list the object contained in specific folder(prefix)
$ aws ls s3://bucket-name/example/
3. Delete bucket
$ aws s3 rb s3://bucket-name
By default, AWS does not allow you delete a bucket that is not empty. In order to by pass that, you must add --force option. However, if versioning is enabled in the bucket, then even this option won't work.
4. Move objects
To move a folder in an s3 bucket to another s3 bucket, use:
$ aws s3 mv s3://bucket-name/example s3://my-bucket/
To move a local file from your current working directory to the Amazon S3 bucket:
aws s3 mv filename.txt s3://bucket-name
To move a file from your Amazon S3 bucket to your current working directory:
aws s3 mv s3://bucket-name/filename.txt ./
5. Copy objects
To copy objects in an s3 bucket to another:
$ aws s3 cp s3://bucket-name/example s3://my-bucket/
To copy a local file from your current working directory to the Amazon S3 bucket:
$ aws s3 cp filename.txt s3://bucket-name
Original Link: https://dev.to/frankpromise/using-s3-commands-with-aws-cli-1jcn
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To