This is not an answer to the question, but for those who come up with the same error message.
I was using a resource policy to try to whitelist requests to an AWS API Gateway by IP, but I was getting the error mentioned by the OP:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "execute-api:Invoke",
"Resource": "arn:aws:execute-api:eu-west-1:{ACCCOUNT_ID}:{API_GW_ID}/{STAGE}/{METHOD}/{PATH}",
"Condition": {
"IpAddress": {
"aws:SourceIp": "{SOME_IP_ADDRESS}/32"
}
}
},
{
"Sid": "",
"Effect": "Deny",
"Principal": {
"AWS": "*"
},
"Action": "execute-api:Invoke",
"Resource": "arn:aws:execute-api:eu-west-1:{ACCCOUNT_ID}:{API_GW_ID}/{STAGE}/{METHOD}/{PATH}"
}
]
}
What I've learnt:
On the one hand, no resource policy means allow all requests.
On the other hand, Deny
statements take precedence over Allow
statements. (Meaning all requests were denied)
Lastly, if a resource policy exists, any request that does not match a statement gets denied.
Hence, to allow requests to API GW only from a certain IP, I ended up using the following policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "execute-api:Invoke",
"Resource": "arn:aws:execute-api:eu-west-1:{ACCCOUNT_ID}:{API_GW_ID}/{STAGE}/{METHOD}/{PATH}",
"Condition": {
"IpAddress": {
"aws:SourceIp": "{SOME_IP_ADDRESS}/32"
}
}
}
]
}