Archive · AWS

S3 Basics: Buckets, Versioning and Public Access

Create a bucket safely: block public access, turn on versioning and encryption.

1 min read

  • Amazon S3
  • AWS CLI 2.0
  • Region ap-south-1

S3 stores objects in buckets. Bucket names are globally unique.

aws s3 mb s3://acme-app-assets-2020 --region ap-south-1
aws s3api put-public-access-block --bucket acme-app-assets-2020 \
  --public-access-block-configuration \
  BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=true
aws s3api put-bucket-versioning --bucket acme-app-assets-2020 \
  --versioning-configuration Status=Enabled
aws s3 cp backup.tar.gz s3://acme-app-assets-2020/backups/
aws s3 sync ./site s3://acme-app-assets-2020/site
  • Block Public Access (available since November 2018) stops accidental exposure; leave it on unless a bucket is truly meant to be public.
  • Versioning lets you recover overwritten or deleted objects.
  • Lifecycle rules move old data to cheaper classes such as S3 Standard-IA or Glacier, or expire it.
  • Turn on default encryption (SSE-S3), or SSE-KMS when you need control over the keys.

Give applications access with an IAM role, not public ACLs.