【问题标题】:API Gateway HTTP Proxy integration with aws-sam (NOT Lambda Proxy)API Gateway HTTP 代理与 aws-sam 的集成(不是 Lambda 代理)
【发布时间】:2022-04-01 21:27:18
【问题描述】:

我正在尝试使用 aws-sam 在本地开发/模拟我的 API 网关。我的 API 网关大量使用了HTTP proxy integrations。生产资源如下所示:

所有 aws-sam 示例whichI'vefound,以及相关文档和Q&A,都使用 Lambda 集成/硬依赖作为代理资源的 Lambda 函数,而不是HTTP 代理集成。

有没有办法为 aws-sam 应用程序定义 HTTP 代理资源?(相对于 Lambda 代理资源?)

相关:

【问题讨论】:

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


    【解决方案1】:

    是的,SAM 只是 Cloud Formation 转换。因此,您仍然可以像往常一样创建传统的 CloudFormation 对象。您也可以将它附加到您的 Serverless::API,但我对此不太有信心。

    Resource:
      Api:
        Type: 'AWS::ApiGateway::RestApi'
        Properties:
          Description: A test API
          Name: MyRestAPI
    
        Type: 'AWS::ApiGateway::Resource'
        Properties:
          ParentId: !GetAtt Api.RootResourceId
          RestApiId: !Ref Api
          PathPart: '{proxy+}'
    

    或可能(未经测试):

    Resource:
      Api:
        Type: 'AWS::Serverless::Api'
        Properties:
          Description: A test API
          Name: MyRestAPI
    
        Type: 'AWS::ApiGateway::Resource'
        Properties:
          ParentId: !GetAtt Api.RootResourceId
          RestApiId: !Ref Api
          PathPart: '{proxy+}'
    

    【讨论】:

    猜你喜欢
    • 2019-08-03
    • 2021-09-11
    • 2017-04-07
    • 2019-08-11
    • 2019-08-03
    • 1970-01-01
    • 2018-05-04
    • 1970-01-01
    • 2021-01-24
    相关资源
    最近更新 更多