Issues consuming AWS API Gateway API

Question:

I have a simple HTTP API created using AWS API Gateway that uses a lambda integration to return some data.
I have also configured it with a custom DN using route53 (CNAME)

Recently I have been getting the following error when making a call to the endpoint

Can anyone help with why this is happening? I have setup a certificate for my custom domain using AWS certificate manager as well so its all AWS services, but for some reason its just stopped working?

Thanks
Andrew


Edit: I am weirdly getting this issue intermittently, when I make a call to the API in a browser I get the following error:

Then it goes away and it works again? HUH? Any ideas?

Answer:

OK I have found what the problem is thanks to the following post

If you look at the comments under the original post right at the bottom the author has resolved the problem but it has not been put as an answer to the post so you needed to read through everything to find out.

What the problem is, is you need to ensure you have your DNS setup correctly in route53.
I was originally creating a CNAME from my custom DN to the invoke URL of the API.

Instead what you need to do is create an ALIAS A record from your custom DN to the DN of your regional API (prefix with d-*)

NOTE: This is different to your invoke URL

Making this change all my problems went away.

For anyone doing this in Terraform this is what you need

Hope this saves someone a whole lot of time in the future.

Leave a Reply