User: anonymous is not authorized to perform: execute-api:Invoke on resource: arn:aws:execute-api:

はじめに

API gatewayのテストをしていると、

“` User: anonymous is not authorized to perform: execute-api:Invoke on resource: arn:aws:execute-api: “` というエラーが出た。

原因

パーミッションエラー

対処

API gatewayの許可IPを確認する。

aws:SourceIpにIPを追加する。

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": "*",
            "Action": "execute-api:Invoke",
            "Resource": "arn:aws:execute-api:*:*:*/*",
            "Condition": {
                "IpAddress": {
                    "aws:SourceIp": [
                        "123.0.0.1",
                        "1.23.4.1"
                    ]
                }
            }
        }
    ]
}

 

参考情報

クラメソさん、いつもありがとうございます。

[新機能] API のアクセスコントロールが簡単に!API Gateway でリソースポリシーが設定可能になりました