Point Custom Domain to an AWS Gateway

Patrick Russo
2 min readMay 22, 2019

--

I’m still relatively new to AWS and networking so this probably took much longer than it should have, but I want to document what I went through for when I forget — I mean… in case anyone finds themselves needing to do this!

I wanted a custom domain to point to an AWS Gateway so that if I ever need to tear down my cloudformation or something else causes the url to change, I’m not screwed and referring to a broken endpoint.

I could only call the API gateway through https://aaaa99aaaa.execute-api.us-east-2.amazonaws.com/ but wanted to call it through api-subdomain.myurl.com.

Step 1:

Request a certificate for api-subdomain.myurl.com from AWS Certificate Manager (ACM)

At [region].console.aws.amazon.com/acm/, request a public certificate and validate that you’re the owner

Wait for validation to complete — it might take a few minutes

Step 2:

Configure custom domain and certificate in API Gateway

In [region].console.aws.amazon.com/apigateway go to Custom Domain Names and click Create Custom Domain Name

Enter the domain you want to forward to the API Gateway, api-subdomain.myurl.com, use Regional as the Endpoint Configuration, and then select your certificate!

After you save this, you’ll need to create Base Path Mappings that will route to a specific API Gateway.

e..g., if you make the path dev, api-subdomain.myurl.com/dev and select your gateway, api-subdomain.myurl.com/dev will behave the same as https://aaaa99aaaa.execute-api.us-east-2.amazonaws.com/

After one more step.

And here, you’ll also see your Target Domain Name listed. This is the new endpoint that AWS and your DNS provider will use.

Step 3:

Configure CNAME record. You can do this with (probably) any DNS provider. I use Google Domains, and it worked great.

In Google Domains, select DNS settings, Custom resource records, and create a CNAME record api-subdomain.myurl.com that points to the Target Domain Name from above.

Hapi coding!

wow, I need to not attempt to tell jokes this early in the morning

--

--