Kir*_*rst 6 aws-cloudformation swagger aws-lambda aws-api-gateway openapi
当我使用 CloudFormation 部署具有 Lambda 集成的 API 时,我可以使用标准 CloudFormation 语法(例如!Ref和 )将 Lambda 函数动态链接到 API 方法!GetAtt:
SomeMethod:
Type: AWS::ApiGateway::Method
Properties:
HttpMethod: PUT
Integration:
Type: AWS_PROXY
IntegrationHttpMethod: POST
# this is defined during deployment
Uri: !Join ["", ["arn:aws:apigateway:", !Ref "AWS::Region", ":lambda:path/2015-03-31/functions/", !GetAtt LambdaFunction.Arn, "/invocations"]]
IntegrationResponses:
- StatusCode: 200
ResourceId: !Ref APIResource
Run Code Online (Sandbox Code Playgroud)
现在,当我想引用外部 swagger 文件来定义我的 API(可以通过对象BodyS3Location上的属性来实现)时AWS::ApiGateway::RestApi,我无法理解如何将定义的方法动态链接到 Lambda 函数。
API as Lambda Proxy描述了如何将方法静态链接到 Lambda 函数,即
"x-amazon-apigateway-integration": {
"credentials": "arn:aws:iam::123456789012:role/apigAwsProxyRole",
"responses": { ... },
# this is statically defined
"uri": "arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:123456789012:function:Calc/invocations",
"httpMethod": "POST",
"requestTemplates": { ... },
"type": "aws"
}
Run Code Online (Sandbox Code Playgroud)
但是,如果我的 Lambda 函数是同一个 CloudFormation 堆栈的一部分(它确实是并且应该是),并且我想部署多个实例,那么如何将我的 API 与 Lambda 动态集成?我无法使用!Refor!GetAttr因为我不在 CloudFormation 的上下文中。
| 归档时间: |
|
| 查看次数: |
596 次 |
| 最近记录: |