【问题标题】:Creating Non-Lambda Proxy AWS API Gateway in CodePipeline在 CodePipeline 中创建非 Lambda 代理 AWS API 网关
【发布时间】:2017-11-06 04:55:40
【问题描述】:

使用代码管道创建了 Lambda 函数 (POST) 和相应的 API 网关。默认情况下,API 网关是使用 lambda 代理类型集成创建的。我应该在 SAM 中提供哪些参数,以便我的 API 网关是使用非 Lambda 代理类型集成创建的。

下面是我的 SAM 模板。

AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-  31 Description: Outputs the time Resources: TimeFunction: Type: AWS::Serverless::Function Properties: Handler: index.handler Runtime: nodejs6.10 CodeUri: ./ Events: MyTimeApi: Type: Api Properties: Path: /TimeResource Method: GET CalculatorFunction: Type: AWS::Serverless::Function Properties: Handler: calc.calculator Runtime: nodejs6.10 CodeUri: ./ Events: MyCalculatorApi: Type: Api Properties: Path: /Calculator Method: POST

请指教

【问题讨论】:

    标签: aws-lambda aws-api-gateway aws-codepipeline amazon-cloudformation


    【解决方案1】:

    如果您使用AWS::Serverless::Api 资源,您应该能够定义您想要的任何 Swagger 定义。在我们的开发人员指南中有 swagger 定义的示例,您还可以从 Stages 页面将现有 API 导出到 swagger。在这种情况下,Swagger 中x-amazon-apigateway-integration 结构上的type 字段应该是aws 而不是aws_proxy

    当您在 SAM 中的 Lambda 函数上设置内联 API 事件类型时,无法设置此字段。

    【讨论】:

    • 如果在我的 SAM 中创建一个 Lambda 函数资源及其相应的 API 资源,而不是在 Lambda 函数上内联设置 API 事件类型,这是否有意义。当我从外界调用我的 API 时,它最终会调用 API Resource 中定义的 Lambda。
    猜你喜欢
    • 2021-02-22
    • 1970-01-01
    • 2021-11-17
    • 1970-01-01
    • 2018-03-15
    • 2020-11-10
    • 2017-11-27
    • 2017-09-28
    相关资源
    最近更新 更多