title: CloudFormation Template for API Gateway with Lambda Proxy and MethodResponse Headers
body: <p>Here is a CloudFormation puzzle I think I cannot solve without your help. I'm trying to create a template for a REST API with CloudFormation (YAML). The API has a Lambda Proxy and has to have a MethodResponse as shown in the attached image. </p>
  
  <p><a href="https://i.stack.imgur.com/ShA0H.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ShA0H.png" alt="MethodResponse"></a> </p>
  
  <p>This is my template so far which produces the following error when building the stack:</p>
  
  <blockquote>
    <p>PostMethod: Value of property ResponseParameters must be an
    object</p>
  </blockquote>
  
  <pre><code>      ApiGatewayAccount: 
          Type: "AWS::ApiGateway::Account"
          Properties: 
              CloudWatchRoleArn: "some role"
        RestApi:
            Type: "AWS::ApiGateway::RestApi"
            Properties:
              Description: "some rest api"
              EndpointConfiguration:
                Types:
                  - REGIONAL
              Name: RestApi
  
        SomeResource:
          Type: "AWS::ApiGateway::Resource"
          Properties:
            ParentId: 
              Fn::GetAtt: 
                - "RestApi"
                - "RootResourceId"
            PathPart: part
            RestApiId: 
              Ref: "RestApi"
  
        SomeSubResource:
          Type: "AWS::ApiGateway::Resource"
          Properties:
            ParentId: 
              Ref: "SomeResource"
            PathPart: count
            RestApiId: 
              Ref: "RestApi"
  
        SomeResponseModel:
          Type: "AWS::ApiGateway::Model"
          Properties:
            ContentType: "text/html"
            Description: "Empty text/html response."
            Name: someresponse
            RestApiId: 
              !Ref RestApi
            Schema: {}
  
        PostMethod:
          Type: "AWS::ApiGateway::Method"
          Properties:
            HttpMethod: POST
            Integration:
              IntegrationHttpMethod: POST
              Type: AWS_PROXY
              Uri: 
                Fn::Join:
                  - ""
                  - - "arn:aws:apigateway:"
                    - "some-region"
                    - ":lambda:path/2015-03-31/functions/"
                    - "some-arn-of-lambda-function"
            MethodResponses:
              -
                ResponseModels:
                  Key: "application/x-www.form-urlencoded"
                  Value: 
                    !Ref SomeResponse
                ResponseParameters:
                    - method.response.header.Content-Length: true
                    - method.response.header.Content-Type: true
                    - method.response.header.Connection: true
                StatusCode: 200
            OperationName: SomeName
            ResourceId:
              !Ref "SomeSubResource"
            RestApiId: 
              !Ref "RestApi"
  </code></pre>