13
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

CloudFormation で API GatewayのURLクエリ文字列パラメータを設定する【cloudpack大阪ブログ】

Posted at

cloudpack大阪の佐々木です。

CloudFormationでAPI Gatewayをつくったときにハマったのでメモしときます。

問題

API Gateway でパスの文字列をバックエンドに渡すとき、統合リクエストURL クエリ文字列パラメータ method.request.path.xxxxを使います。

こんなやつ
Kobito.jw0DCe.png

これを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でつくったら設定できない状態になりました。マネージメントコンソールを見比べても、この設定は箇所はないようで、ハマりどころかと思います。

13
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?