I am trying to create a lambda service on AWS and have it accessed from outside via the API gateway with no authentication or restriction required.
To make things ea
If you set 'API Key Required' option to true, please check below.
I might have come across a solution to this problem. I had the same issue right now on MacOS. I tried to flush my DNS and then it worked!
Try this in the terminal:
Mac OS X Yosemite and later
sudo killall -HUP mDNSResponder
Mac OS X Yosemite v10.10 through v10.10.3
sudo discoveryutil mdnsflushcache
Mac OS X Mavericks, Mountain Lion and Lion
sudo killall -HUP mDNSResponder
Mac OS X Snow Leopard
sudo dscacheutil -flushcache
As @gary69 and @Adriaan Pelzer mentions
https://stackoverflow.com/a/52727654/809043
https://stackoverflow.com/a/55136675/809043
You can get the message {"message":"Forbidden"} when requesting a Private API.
So if you have a setup where all traffic should go thorough a API Endpoint which than directs the traffic to the API Gateway then the following parameters may be used.
APIGatewayVPCEndpoint:
Type: 'AWS::EC2::VPCEndpoint'
Properties:
PolicyDocument: '{
"Version":"2012-10-17",
"Statement":[{
"Effect":"Allow",
"Principal": "*",
"Action":["execute-api:Invoke"],
"Resource":["arn:aws:execute-api:eu-north-1:000000000000:*/*"]
}]
}'
...
VpcEndpointType: Interface
PrivateDnsEnabled: true
If PrivateDnsEnabled is enabled, than the endpoint in the API Gateway needs to be of Type Private, and a policy needs to added.
ApiGatewayRest:
Type: AWS::ApiGateway::RestApi
Properties:
Description: A mocked API
Name: Mocked API
EndpointConfiguration:
Types:
- PRIVATE
Policy: '{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Principal": "*",
"Action": "execute-api:Invoke",
"Resource": "arn:aws:execute-api:eu-north-1:000000000000:*/*/*/*"
}]
}'
This forum thread helped clear out some of the details for me
https://forums.aws.amazon.com/thread.jspa?threadID=286760
I had a similar problem, and I had the following:
I also didn't set any Authorization nor restrictions to make things simple.
I was able to fix the problem by adding Base Path Mappings for each of my stages (dev, staging, prod).
I got {"message":"Forbidden"}
on an API with EndpointConfiguration set to PRIVATE, and a VpcEndpoint created for it in the Vpc's private subnets (this is an inter-service API)
The reason I got {"message":"Forbidden"}
was that I was under the impression I should use one of the VpcEndpoint's urls. The URL to use is still the one associated with the stage (in ApiGateway console). It is:
https://${RestApiId}.execute-api.${Region}.amazonaws.com/${StageName}
I got this error from an nginx fargate service trying to access a private API in API Gateway. I needed to add a policy under resource policies in my api like this
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": "*",
"Action": "execute-api:Invoke",
"Resource": "arn:aws:execute-api:us-east-1:<AccountID>:<RestApiID>/*",
"Condition": {
"StringEquals": {
"aws:sourceVpce": "<VPC Endpoint ID for execute-api>"
}
}
}
]
}