← All posts
2 min read

S3 from Zero: buckets, objects, and sync

#aws#s3#storage#cli
📑 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=$REGION

List your buckets:

aws s3api list-buckets \
  --query "Buckets[].Name" \
  --output table

Upload one file

Create a tiny file:

echo "hello from aws cli" > hello.txt

Upload 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.txt

Sync a folder

Create a folder:

mkdir site
echo "home page" > site/index.html
echo "about page" > site/about.html

Sync it:

aws s3 sync site "s3://$BUCKET/site/"

List recursively:

aws s3 ls "s3://$BUCKET/" --recursive

High-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/" --recursive

Delete 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.