201 — S3 Buckets and Objects

Beginner

Create an S3 bucket, upload and download objects using the AWS CLI, generate a presigned URL for temporary access, and clean up — all from the terminal.

Learning Objectives

1
Create an S3 bucket using a globally unique, account-scoped name
2
Upload a local file to S3 using aws s3 cp
3
List bucket contents with aws s3 ls
4
Download an object from S3 back to the local filesystem
5
Generate a presigned URL for temporary object access
6
Delete objects and remove the bucket cleanly
Step 1

Understand bucket naming rules

Before creating a bucket, learn the constraints that apply to all S3 bucket names. These rules are enforced globally across every AWS account.

Commands to Run

# Preview the bucket name you will use in this lesson:
echo "devopspath-$(aws sts get-caller-identity --query Account --output text)-practice"

What This Does

S3 bucket names must be globally unique across all AWS accounts and regions.

The rules: 3–63 characters, lowercase letters, numbers, and hyphens only (no underscores or uppercase), must start and end with a letter or number, and cannot be formatted as an IP address.

Embedding your 12-digit Account ID in the name guarantees uniqueness without a random suffix.

Expected Outcome

The echo command prints a name like: devopspath-123456789012-practice The Account ID will be your 12-digit number.

This is the bucket name you will use in subsequent steps.

Pro Tips

  • 1
    S3 bucket names are global — two accounts cannot own the same name at the same time.
  • 2
    Using your account ID as part of the name is a common convention that makes bucket names traceable to an owner without storing that metadata separately.
  • 3
    Avoid underscores: they are not allowed in bucket names and will cause a 'InvalidBucketName' error.

Common Mistakes to Avoid

  • āš ļøUsing uppercase letters in bucket names — S3 rejects them silently with 'InvalidBucketName'.
  • āš ļøForgetting the --output text flag in the account ID substitution — without it, the CLI returns quoted JSON and the bucket name includes quote characters.
Was this step helpful?

All Steps (0 / 9 completed)