Menu
Amazon Route 53
API Reference

Using Autonaming for Service Discovery

Amazon Route 53 autonaming makes it easier to provision instances for microservices by automating DNS configuration. Autonaming lets you automatically create DNS records based on a template that you define. You can also optionally create a health check based on the same template and associate the health check with all of the new records.

Here's how you use Amazon Route 53 autonaming:

  1. Create either a public namespace (accessible on the internet) or a private namespace (accessible only in an Amazon VPC). Note the following:

    • A namespace is a logical group of services that share the same domain name, such as example.com.

    • When you create a namespace, you specify a name that matches the name of a domain that you've registered.

    • When you create a namespace, Amazon Route 53 automatically creates a hosted zone that has the same name as the namespace.

    • For private namespaces, you can query within your VPC immediately.

    Commands:

    For autonaming API actions, submit HTTPS requests to one of the following endpoints:

    • EU (Ireland) – servicediscovery.eu-west-1.amazonaws.com

    • US East (N. Virginia) – servicediscovery.us-east-1.amazonaws.com

    • US East (Ohio) – servicediscovery.us-east-2.amazonaws.com

    • US West (Oregon) – servicediscovery.us-west-2.amazonaws.com

  2. If you created a public DNS namespace, perform the following steps:

    1. If you already registered a domain that has the same name as the public DNS namespace, skip to step 2b.

      If you haven't registered a domain that has the same name as the namespace, register a domain. If you want to use Amazon Route 53 for domain registration, see Registering a New Domain in the Amazon Route 53 Developer Guide.

    2. Get the names of the name servers that Amazon Route 53 assigned to your hosted zone. For more information, see Getting the Name Servers for a Public Hosted Zone.

    3. Change the name servers that are assigned to the domain. If the domain is registered with Amazon Route 53, see Adding or Changing Name Servers and Glue Records for a Domain for more information.

  3. Using the OperationId that was returned when you created the namespace, get the namespace ID.

    Command:

  4. Create a service for the namespace, and specify the following values:

    • A name for the service, such as cdn or prod. When you register an instance in the next step, Amazon Route 53 creates records in the hosted zone that it created automatically in step 1. The record names are a combination of the name of the service and the name of the namespace, for example, backend.example.com or worker.example.com.

    • DNS settings for up to five records.

    • Optionally, a health check. If you specify settings for a health check, Amazon Route 53 assigns the health check to all the records that it creates when you register an instance.

    • The NamespaceId that you got in step 3.

    Command:

  5. Register one or more instances. Specify the ServiceId that Amazon Route 53 returned in the response to the CreateService request, an InstanceId to associate your instance with the record, and IP address for the instance.

    Amazon Route 53 creates multivalue answer records based on the settings that you specified in the service. You can see the records that Amazon Route 53 creates in the hosted zone, but you can't change or delete them. For more information, see Multivalue Answer Routing in the Amazon Route 53 Developer Guide

    Command:

    When Amazon Route 53 receives a DNS query for the name of an instance, such as backend.example.com, it responds with up to eight IP addresses (for A or AAAA records) or up to eight SRV record values. If you specified a health check when you created the service, Amazon Route 53 returns values only for healthy instances.

  6. When you're ready to remove the DNS records and healthchecks for an instance, you can deregister your instance. Amazon Route 53 automatically deletes the corresponding resources. Specify the ServiceId that Amazon Route 53 returned in the response to the CreateService request, and specify the InstanceId for the instance that you want to deregister.

    Command: