Amazon Route 53
Developer Guide (API Version 2012-12-12)
« PreviousNext »
View the PDF for this guide.Go to the AWS Discussion Forum for this product.Go to the Kindle Store to download this guide in Kindle format.Did this page help you?  Yes | No |  Tell us about it...

How to Create Weighted Alias Resource Record Sets

You can create weighted alias resource record sets using the Route 53 console or the Route 53 API. See the applicable topic:

Creating Weighted Alias Resource Record Sets Using the Route 53 Console

To create weighted alias resource record sets using the Route 53 console

  1. If you're creating weighted alias resource record sets for:

    • An AWS resource other than an Elastic Load Balancing load balancer, skip to Step 2.

    • A load balancer and you created your Route 53 hosted zone and your Elastic Load Balancing load balancer using the same AWS account, skip to Step 2.

    • A load balancer and you created the hosted zone and the load balancer using different accounts, perform the following steps to get the DNS name for the load balancer:

    1. Sign in to the AWS Management Console using the AWS account that was used to create the load balancer for which you want to create an alias resource record set.

    2. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.

    3. In the left navigation pane, click Load Balancers.

    4. In the list of load balancers, select the load balancer for which you want to create a Route 53 alias resource record set.

    5. In the bottom pane, on the Description tab, get the A record value for DNS Name. When you create the resource record set in Route 53 and specify the A record value, Route 53 responds to A and AAAA queries with the IPv4 or IPv6 address, as applicable.

      Important

      Do not use the value for the AAAA record or the dualstack (A or AAAA record) record.

      EC2: getting the DNS name and hosted zone ID for a load balancer.

    6. Sign out of the AWS Management Console.

    7. Sign in to the AWS Management Console again using the AWS account that was used to create the Route 53 hosted zone.

  2. Open the Amazon Route 53 console at https://console.aws.amazon.com/route53/.

  3. In the Route 53 console, do one of the following to display the record sets for the hosted zone in which you want to create weighted alias resource record sets:

    • Click the row for the hosted zone, and click Go to Record Sets.

    • Double-click the row for the hosted zone.

    Creating a resource record set: Go to Record Sets button on the Hosted Zones page.

  4. Click Create Record Set.

  5. Enter the applicable values:

    Name

    Enter the name of the domain or subdomain for which you're creating an alias resource record set. Specify the same value for all of the resource record sets that you want to include in the same group of weighted alias resource record sets. The default value is the name of the hosted zone.

    Type

    Select the applicable value:

    • If you're creating an alias resource record set for a CloudFront distribution, an Amazon EC2 instance, an Elastic Load Balancing load balancer, or an Amazon S3 bucket, select A - Ipv4 address.

    • If you're creating an alias resource record set for another resource record set in this hosted zone, select the type of the resource record set for which you're creating the alias.

    Select the same value for all of the resource record sets that you want to include in the same group of weighted resource record sets.

    Alias

    Click Yes.

    Alias Target

    For CloudFront distributions, do one of the following:

    • If you used the same account to create your Route 53 hosted zone and your CloudFront distribution: Click Alias Target and choose a distribution from the list. If you have a lot of distributions, you can type the first few characters of the domain name for your distribution to filter the list.

    • If you used different accounts to create your Route 53 hosted zone and your distribution: Enter the CloudFront domain name name for the distribution; for example, d111111abcdef8.cloudfront.net.

    For Elastic Load Balancing load balancers, do one of the following:

    • If you used the same account to create your Route 53 hosted zone and your load balancer: Click Alias Target and choose a load balancer from the list. If you have a lot of load balancers, you can type the first few characters of the DNS name to filter the list.

    • If you used different accounts to create your Route 53 hosted zone and your load balancer: Enter the value that you got in Step 1 for the DNS name of the load balancer.

    For Amazon S3 buckets, do one of the following:

    • If you used the same account to create your Route 53 hosted zone and your Amazon S3 bucket: Click Alias Target and choose a bucket from the list. If you have a lot of buckets, you can type the first few characters of the DNS name to filter the list.

      The value of Alias Target changes to the Amazon S3 website endpoint for your bucket.

    • If you used different accounts to create your Route 53 hosted zone and your Amazon S3 bucket: Enter the domain name of the Amazon S3 website endpoint in the following format:

      s3-website-region.amazonaws.com

      The region value represents the Amazon S3 region in which the bucket is hosted; for example, us-east-1.

    Note

    You can create only one weighted alias resource record set that routes queries to an Amazon S3 bucket because the name of the resource record set must match the name of the bucket and bucket names must be globally unique.

    For resource record sets in this hosted zone, click Alias Target and choose the applicable resource record set. If you have a lot of resource record sets, you can type the first few characters of the name to filter the list.

    Alias Hosted Zone ID

    This value appears automatically based on the value that you selected or entered for Alias Target.

    Routing Policy

    Choose Weighted.

    Weight

    Enter an integer between 0 and 255. The value that you specify for Weight depends on the value you specify for Evaluate Target Health (see below):

    • If you set Evaluate Target Health to No: For the value of Weight, enter an integer between 0 and 255. To disable routing to a resource, set Weight to 0. If you set Weight to 0 for all of the resource record sets in the group, queries are routed to all resources with equal probability. This ensures that you don't accidentally disable routing for a group of weighted alias resource record sets.

    • If you set Evaluate Target Health to Yes: See Configuring Active-Active or Active-Passive Failover Using Route 53 Weighted and Weighted Alias Resource Record Sets for an explanation of how Weight and Evaluate Target Health are related.

    Set ID

    Enter a value that is unique for the current combination of Name and Type; for example, US-East-Region.

    Evaluate Target Health

    Select Yes if you want Route 53 to determine whether to respond to DNS queries using this resource record set by checking the health of the AWS resource specified by Alias Target. Note the following:

    • You cannot set Evaluate Target Health to Yes when the alias target is a CloudFront distribution.

    • If the AWS resource that you specify in Alias Target is a resource record set or a group of resource record sets (for example, a group of weighted resource record sets), but it is not another alias resource record set, we recommend that you associate a health check with all of the resource record sets in the alias target. For more information, see What Happens When You Omit Health Checks?.

    • If you specify an Elastic Load Balancing load balancer in Alias Target, Elastic Load Balancing routes queries only to the healthy Amazon EC2 instances that are registered with the load balancer. If no Amazon EC2 instances are healthy or if the load balancer itself is unhealthy, and if Evaluate Target Health is Yes for the corresponding alias resource record set, Route 53 routes queries to other resources.

      When you create a load balancer, you configure settings for Elastic Load Balancing health checks; they're not Route 53 health checks, but they perform a similar function. Do not create Route 53 health checks for the Amazon EC2 instances that you register with an Elastic Load Balancing load balancer.

      For more information, see How Health Checks Work in More Complex Route 53 Configurations.

    • We recommend that you set Evaluate Target Health to Yes only when you have enough idle capacity to handle the failure of one or more endpoints.

    Associate with Health Check

    Select Yes if you want Route 53 to determine whether to respond to DNS queries using this resource record set by checking the health of a specified endpoint. Then select the health check that you want Route 53 to perform for this resource record set. For more information, see Managing Resource Availability with Route 53 DNS Failover.

    Creating a weighted alias resource record set, right pane.

  6. Click Create Record Set.

  7. Repeat Steps 4 through 6 for each of the weighted resource record sets that you want to add to the group.

Creating Weighted Alias Resource Record Sets Using the Route 53 API

You can also use the ChangeResourceRecordSets action to create weighted alias resource record sets.

The example below assumes the following:

  • example.com is the domain for which you want to create weighted alias resource record sets.

  • SetIdentifier differentiates the two weighted alias resource record sets from one another. This element is required because the Name and Type elements have the same values for both resource record sets.

  • Z1111111111111 and Z3333333333333 are examples of hosted zone IDs for the Elastic Load Balancing load balancer specified by the value of DNSName. You can get the value of a load balancer's hosted zone ID, CanonicalHostedZoneNameID, in the following ways:

    • Use the AWS Management Console. On the EC2 page, click Load Balancers in the Navigation pane.

    • Use the DescribeLoadBalancers action, which is described in the "Actions" chapter of the Elastic Load Balancing API Reference.

    • Use the Elastic Load Balancing elb-describe-lbs CLI command. For more information about the CLI command, see the Elastic Load Balancing Quick Reference Card or the Elastic Load Balancing CLI help.

  • example-load-balancer-2222222222.us-east-1.elb.amazonaws.com and example-load-balancer-4444444444.us-east-1.elb.amazonaws.com are examples of Elastic Load Balancing domains from which Route 53 responds to queries for example.com.

    Use the DNS name that was returned by the Elastic Load Balancing CreateLoadBalancer action, which is described in the "Actions" chapter of the Elastic Load Balancing API Reference. You can also get the domain name for a load balancer by using the same methods that you used to get the hosted zone ID for the load balancer.

  • <EvaluateTargetHealth>true</EvaluateTargetHealth> in the first weighted resource record set indicates that health checks are enabled for the load balancer that is specified in DNSName. <EvaluateTargetHealth>false</EvaluateTargetHealth> in the second weighted resource record set indicates that health checks are disabled for the corresponding load balancer. For more information about health checks, see Managing Resource Availability with Route 53 DNS Failover.

POST /2012-12-12/hostedzone/Z5555555555/rrset HTTP/1.1
<?xml version="1.0" encoding="UTF-8"?>
<ChangeResourceRecordSetsRequest xmlns="https://route53.amazonaws.com/
doc/2012-12-12/">
   <ChangeBatch>
      <Comment>
      This change batch creates two weighted alias resource record sets. 
      Route 53 responds to queries for example.com with the first ELB 
      domain 3/4ths of the times and the second one 1/4th of the time.
      </Comment>
      <Changes>
         <Change>
            <Action>CREATE</Action>
            <ResourceRecordSet>
               <Name>example.com.</Name>
               <Type>A</Type>
               <SetIdentifier>1</SetIdentifier>
               <Weight>3</Weight>
               <AliasTarget>
                  <HostedZoneId>Z1111111111111</HostedZoneId>
                  <DNSName>example-load-balancer-2222222222.us-east-1.elb.amazonaws.com.</DNSName>
                  <EvaluateTargetHealth>true</EvaluateTargetHealth>
               </AliasTarget>
            </ResourceRecordSet>
         </Change>
         <Change>
            <Action>CREATE</Action>
            <ResourceRecordSet>
               <Name>example.com.</Name>
               <Type>A</Type>
               <SetIdentifier>2</SetIdentifier>
               <Weight>1</Weight>
               <AliasTarget>
                  <HostedZoneId>Z3333333333333</HostedZoneId>
                  <DNSName>example-load-balancer-4444444444.us-east-1.elb.amazonaws.com.</DNSName>
                  <EvaluateTargetHealth>false</EvaluateTargetHealth>
               </AliasTarget>
            </ResourceRecordSet>
         </Change>
      </Changes>
   </ChangeBatch>
</ChangeResourceRecordSetsRequest>

After you send your change request, check to ensure that your change was applied to all Route 53 DNS servers by polling for the status of the change. When the change is complete, its status becomes INSYNC. For more information about polling for the status of a change request, see Checking the Status of Your Change.