API网关HTTP代理与aws-sam集成(非Lambda代理)

Dan*_* B. 5 aws-api-gateway aws-sam-cli aws-sam

我正在尝试使用aws-sam在本地开发/模拟我的API网关。我的API网关充分利用了HTTP代理集成。生产资源如下所示:

API网关资源方法上的HTTP代理集成的屏幕截图

所有的AWS-SAM的例子其中 发现,以及相关的文档和Q&A,使用LAMBDA集成/对lambda函数作为代理的资源硬依赖,对一个HTTP代理服务器的整合。

有没有办法为aws-sam应用程序定义HTTP代理资源?(而不是Lambda代理资源?)

有关:

J.A*_*s V 5

是的,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+}'
Run Code Online (Sandbox Code Playgroud)

或可能(未经测试):

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+}'
Run Code Online (Sandbox Code Playgroud)