← All posts
2 min read

Remove S3 static website configuration

#aws#cli#s3#storage#web
📑 On this page

Part 60 of AWS from Zero. This lesson keeps the scope to one S3 behavior you can verify from the terminal.

What we are learning

Website configuration is independent from the objects in the bucket. Removing it disables website behavior without deleting content.

Before you run it

aws sts get-caller-identity
REGION="ap-south-1"
BUCKET="replace-with-your-private-demo-bucket"

Use a private general purpose bucket that you own. Replace every placeholder before running a write or delete command.

The command

aws s3api delete-bucket-website --bucket "$BUCKET"

A successful configuration command may return no output. Treat inspection as a separate required step.

Inspect the result

aws s3api get-bucket-website --bucket "$BUCKET"

The expected result is a NoSuchWebsiteConfiguration error.

One tiny variation

aws s3api list-objects-v2 \
  --bucket "$BUCKET" \
  --query "Contents[].Key" \
  --output table

The objects remain and can still be accessed through authorized S3 API requests.

Common mistake

Do not delete the entire bucket just to turn off website hosting. Remove the website configuration first and handle objects separately.

Cleanup

# This lesson does not require an additional persistent resource.
aws s3api head-bucket --bucket "$BUCKET"

Keep the shared demo bucket for the next lesson, or remove only the configuration and objects created here.

Next, we will learn Enable S3 server access logging safely.

Official AWS CLI reference