14. Amazon S3: Buckets, Objects, Policies and Presigned URLs
14.2 Creating a Bucket and Uploading Objects
Aadhi console madhun, mag CLI ne – donhi yayla pahijet. Console chi UI vela-velela badalte, pan settings chi naave tich rahtat.
Console steps
- Open the AWS Console → S3 → Create bucket.
- Bucket type: General purpose. Bucket name:
ravindra-demo-files-pune(lowercase, numbers and hyphens only, 3–63 characters). - AWS Region:
Asia Pacific (Mumbai) ap-south-1. - Object Ownership: keep ACLs disabled (recommended) – access is controlled only by policies.
- Block Public Access settings: keep Block all public access ticked.
- Bucket Versioning: Enable (we will see why in 14.5).
- Default encryption: SSE-S3 (Amazon S3 managed keys) – on by default.
- Click Create bucket, open it and use Upload → Add files → Upload.
AWS CLI steps (on your laptop with aws configure done, or on EC2 with an IAM role – see 14.7):
aws --version # AWS CLI v2 is preinstalled on Amazon Linux 2023
aws s3 mb s3://ravindra-demo-files-pune --region ap-south-1 # make bucket
echo "Namaskar mitrano" > hello.txt
aws s3 cp hello.txt s3://ravindra-demo-files-pune/notes/hello.txt
aws s3 ls s3://ravindra-demo-files-pune/ --recursive --human-readable
aws s3 cp s3://ravindra-demo-files-pune/notes/hello.txt ./copy.txt # download
aws s3 sync ./site s3://ravindra-demo-files-pune/site/ # upload a whole folder
aws s3 rm s3://ravindra-demo-files-pune/notes/hello.txt # delete one object
aws s3api head-object --bucket ravindra-demo-files-pune --key site/index.html # metadata
| Command | What it does |
|---|---|
aws s3 mb / aws s3 rb |
Make / remove a bucket (rb --force also deletes objects – careful!) |
aws s3 cp |
Copy one file to/from S3 (--recursive for folders) |
aws s3 sync |
Copy only new/changed files; --delete removes extra files at the target |
aws s3 ls |
List buckets or objects |
aws s3 mv / aws s3 rm |
Move / delete objects |
aws s3api ... |
Low-level API calls (policies, versioning, head-object, etc.) |
Ravindra Bagale's Tip
aws s3 sync ./site s3://bucket/ --delete he command khup powerful aahe – local folder chukicha asla (jase rikama folder) tar bucket madhla sagla data delete hoto! Khup students ne ashi chuk keli aahe. Aadhi --dryrun lavun bagha kay honar aahe, mag khara command chalva.
Lab
Create a bucket in ap-south-1 from the console, upload one image, then use the CLI to list it, download it with a new name, and upload a folder of three files with aws s3 sync --dryrun followed by the real sync.