![](/img/trans.png)
[英]API Gateway HTTP Proxy integration with aws-sam (NOT Lambda Proxy)
[英]How to remove tickmark Use Lambda Proxy integration on aws api
你不能用 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 类型检查文档的更多信息。 同样需要注意的是,如果没有代理,您可能需要提供 model 和 req/res 模板。 此外,SAM CLI local 将无法与 req/res 模板一起使用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.