Perry Hoekstra
Perry Hoekstra

Reputation: 2763

Route 53 Subdomains and API Gateway

I have a domain hosted through Route 53 called foo.com and all is good. I have both NS and SOA records created in Route 53:

foo.com. NS
ns-1609.awsdns-09.co.uk. 
ns-431.awsdns-53.com. 
ns-1071.awsdns-05.org. 
ns-662.awsdns-18.net.

foo.com. SOA
ns-1609.awsdns-09.co.uk. awsdns-hostmaster.amazon.com.

We also segment our platforms by account. So, we have an AWS subaccount that supports our DEV environment (following the AWS document: https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/dns-routing-traffic-for-subdomains.html). So, within our foo.com hosted zone, we also have an entry:

devapi.foo.com. NS
ns-3476.awsdns-09.co.uk. 
ns-2341.awsdns-76.com. 
ns-3245.awsdns-56.org. 
ns-294.awsdns-67.net.

Within our AWS DEV account, we have a devapi.foo.com hosted zone with the exact same NS record:

devapi.foo.com. NS
ns-3476.awsdns-09.co.uk. 
ns-2341.awsdns-76.com. 
ns-3245.awsdns-56.org. 
ns-294.awsdns-67.net.

along with a SOA record and an A record that points at the DEV API Gateway:

devapi.foo.com. A  ALIAS f-8wdjr4hvgh.execute-api.us-east-2.amazonaws.com.

where f-8wdjr4hvgh.execute-api.us-east-2.amazonaws.com. is the domain name of the API Gateway.

I have a custom domain mapping for devapi.foo.com

Unfortunately, in all of this, devapi.foo.com is not pingable/routable. If you ping it, it returns an IP address but a Request timeout for icmp_seq* ...

If I use https://www.whatsmydns.net/#A/ for devapi.foo.com, I get green check marks but I believe that all that is telling me is that the domain name is resolvable.

Thoughts on what I am missing?

Followup: The issue was with the Custom Domain Mapping and Base Path.

Upvotes: 2

Views: 2973

Answers (1)

Jimbo
Jimbo

Reputation: 3284

I ran into a problem where I went to setup a record that mapped my custom sub-domain to my API Gateway. When I went to select the actual endpoint I got a red warning/error message saying "cannot retrieve endpoint suggestions"

The instructions for setting everything up are here: https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/routing-to-api-gateway.html

Before doing what I was trying to do, the prerequisites (stated on the linked page) were:

  1. An API Gateway API that has a custom domain name, such as api.example.com, that matches the name of the Route 53 record that you want to create.
  2. A registered domain name. You can use Amazon Route 53 as your domain registrar, or you can use a different registrar.
  3. Route 53 as the DNS service for the domain. If you register your domain name by using Route 53, we automatically configure Route 53 as the DNS service for the domain.

I realized I had not done step #1. This needs to be done via the API Gateway interface, not the Route 53 interface. If you haven't done this for the domain yet (not the sub-domain, but the domain) you may need to do some work to setup a certificate for the domain. This involves placing what looks to be a sort of magic key entry in your domain registry (using Route 53 or whatever you used to register your domain) so that Amazon knows you own the domain.

Once this custom domain has been setup (again, in the API Gateway section, not Route 53), then I was able to create a record in Route 53 and my API Gateway endpoint was now detected for selection.

Upvotes: 1

Related Questions