【问题标题】:AWS API Gateway Method Response in CloudFormationCloudFormation 中的 AWS API Gateway 方法响应
【发布时间】:2018-09-28 06:31:15
【问题描述】:

我正在尝试设置我的 API 网关,使其具有以下简单的方法响应:

我正在使用 CloudFormation,但一直遇到错误。我相信这很简单,但是在花了几个小时阅读文档后我被困住了。这是我的方法资源(在 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

我需要 MethodResponse 属性吗?

【问题讨论】:

    标签: aws-api-gateway amazon-cloudformation


    【解决方案1】:

    好吧,看来我只需要添加这个:

    MethodResponses:
        - StatusCode: 200
          ResponseModels: { "application/json": "Empty" }
    

    【讨论】:

    【解决方案2】:

    是的,没错。您需要添加以下内容:

    方法响应:

    • 状态码:200

      响应模型:

        application/json: 'Empty'
      

    【讨论】:

      猜你喜欢
      • 2018-04-19
      • 2021-10-13
      • 2015-12-04
      • 2018-06-09
      • 1970-01-01
      • 2016-04-16
      • 2019-10-25
      • 1970-01-01
      • 2019-06-20
      相关资源
      最近更新 更多