I have a lambda function behind an api gateway. This is working fine when triggered with an Invoke URL. Invoke URL is the link offered in method tab under stages.
I am sending request to the resource as below, and this works fine.
I want to set a custom domain for my api so I followed the standard procedure to set an ACM certificate. In addition to that I did set domain (api.tarkshala.com) in route53. Check screenshots given below.
But when I hit the API using cloudfront link(d3pn2j4magp6tp.cloudfront.net) or the domain name (api.tarkshala.com) using POSTMAN, it ends up into 403 Forbidden.
I don't know what exactly am I missing?
Response Header looks as following:
Connection →keep-alive
Content-Length →23
Content-Type →application/json
Date →Fri, 13 Apr 2018 03:17:25 GMT
Via →1.1 a1cf0e6cf29b584b5fe1ada9ccee9758.cloudfront.net (CloudFront)
X-Amz-Cf-Id →9Jh5HeQIuDNfm5WGlTae34oYZ7BiN3nI2VlH_8PJHLQ0mr2C20njJQ==
X-Cache →Error from cloudfront
x-amz-apigw-id →FQoiyF1phcwFVrg=
x-amzn-ErrorType →ForbiddenException
x-amzn-RequestId →3013c239-3ec9-11e8-abe6-53449bcfc96c
Response:
{
"message": "Forbidden"
}
Alias Target
inRoute 53
. Try to add it:d3pn2j4magp6tp.cloudfront.net.
- If this still doesnt work how did you configure your "Base Path Mappings"? Please click on "Show Base Path Mappings" inAPI Gateway
(the 3. screenshot) - MaiKaYHost
header in the request from postman is set to your custom domain name (not the cloudfront hostname)? - Michael - sqlbotHost
header do you mean the url? Or there should be some field in Request Headers? @MaiKaY I updated theAPI Gateway
screenshot. - Kuldeep YadavHost:
, which you should be able to see in the request headers. This needs to be your custom domain name, not the cloudfront.net target hostname. - Michael - sqlbot