S3 Static Site Setup
- In your AWS Console, go to Services -> S3
- Click [ + Create Bucket ]
- Type in a bucket name for static site logging (i.e., domainname.com-logs)
- Accept next all the way to Create Bucket
- Click [ + Create Bucket ]
- Type in your domain name (for example, “domainname.com”)
- If you created a logs bucket:
- Check “Log requests for access to your bucket” under “Server access logging”
- Enter the logging bucket name under the “Target bucket” field.
- Hit [Next] for Configure Options
- Under Set Permissions, uncheck “Block all public access” and check the box that says “I acknowledge that the current settings may result in this bucket and the objects within becoming public”
- Click Create Bucket
Creating a static site
- Drag and drop your static HTML files and assets within the site root in your project and drag to S3. Before sure you have the html file you want to use as an index and as an error page.
- Click [Next] on the Upload modal.
- Under “Manage public permissions” change “Do not grant public read access to this object(s)” to “Grant public read access to this object(s)” and click [Next]
- Click [Upload] from the “Set Properties” step (skip Storage Class configuration, etc. screen).
- Under the “Properties” tab for your bucket, click on the “Static website hosting” tile
- Select “Use this bucket to host a website”, enter the name of your index and error documents, and click [Save].
- You should be able to click the link under endpoint and see your index page.
Create a hosted zone for your domain in Route 53
- In Route 53, select Hosted zone link on the left of the console
- Click [Create hosted zone]
- Enter your Domain name
- Select “Public hosted zone”
- Click “Create hosted zone”
- If you have a domain purchased elsewhere than AWS, copy the name servers under the “Hosted zone details” and set on your domain. (e.g., on Namecheap, it’s under Domain->Nameservers->Custom DNS… BE SURE TO HIT THE GREEN CHECKMARK AFTER EDITS!!)
Create a Record in the Hosted Zone
- Select “Create record”
- Select “Simple record”
- Under “Define simple record”
- leave the record name blank
- Value/Route traffic to
- Alias to S3 website endpoints
- Select your region
- In the field that says “Choose S3 Bucket”, you should see your bucket as an option:
- To finish, click [Define simple record] and then [Create records]
3 responses to “Hosting a static site on S3 with a purchased domain”
[…] so we’ve set up a static site hosted from an S3 bucket with a custom domain using Route 53. But sadly, […]
[…] so you’ve created a lovely static site and/or set up a CloudFront distribution for https for it. But CloudFront bills by the GB. What if […]
[…] you’re serving up a static website from S3, especially if you have larger assets stored there, you may want to put monitoring on the requests […]