Configure an S3 static website index
📑 On this page
Part 57 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 tells the S3 website endpoint which object to serve for a directory-style request. It does not make objects readable.
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 put-bucket-website \
--bucket "$BUCKET" \
--website-configuration '{"IndexDocument":{"Suffix":"index.html"}}'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 returned suffix should be index.html.
One tiny variation
echo '<h1>AWS from Zero</h1>' > index.html
aws s3 cp index.html "s3://$BUCKET/index.html" \
--content-type text/htmlUploading the index object is separate from configuring website behavior.
Common mistake
S3 website endpoints do not support HTTPS directly. For a production HTTPS site, place CloudFront in front of a private S3 origin.
Cleanup
aws s3api delete-bucket-website --bucket "$BUCKET"
aws s3 rm "s3://$BUCKET/index.html"
rm index.htmlThe website configuration and demo index are removed.
Next, we will learn Add an S3 website error document.