S3 from Zero: buckets, objects, and sync
📑 On this page
Part 6 of AWS from Zero. S3 is object storage. You put files into buckets, and AWS stores them as objects.
S3 is a good first service because the commands are visible and concrete: create a bucket, upload a file, list it, download it, delete it.
Pick a unique bucket name
S3 bucket names are globally unique. Nobody else in AWS can already be using the same name.
Use something personal:
BUCKET="aws-zero-dhayal-20260712"
REGION="ap-south-1"PowerShell:
$BUCKET = "aws-zero-dhayal-20260712"
$REGION = "ap-south-1"Create a bucket
For regions outside us-east-1, include the location constraint:
aws s3api create-bucket \
--bucket "$BUCKET" \
--region "$REGION" \
--create-bucket-configuration LocationConstraint="$REGION"PowerShell uses the same AWS CLI command, but variables look different:
aws s3api create-bucket `
--bucket $BUCKET `
--region $REGION `
--create-bucket-configuration LocationConstraint=$REGIONList your buckets:
aws s3api list-buckets \
--query "Buckets[].Name" \
--output tableUpload one file
Create a tiny file:
echo "hello from aws cli" > hello.txtUpload it:
aws s3 cp hello.txt "s3://$BUCKET/hello.txt"List objects:
aws s3 ls "s3://$BUCKET/"Download it with a new name:
aws s3 cp "s3://$BUCKET/hello.txt" downloaded-hello.txtSync a folder
Create a folder:
mkdir site
echo "home page" > site/index.html
echo "about page" > site/about.htmlSync it:
aws s3 sync site "s3://$BUCKET/site/"List recursively:
aws s3 ls "s3://$BUCKET/" --recursiveHigh-level vs low-level commands
You used two command families:
aws s3 ...: friendly high-level commands for common file operations.aws s3api ...: lower-level API-shaped commands.
Both are useful. s3 cp and s3 sync are great for files. s3api is better for bucket settings, policies, encryption, and precise automation.
Cleanup
Delete objects:
aws s3 rm "s3://$BUCKET/" --recursiveDelete the bucket:
aws s3api delete-bucket --bucket "$BUCKET" --region "$REGION"Confirm it is gone:
aws s3api list-buckets \
--query "Buckets[?Name=='$BUCKET']"In part 7, we use S3 as a static website host, still with no console clicking.