cloudpack大阪の佐々木です。
CloudFormationでAPI Gatewayをつくったときにハマったのでメモしときます。
問題
API Gateway でパスの文字列をバックエンドに渡すとき、統合リクエスト
のURL クエリ文字列パラメータ
method.request.path.xxxx
を使います。
これをCloudFormationでつくるとき、Integration → RequestParameters に記述します。
TestMethod:
Type: "AWS::ApiGateway::Method"
Properties:
Integration:
RequestParameters:
"integration.request.querystring.Subject": "method.request.path.name"
が、これだけだとエラーになります。
あとからマネージメントコンソールで足そうとしても、
Invalid mapping expression specified: Validation Result: warnings : [], errors : [Invalid mapping expression parameter specified: method.request.path.name]
というエラーになって設定できません。
解決策
Properties直下のRequestParameters
に使用するpathの情報を設定する必要があるみたいです。
TestMethod:
Type: "AWS::ApiGateway::Method"
Properties:
RequestParameters:
"method.request.path.name": true
Integration:
Type: AWS
IntegrationHttpMethod: POST
RequestParameters:
"integration.request.querystring.Subject": "method.request.path.name"
これ、マネージメントコンソールで作ったら問題なく設定できて、CFnでつくったら設定できない状態になりました。マネージメントコンソールを見比べても、この設定は箇所はないようで、ハマりどころかと思います。