This tutorial will guide you through the process of setting up an Apex redirect using AWS S3, AWS CloudFront, and AWS Certificate Manager.
example.com
, myapp.io
, etc.).
app
, www
, etc.).
us-east-1
region, but your redirect will be served globally with minimal latency via AWS CloudFront.
Choose “Specify an Amazon S3 template URL”, and use the following template URL:
Stack name
, choose any name you’ll recognize in the future, e.g.: redirect-example-com
.
Domain
parameter, input the domain you want to redirect away from.
Subdomain
parameter, use the subdomain. Don’t include the domain itself there! For example, you want to redirect to app.example.com
, then just input app
.
ViewerBucketName
parameter, input any name you’ll recognize in the future. You cannot use dots here. A name like redirect-example-com
will work here too.
CREATE_IN_PROGRESS
, navigate to your mailbox, and look for an email from AWS to validate your domain ownership.
Once you receive it, read the instructions and click through to validate.
CREATE_COMPLETE
.
This process will take about one hour, so sit back while CloudFormation does the work and come back once it’s complete (but we’d suggest you stay around for the first 5 minutes or so in case an error shows up).
If, for some reason, the process fails, review the error in the stack’s Events tab. This may be caused by choosing a bucket name that is already in use. Once you’ve identified the error, delete the stack, and start over again.
DistributionHostname
provided by CloudFormation as an output for the stack. You can find it in CloudFormation under the Outputs tab for the stack after its state changes to CREATE_COMPLETE
.
Once you have the hostname in hand, the instructions depend on your DNS provider.
If you’re setting up a redirect for a domain that’s already serving production traffic, now is a good time to check that the redirect works the way you expect.
To do so, use curl
and verify that the following requests return a redirect to the right host (you should see a Location
header in the response):
DistributionHostname
you got from CloudFormation.
DistributionHostname
you got from CloudFormation.
DistributionHostname
you got from CloudFormation.