DEV Community

Dickson for AWS Community Builders

Posted on • Updated on

Creating a custom domain name for AWS Elastic Beanstalk application

Amazon Route 53 is a highly available and scalable Domain Name System (DNS) service. Besides traffic management, Route 53 provides various features such as domain name registration, DNS routing policies and health checks.

Amazon Route 53

Registering a domain

  1. In the Route 53 console, select Registered domains in the navigation pane and click Register domains.
    Register domains

  2. Enter a desired domain name and click Search. From the list of the available domains, choose one and click Select.
    Search for domains

  3. Click Proceed to checkout.
    Selected domains

  4. Select the duration and/or (un)check the Auto-renew option, and click Next.
    Pricing

  5. Enter the contact information and click Next.
    Contact informationContact information

  6. Review the information, accept the terms and conditions, and click Submit.
    Review and submitReview and submit

Note: The registration can take up to 15 minutes. You may receive an email to verify your email address for the domain name, or the domain name will be suspended. If you receive an email about failing to register the domain name, create an Account and billing support case with service Domains and category Registration issue. The issue should be resolved in 2-3 days.

Creating records in Route 53 Hosted Zone

  1. Select Hosted zones in the navigation pane and click the hosted zone created in the previous step.
    Hosted zones

  2. Click Create record.
    Hosted zone

  3. Enter www as the subdomain, toggle on the switch for Alias, select Alias to Elastic Beanstalk environment, select the region of the environment, select the environment accordingly, keep other values default, and click Create records.
    Create record

Updating the Django settings

  1. Append the Route 53 domain name to the ALLOWED_HOSTS list in the file named settings.py in the ebdjango directory, and save the file.

    ALLOWED_HOSTS = [
        "djangoproj-dev.eba-ttkddb9r.us-east-1.elasticbeanstalk.com",
        "www.elasticbeanstalkapp.com",
    ]
    
  2. Re-deploy the Django site.

    eb deploy

After the environment update completes, the Django site is updated. At this stage, navigating to either the Elastic Beanstalk domain name (i.e. http://djangoproj-dev.eba-ttkddb9r.us-east-1.elasticbeanstalk.com) or the Route 53 domain name (i.e. http://www.elasticbeanstalkapp.com) gets the same Django site.

Django Site

References

Top comments (0)