https://console.aws.amazon.com/quickstart-website
Add a name and select example website.
To get the S3 bucket name that was created: Click Manage files in Amazon S3.
- Click
Buy domain - Click
Choose existing domain - Select the domain and enter an optional subdomain
Allow some time for the newly created Record Set to propagate.
Click Manage settings in Amazon CloudFront
- Click
Edit - Add the alternate domain names, e.g.:
www.example.com example.com - Select the appropriate certificate
- Select the desired Security Policy
- Select the supported HTTP Versions
- Save by clicking
Yes, Edit
- Edit the first behavior item
- Select
Redirect HTTP to HTTPSin theViewer Protocol Policy - Set
Object Cachingvariables (or selectUse Origin Cache Headers) - Set
YestoCompress Objects Automatically - Save by clicking
Yes, Edit
If your website is not an SPA, you can ignore this part
- Click
Create Custom Error Response - Select HTTP Error Code
404: Not Found - Set
YesonCustomize Error Response - Type
/index.htmlin Response Page Path - Set
HTTP Response Codeto200: OK
Do the same for all the other error codes you want to handle.
The following steps assume the scenario where we want http://example.com or https://example.com to be redirected to https://www.example.com
- Type a
Bucket Namee.g.:aws-example-redirect - Select
US East (N. Virginia)as the region - Click
Create bucket - Open the newly created bucket
- Go to the
Propertiestab - Click
Static website hosting - Select
Redirect requests - Type
www.example.comas the domain andhttpsas the protocol - Copy the endpoint URL
- Click
Save
- Paste the bucket's endpoint URL (that was copied from the previous step) as the
Origin Domain Name - Select the appropriate
Price Class - Type
example.comin theAlternate Domain Names - Select the appropriate SSL Certificate
- Create Distribution
- Leave
Nameempty - Set
YestoAlias - Select the CloudFront distribution from the previous step as the
Alias Target - Create record set