Routing Traffic to a Website that Is Hosted in an Amazon S3 Bucket
Amazon Simple Storage Service (Amazon S3) provides secure, durable, highly scalable cloud storage. You can configure an S3 bucket to host a static website that can include web pages and client-side scripts. (S3 doesn't support server-side scripting.)
To route domain traffic to an S3 bucket, use Amazon Route 53 to create an alias resource record set that points to your bucket. An alias resource record set is an Amazon Route 53 extension to DNS. It's similar to a CNAME resource record set, except you can create an alias resource record set both for the root domain, such as example.com, and for subdomains, such as www.example.com. You can create CNAME resource record sets only for subdomains.
Amazon Route 53 doesn't charge for alias queries to S3 buckets or other AWS resources.
Before you get started, you need the following:
An S3 bucket that is configured to host a static website. For more information, see Configure a Bucket for Website Hosting in the Amazon Simple Storage Service Developer Guide.
The bucket must have the same name as your domain or subdomain. For example, if you want to use the subdomain acme.example.com, the name of the bucket must be acme.example.com.
If you want to route traffic for multiple domains, such as example.com and www.example.com, to a single bucket, you can create a bucket for each domain and configure all but one of the buckets to redirect traffic to the remaining bucket. For more information, see Example: Setting Up a Static Website Using a Custom Domain in the Amazon Simple Storage Service Developer Guide.
A registered domain name. You can use Amazon Route 53 as your domain registrar, or you can use a different registrar.
Amazon Route 53 as the DNS service for the domain. If you register your domain name by using Amazon Route 53, we automatically configure Amazon Route 53 as the DNS service for the domain.
For information about migrating DNS service to Amazon Route 53, see Configuring Amazon Route 53 as Your DNS Service.
Configuring Amazon Route 53 to Route Traffic to an S3 Bucket
To configure Amazon Route 53 to route traffic to an S3 bucket that is configured to host a static website, perform the following procedure.
To route traffic to an S3 bucket
Sign in to the AWS Management Console and open the Amazon Route 53 console at https://console.aws.amazon.com/route53/.
In the navigation pane, choose Hosted Zones.
Choose the name of the hosted zone that has the domain name that you want to use to route traffic to your S3 bucket.
Choose Create Record Set.
Specify the following values:
Type the domain name that you want to use to route traffic to your S3 bucket. The default value is the name of the hosted zone.
For example, if the name of the hosted zone is example.com and you want to use acme.example.com to route traffic to your bucket, type acme.
Choose A – IPv4 address.
- Alias Target
In the S3 website endpoints section of the list, choose the bucket that has the same name that you specified for Name.
- Routing Policy
Accept the default value of Simple.
- Evaluate Target Health
Accept the default value of No.
Changes generally propagate to all Amazon Route 53 servers in a couple of minutes. In rare circumstances, propagation can take up to 30 minutes. When propagation is done, you'll be able to route traffic to your S3 bucket by using the name of the alias resource record set that you created in this procedure.