I'm getting {"message":"Forbidden"} when trying to access my lambda from custom domain in api Gateway

1

I'm getting {"message":"Forbidden"} when trying to access my lambda from custom domain in api Gateway.

I followed this amazon tutorial https://www.youtube.com/watch?v=Ro0rgeLDkO4 Which seems like there is some sort of permission problem. But I'm not sure what it is?

2 Answers
1

Hi There,

Can you confirm if you are able to get a response from your lambda when hitting the apigateway directly ?

**Please ensure to add API mappings for the Custom domain names to associate the API , Stage & Path.

You can click on 'Configure API mappings' under the path : 'API Gateway' > ' Custom domain name' > 'API mappings'**

Most probably you are missing this mapping due to which you are getting {"message":"Forbidden"}

Thanks

AwsDev
answered 2 years ago
  • Hei, I found the solution later. I did few things. One of them is that I had to remove the "stage" from the link.

0

Resolution for me was that I had forgotten the A record in the hosted zone pointing from the generated "API Gateway domain name" to your domain name.

Ferom the console the generated domain name can be found in API gateway -> Custom domain names -> <YOUR DOMAIN> -> Configurations -> API Gateway domain name

In Python CDK this looked something like:

        api_domain_name =  <YOUR DOMAIN NAME>

        api_domain = cdk.aws_apigateway.DomainName(
            self,
            "ApiDomainName",
            domain_name=api_domain_name,
            certificate=cert,
        )

        cdk.aws_route53.ARecord(
            self,
            "ApiGWARecord",
            zone=hostzone,
            record_name=api_domain_name,
            target=cdk.aws_route53.RecordTarget.from_alias(
                cdk.aws_route53_targets.ApiGatewayDomain(
                    api_domain,
                )
            ),
        )
answered 7 months ago

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