Victor
Victor

Reputation: 14573

API Gateway custom domain ERR_NAME_NOT_RESOLVED

I followed the steps in the AWS documentation to set a custom domain for my APIs.

I have a setup with a versioned, regional API and I decided I would keep every version in a separate API Gateway API, like this:

test_api_v1
test_api_v2
etc.

I created a custom domain and the path mapping for each API as you can see below:

+---------------------------------------+
|           GetBasePathMappings         |
+----------+-------------+--------------+
| basePath |  restApiId  |    stage     |
+----------+-------------+--------------+
|  v2      |  api-id-v2  |  production  |
|  v1      |  api-id-v1  |  production  |
+----------+-------------+--------------+

Then created the corresponding record in Route53:

{
    "Name": "test-api.mydomain.com.",
    "Type": "CNAME",
    "AliasTarget": {
        "HostedZoneId": "Z1U9ULNL0V5AJ3",
        "DNSName": "d-abcdef1234.execute-api.eu-central-1.amazonaws.com.",
        "EvaluateTargetHealth": false
    }
}

P.S. I also tried with an A record, instead of CNAME; results were the same.

Now the problem comes from the fact that doing test-api.mydomain.com a few consecutive times, I get the the record shown sometimes and sometimes nothing and the browser says ERR_NAME_NOT_RESOLVED.

How can I solve this? How can I even debug it further?

Upvotes: 0

Views: 4192

Answers (1)

marcincuber
marcincuber

Reputation: 3791

So just looking at the docs you must have the following;

Before you get started, you need the following:

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.

A registered domain name. You can use Amazon Route 53 as your domain registrar, or you can use a different registrar.

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.

When you creating route 53 record. Specify the following values:

Name: Enter the domain name that you want to use to route traffic to your API.

The API that you want to route traffic to must include a custom domain name, such as api.example.com, that matches the name of the Route 53 record.

Type: Choose A – IPv4 address.

Alias: Choose Yes.

Alias Target: How you specify the value for Alias Target depends on whether you created the hosted zone and the API using the same AWS account or different accounts:

Same account – Choose the list, and find the category API Gateway APIs. The list of target domain names includes only APIs that have a custom domain name that matches the value that you specified for Name. Choose the applicable value.

Routing Policy: Choose the applicable routing policy. For more information, see Choosing a Routing Policy.

Evaluate Target Health: Accept the default value of No.

Upvotes: 1

Related Questions