我的应用程序有一个 SAM 模板。每次我使用新的 API Gateway 阶段名称部署我的 SAM 模板时,它都会替换之前创建的阶段。
所以,发现这篇文章可以帮助我发布指向不同 lambda 版本的不同版本。 https://aws.amazon.com/blogs/compute/using-api-gateway-stage-variables-to-manage-lambda-functions/
但是,为此,我必须在部署后手动更改 API 网关。那么,有什么办法可以使用 AWS SAM 做到这一点吗?
例如,请考虑以下 CloudFormation 模板摘录:
ProxyMethod:
Type: AWS::ApiGateway::Method
Properties:
HttpMethod: ANY
RestApiId: !Ref Api # AWS::ApiGateway::RestApi defined elsewhere
ResourceId: !Ref ProxyResource # AWS::ApiGateway::Resource defined elsewhere
AuthorizationType: NONE #auth is done at the public API layer
Integration:
# client request passed through as-is. "Lambda proxy integration"
Type: AWS_PROXY
Uri: !Join
- ''
- - 'arn:aws:apigateway:'
- !Sub ${AWS::Region}
- ':lambda:path/2015-03-31/functions/${!stageVariables.FunctionArn}/invocations'
IntegrationHttpMethod: ANY
PassthroughBehavior: WHEN_NO_MATCH
Run Code Online (Sandbox Code Playgroud)
这应该允许我使用在运行时确定的 …
amazon-web-services aws-cloudformation aws-lambda aws-api-gateway aws-sam