Help us understand the problem. What is going on with this article?

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

More than 1 year has passed since last update.

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" 

http://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/aws-properties-apitgateway-method-integration.html#cfn-apigateway-method-integration-requestparameters

が、これだけだとエラーになります。
あとからマネージメントコンソールで足そうとしても、

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" 

http://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-method.html#cfn-apigateway-method-requestparameters

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

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした