Aws lambda API网关中的OpenAPI和Lambda集成
当我使用CloudFormation部署一个具有Lambda集成的API时,我能够使用标准CloudFormation语法(如Aws lambda API网关中的OpenAPI和Lambda集成,aws-lambda,swagger,amazon-cloudformation,aws-api-gateway,openapi,Aws Lambda,Swagger,Amazon Cloudformation,Aws Api Gateway,Openapi,当我使用CloudFormation部署一个具有Lambda集成的API时,我能够使用标准CloudFormation语法(如)将Lambda函数动态链接到API方法!参考和!GetAtt: SomeMethod: Type: AWS::ApiGateway::Method Properties: HttpMethod: PUT Integration: Type: AWS_PROXY IntegrationHttpMethod: POST #
)将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
现在,当我想引用一个外部swagger文件来定义我的API时,我可以通过AWS::ApiGateway::RestApi
对象上的BodyS3Location
属性来实现,我不明白如何将定义的方法动态链接到Lambda函数
描述如何将方法静态链接到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"
}
但是,如果我的Lambda函数是同一个CloudFormation堆栈的一部分(它现在是并且应该是),并且我想要部署多个实例,那么如何将我的API与Lambda动态集成?我不能用!参考
或!GetAttr
因为我不在CloudFormation的上下文中