skip to Main Content

So I’m trying to set up a custom domain for my AWS Lambda function.

I went through all the instructions to buy a domain name via google domains, set up a certificate through AWS Certificate manager, and created the corresponding route 53 hosted zone.

enter image description here

For whatever reason, I unfortunately get a 403 error when I try to reach the API Gateway domain name endpoint. In this case, it’s https://d-frdw0740fd.execute-api.us-east-1.amazonaws.com.

Also for context, here is my API mappings tab.

API mappings tab

For more context, here is my hosted zone in route 53 corresponding with my custom domain name:

route 53

Instead of bringing me to a {"message": "Not Found"} page, I’d like it to bring me to my actual aws endpoint.

Where am I going wrong in order to set up my configuration so that my API Gateway domain name is correctly linked to the functional aws endpoint instead of just reaching a 404 error?

UPDATE: I redeployed my serverless function and not instead of getting now instead of the 404 Not Found error I get 403 Forbidden:

{
"message": "Forbidden"
}

2

Answers


  1. Chosen as BEST ANSWER

    Finally found the solution. I was previously trying to use the domain from Google domains but it’s just easier doing it all through route 53 registering a new domain which creates a hosted domain. For context, this video was very helpful in getting me set up

    After following the steps in API gateway to create a certificate, custom domain, name, and api mapping, there’s one last step where you must add an A name DNS record that maps to the custom domain you just created.

    One major step that I needed to take that I was failing to do was to route the traffic from my gateway API to my domain

    After doing that, I was able to successfully set up the custom domain name for the API.

    Another major thing I learned was that under "Custom domain names", don't try to hit "API Gateway domain name" directly.

    enter image description here

    I tried so many times to hit this API and it was giving me that forbidden error, but it will always give that error even when the ACTUAL custom domain set up properly. So it is not useful to keep hitting this url to test that the domain is working properly, instead use the custom domain you've set up in route 53 to test to see if the setup is configured correctly.


  2. I have read your question and all comments and looks like the problem is in URL.

    • Problem

    As per the problem statement url [Invoke URL] 1zofmxtv82.execute-api.us-east-1.amazonaws.com/dev/health-check is working as expected but url [API Gateway Domain Name] d-frdw0740fd.execute-api.us-east-1.amazonaws.com/dev/health-check is giving 403 forbidden.

    • Solution

    There is no need to use stage name (dev) in this URL d-frdw0740fd.execute-api.us-east-1.amazonaws.com/dev/health-check

    Please try with d-frdw0740fd.execute-api.us-east-1.amazonaws.com/health-check

    or try with Route53 URL

    party-poll-api.com/health-check

    • Reason

    Stage name already included in API mapping so need to mention it again.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search