Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS API Gateway Method Response in CloudFormation

I am trying to set up my API Gateway so it has this simple method response:

Method Response

Method Response Details

And I am using CloudFormation and I keep running into errors. I believe this is pretty simple but I am stuck after spending hours reading docs. Here is my method resource (in YAML):

MyMethod:
Type: "AWS::ApiGateway::Method"
Properties:
  AuthorizationType: "NONE"
  HttpMethod: "GET"
  Integration:
    Type: AWS
    Credentials: !GetAtt MyRole.Arn
    IntegrationHttpMethod: "POST"
    Uri:
      Fn::Join: [ "", [ "arn:aws:apigateway:", Ref: "AWS::Region", ":states:action/SendTaskSuccess" ] ]
    PassthroughBehavior: WHEN_NO_TEMPLATES
    RequestTemplates:
      application/json: |
        {
           "output": "\"Approve link was clicked.\"",
           "taskToken": "$input.params('taskToken')"
        }
    IntegrationResponses:
      - StatusCode: 200
        ResponseTemplates: {"application/json": "$input.json('$.body')"}
   RequestParameters:
    method.request.querystring.taskToken: false
  OperationName: succeed
  ResourceId: !Ref MyResource
  RestApiId: !Ref MyApi

Do I need a MethodResponse property?

like image 314
Moneer81 Avatar asked Apr 18 '18 06:04

Moneer81


1 Answers

Ok it looks like I just had to add this:

MethodResponses:
    - StatusCode: 200
      ResponseModels: { "application/json": "Empty" }
like image 66
Moneer81 Avatar answered Sep 21 '22 23:09

Moneer81