This usually comes when we try to access the Private API endpoint with incorrect policy & without passing the 'HOST' header in the invoke request.
Let's say I have an API that is deployed as a private endpoint with the below resource policy.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": "*",
"Action": "execute-api:Invoke",
"Resource": "arn:aws:execute-api:us-west-2:12345678:2ucqasdfasdfryc/*"
},
{
"Effect": "Deny",
"Principal": "*",
"Action": "execute-api:Invoke",
"Resource": "arn:aws:execute-api:us-west-2:12345678:2dgaucqt6dfgdyc/*",
"Condition": {
"StringNotEquals": {
"aws:SourceVpce": "vpce-87878kjlkj8787k"
}
}
}
]
}
Accessing Private API endpoint when private-DNS-hostnames disabled.
curl -v -H 'Host: 01234567ab.execute-api.us-west-2.amazonaws.com' https://vpce-01234567abcdef012-01234567.execute-api.us-east-1.vpce.amazonaws.com/test/pets
[OR]
use the API ID
instead of the Host
header.
curl -v -H 'x-apigw-api-id: 01234567' https://vpce-01234567abcdef012-01234567.execute-api.us-east-1.vpce.amazonaws.com/test/pets
[solved]
to your question. Thanks! – Tim Malone