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 Antworten
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
beantwortet vor 2 Jahren
  • 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,
                )
            ),
        )
beantwortet vor 8 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen