API网关HTTP代理与aws-sam集成(非Lambda代理) [英] API Gateway HTTP Proxy integration with aws-sam (NOT Lambda Proxy)
问题描述
我正在尝试使用aws-sam在本地开发/模拟我的API网关。我的API网关自由使用 HTTP代理集成。生产资源看起来像这样:
I am trying to use aws-sam to develop / simulate my API Gateway locally. My API gateway makes liberal use of the HTTP proxy integrations. The production Resource looks like this:
< img src = https://i.stack.imgur.com/6fFss.png alt = API网关资源方法上的HTTP代理集成的屏幕截图>
所有aws-sam示例其中 我已经 找到,以及相关文档和,使用Lambda集成/与HTTP代理集成相比,对Lambda函数作为代理资源有着严格的依赖。
All of the aws-sam examples which I've found, as well as related documentation and Q&A, use the Lambda integrations / have a hard dependency on a Lambda function being the proxied resource, versus an HTTP Proxy integration.
是否可以为aws-sam应用程序定义HTTP代理资源?(与Lambda代理资源相对?)
Is there a way to define an HTTP Proxy resource for an aws-sam application? (As opposed to a Lambda Proxy resource?)
相关
- 使用SAM创建API网关代理资源
- 我也在尝试解决相同的问题在以下帖子中使用serverless-offline- API网关HTTP代理与无服务器离线(而不是Lambda代理)的集成
推荐答案
是的,SAM只是云形成转换。因此,您仍然可以照常创建传统的CloudFormation对象。您也许也可以将其附加到您的Serverless :: API上,但对此我不太自信。
Yes, SAM is just a Cloud Formation transform. So you can still create traditional CloudFormation objects as usual. You might be able to also attach it to your Serverless::API but I am less confident about that.
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+}'
这篇关于API网关HTTP代理与aws-sam集成(非Lambda代理)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!