Your Elastic Beanstalk Environment's custom domain name
Your environment is available to users with a sub-domain elasticbeanstalk.com. When you create an environment, you can choose you own domain for your application.
To route users to your environment Elastic Beanstalk registers a CNAME record that points to your environment's load balancer. You can see the current value of the CNAME in the Environment Dashboard:
You can change the CNAME on your environment by swapping it with the CNAME of another environment. For instructions, see Blue/Green Deployments with AWS Elastic Beanstalk.
If you own a domain name, you can use Amazon Route 53 to resolve it to your environment. You can purchase a domain name with Amazon Route 53, or use one that you purchase from another provider. To purchase a domain name with Amazon Route 53, see Registering a New Domain in the Amazon Route 53 Developer Guide.
To use a custom domain name, first create a hosted zone for your domain. A hosted zone contains the name server and start of authority (SOA) records that specify the DNS hosts that will resolve requests for your domain name.
To create a hosted zone in Amazon Route 53
Open the Amazon Route 53 management console.
Choose Hosted Zones.
Choose Create Hosted Zone.
For Domain Name, type the domain name that you own. For example:
example.com
.Choose Create.
Next, add a record to the hosted zone that resolves your domain name to your environment. When an Amazon Route 53 DNS server receives a name request for your custom domain name, it resolves to the elasticbeanstalk.com subdomain, which resolves to the public DNS name of your Elastic Load Balancing load balancer, which relays requests to the instances in your environment.
Note
In a single-instance environment, the elasticbeanstalk.com subdomain resolves to an Elastic IP address attached to the instance running your application.
If your environment has a regionalized subdomain, you can use an Amazon Route 53alias resource record setto save money on name resolution. The domain name for an environment with a regionalized subdomain includes the region; for example,my-environment.us-west-2.elasticbeanstalk.com
.
To add an alias resource record set in Amazon Route 53
Open the Amazon Route 53 management console.
Choose Hosted Zones.
Choose your hosted zone's name.
Choose Create Record Set.
For Name, type the subdomain that will redirect to your Elastic Beanstalk application. For example:
www
.For Type, chooseA - IPv4 address.
For Alias, chooseyes
For Alias Target, choose the domain name of your Elastic Beanstalk environment.
Choose Save Record Set.
If your environment does not have a regionalized subdomain, create a CNAME record instead.
To add a CNAME record in Amazon Route 53
Open the Amazon Route 53 management console.
Choose Hosted Zones.
Choose your hosted zone's name.
Choose Create Record Set.
For Name, type the subdomain that will redirect to your Elastic Beanstalk application. For example:
www
.For Type, choose CNAME - Canonical Name.
For Value, type the domain name of your Elastic Beanstalk environment. For example:
example.elasticbeanstalk.com
.Choose Save Record Set.
DNS records take up to 24 hours to propagate worldwide.
If you registered a domain name with another provider, register the name servers in your Amazon Route 53 hosted zone in the domain configuration. When your provider receives DNS requests for your domain name, it will forward them to Amazon Route 53's name servers to resolve the domain name to an IP address. Look for a setting called_Nameservers_or check your provider's documentation.
The Amazon Route 53 console displays the list of name servers for your hosted zone in an NS record on theHosted Zonespage:
If you have multiple environments running your application, you can use the Elastic Beanstalk console to swap two environments' domain names. This allows you to deploy a new version of your application to a standby environment, test it, and then swap domains with the production environment.
When you perform a CNAME swap, users are directed to the new version of your application with zero downtime. This is known as ablue/green deployment.
To swap environment CNAMEs
Open the Elastic Beanstalk console.
Choose either environment to open the Environment Dashboard.
Choose Actions, and then choose Swap Environment URLs.
Select the other environment.
Choose Swap.