AWS S3 CLI
- AWS CLI for S3 comes with two commands
- s3: simple interface
- s3api: low level calls
-
Terms:
- S3uri:
- bucket:
s3://<bucket-name>- Examples:
- s3://ltdocsforlearning
- Examples:
- object:
s3://<bucket-name>/<path-to-object>- Examples:
- s3://ltdocsforlearning/docs/1.txt
- Examples:
- bucket:
- S3uri:
-
Setting up aws cli
- AWS CLI access key and secret key setup on workstation
- AWS IAM Role to access s3 on EC2 instance
How to use aws cli
- Refer Here for s3 cli docs and Refer Here for s3api cli docs
Activities
- Setup necessary IAM Permission on your workstation
- Get all the s3 buckets
aws s3 ls
- Create a new bucket
aws s3 mb s3://<new-bucket-name>

* upload some files from local system to new bucket
aws s3 cp <source> <destination>


* upload folders into new bucket



* copy the contents of new bucket into another bucket post creation

* delete both buckets

- Download any website template into a folder on your workstation Refer Here
- cd in to the folder with index.html
- Now cp the contents to a new bucket
- Grant public read access
{
"Version": "2012-10-17",
"Id": "Policy1729912460136",
"Statement": [
{
"Sid": "Stmt1729912458418",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::ltwebsite.com/*"
}
]
}
- Findout commands to unblock public access and upload the s3 bucket policy
- I want to backup a folder on my system to s3 for which using sync is recommended
