【问题标题】:How to remove tickmark Use Lambda Proxy integration on aws api如何删除标记在 aws api 上使用 Lambda 代理集成
【发布时间】:2020-11-19 08:18:02
【问题描述】:

我正在使用 sam 模板来创建 api+lambdas,但我遇到了一个问题:如何删除标记使用 Lambda 代理集成在 sam 模板中使用 enter image description hereaws api ??????

【问题讨论】:

    标签: api aws-lambda aws-api-gateway aws-sam


    【解决方案1】:

    你不能用 SAM 做到这一点,因为它是有限的,而且他们选择让它保持轻便和最小化(根据我在 Github 上与他们争论附加功能的经验)。您可以做的是将 SAM 与 cloudformation 类型混合:

    ApiGatewayRestApi:
      Type: AWS::ApiGateway::RestApi
      Properties:
        ApiKeySourceType: HEADER
        Description: An API Gateway with a Lambda Integration
        EndpointConfiguration:
          Types:
            - EDGE
        Name: lambda-api
    
    ApiGatewayResource:
      Type: AWS::ApiGateway::Resource
      Properties:
        ParentId: !GetAtt ApiGatewayRestApi.RootResourceId
        PathPart: 'lambda'
        RestApiId: !Ref ApiGatewayRestApi
    
    ApiGatewayMethod:
      Type: AWS::ApiGateway::Method
      Properties:
        ApiKeyRequired: false
        AuthorizationType: NONE
        HttpMethod: POST
        Integration:
          ConnectionType: INTERNET
          Credentials: !GetAtt ApiGatewayIamRole.Arn
          IntegrationHttpMethod: POST
          PassthroughBehavior: WHEN_NO_MATCH
          TimeoutInMillis: 29000
          Type: AWS
          Uri: !Sub 'arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${LambdaFunction.Arn}/invocations'
        OperationName: 'lambda'
        ResourceId: !Ref ApiGatewayResource
        RestApiId: !Ref ApiGatewayRestApi
    

    注意integration type 设置为AWS 而不是AWS_PROXY。有关 CFT 类型的更多信息,请查看documentation。另外需要注意的是,如果没有代理,您可能需要提供模型和 req/res 模板。 SAM CLI local 也不能与 req/res 模板一起使用。

    【讨论】:

      猜你喜欢
      • 2020-07-22
      • 2018-05-04
      • 1970-01-01
      • 2017-04-07
      • 2018-10-27
      • 1970-01-01
      • 2017-10-01
      • 1970-01-01
      • 2019-07-09
      相关资源
      最近更新 更多