Should dig display the API gateway when I query the custom domain?

0

I'm still struggling with getting my custom domain name working for my regional REST API, and I'm trying to find where it is broken.

In Route 53 I have a hosted Zone, mysite.com, with 4 records:

  • mysite.com, A, d1111111111111.cloudfront.net, Alias:Yes
  • mysite.com, NS, ns-1332.awsdns-38.org, ns-623.awsdns-13.net, ns-1606.awsdns-08.co.uk, ns-206.awsdns-25.com, Alias:No
  • mysite.com, SOA, ns-1332.awsdns-38.org awsdns-hostm<aster>.amazon.com..., Alias:No
  • api.mysite.com, A, d-yyyyyyyyyy.execute-api.us-east-1.amazonaws.com, Alias: Yes

If I execute 'dig mysite.com', it returns in the answer section: mysite.com 600 IN CNAME dd1111111111111.cloudfront.net

Next, if I execute 'dig api.mysite.com', I get in the answer section: api.mysite.com 600 IN CNAME dd1111111111111.cloudfront.net, still pointing at my CloudFront distribution, not the API Gateway. Is this expected behavior?

2 Answers
1
Accepted Answer

Is it possible that your domain hasn't been properly delegated to Route53? If that were the case, another name server somewhere else could be answering queries. Check the SOA record with

dig SOA example.com

and verify that an awsdns nameserver is listed in the answer.

AWS
EXPERT
Paul_L
answered 10 months ago
  • It looks like that is it: I get ns47.domaincontrol.com

1

as per the following references

https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-custom-domains.html

There are two types of custom domain names in API Gateway: Edge-optimized and Regional. When you create a custom domain name for an edge-optimized API, API Gateway sets up an Amazon CloudFront distribution. You must then set up a DNS record to map the custom domain name to the CloudFront distribution domain name. For a Regional API, you need to set up a DNS record to map the custom domain name to the Regional domain name​

For both types of custom domain names, you must provide a certificate. This can be requested from AWS Certificate Manager (ACM) or imported from a third-party certificate authority

In your specific situation, you mentioned that you have an 'A' record in Amazon Route 53 for api.mysite.com that points to d-yyyyyyyyyy.execute-api.us-east-1.amazonaws.com, which I assume is your API Gateway endpoint. However, when you run dig api.mysite.com, the result points to dd1111111111111.cloudfront.net, which is a CloudFront distribution.

If your API Gateway is regional (which is typically the case if the domain name includes execute-api), you would expect the dig api.mysite.com to show the API Gateway URL (d-yyyyyyyyyy.execute-api.us-east-1.amazonaws.com) in the results. If it is showing a CloudFront URL instead, it could be that there is a configuration issue with your DNS records in Route 53 or there is a propagation delay for the changes.

Please verify the following:

Check your Route 53 setup again to ensure that your api.mysite.com record is correctly set to alias your API Gateway endpoint (d-yyyyyyyyyy.execute-api.us-east-1.amazonaws.com), not a CloudFront distribution. It might take some time for the DNS changes to propagate. Depending on various factors, DNS changes can take up to 48 hours to fully propagate globally. Confirm that you have correctly set up the custom domain name in the API Gateway console, and it is correctly associated with your API deployment.

profile picture
EXPERT
answered 10 months ago
  • I have confirmed that the A record for mysite.com points to the CloudFront distribution, and that the A record for api.mysite.com is routing to the Regional API Gateway's custom domain. Both the CloudFront distribution and API Gateway are tied to the same certificate, which has two domains listed: 'mysite.com' and '.mysite.com'. The CloudFront distribution has two Alternate Domain Name (CNAME) records: 'mysite.com' and 'www.mysite.com'. It used to have the CNAMEs 'mysite.com' and '.mysite.com', but I changed it yesterday. Prior to my change, I was getting a 404 calling https://api.mysite.com. Since changing the CNAME on the CF Distribution to 'www.mysite.com', I get a SSLV3_ALERT_HANDSHAKE_FAILURE when calling any subdomain of 'mysite.com' other than 'www'. So it seems that Route 53 is sending everything through to Cloudfront as dig is indicating. I should also add that the Route 53 and Cloudfront configs were originally set up 4 years ago: I am trying to add the Custom Domain name to my existing Regional API gateway.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions