AWS – Managing domains with Route 53

How to Create ASP.NET Core 3.1 MVC Applications

In this recipe, we’ll show you how to host a domain in Route 53 and add some records to it:

Hosting a domain

Getting ready

You technically don’t need to have registered a domain name in order to proceed with this recipe, but it helps if you have a real domain that you can use.

How to do it…

Follow these steps to create a hosted zone:

  1. Create a new CloudFormation template and add the following parameters to it:
    Description: Your domain name ( 
    Type: String
  1. Next, we need to add a HostedZone resource to our template, as follows:
    Type: AWS::Route53::HostedZone 
      Name: !Ref DomainName
  1. You’re now ready to go ahead and create your hosted zone in Route 53. You can do so via the CloudFormation web console or by using the following CLI command:
      aws cloudformation create-stack \
        --stack-name example-hosted-zone \
        --template-body file://07-03-Route53.yaml \
        --parameters \

This will create a hosted zone in Route 53. Once the stack has been created, go and find it in the web console. You’ll see that there are a number of name servers associated with it. These are the name servers to use if you wish to proceed with delegating your domain name to AWS’s Route 53 servers using your domain name registrar’s control panel.

How it works…

Amazon Route 53 acts as a traditional registrar, where you can claim a domain and then configure the DNS entries for that domain. But Route 53 takes routing functionality much further, integrating closely with AWS services to allow you to configure complex scenarios for routing traffic to a global collection of regional and edge locations. Users can be routed based on geographic location by the latency of the connection to your regional resources, or according to the health of the target servers, which can provide a robust failover mechanism. Integration with services such as S3 and CloudFront allows you to easily host a website without setting up any servers.

There’s more…

A hosted zone with no DNS records will be of limited use to you. Here are some examples of records that you may wish to add to your template:

    Type: AWS::Route53::RecordSetGroup 
        Ref: DNSHostedZone 
      - Name: !Ref DomainName 
        Type: A 
        TTL: 60 
          - "" 
      - Name: !Ref DomainName 
        Type: MX 
        TTL: 60 
          - "10" 
          - "20" 
      - Name: !Ref DomainName 
        Type: TXT 
        TTL: 60 
          - '"v=spf1 ?all"'

Some items of note:
For the priority in MX records, add the number at the start of the record, followed by a space.

For TXT records such as spf entries, which typically need to be quoted, you can surround double quotes with single quotes.

Here’s how this looks in the Route 53 web console:

Hosting a domain

See also

  • The Hosting a static website recipe in  Chapter 3, AWS Storage and Content Delivery

Comments are closed.