Amazon web services 云形成定义的lambda和api网关
我想向用于lambda的端点添加授权。 因为我不能在Lambda定义中设置它,所以我显式地创建方法Amazon web services 云形成定义的lambda和api网关,amazon-web-services,aws-lambda,amazon-cloudformation,aws-api-gateway,Amazon Web Services,Aws Lambda,Amazon Cloudformation,Aws Api Gateway,我想向用于lambda的端点添加授权。 因为我不能在Lambda定义中设置它,所以我显式地创建方法 LambdaName: Type: AWS::Serverless::Function Properties: CodeUri: ./lambdaDir FunctionName: LambdaName Events: APIEvent: Type: Api Properties:
LambdaName:
Type: AWS::Serverless::Function
Properties:
CodeUri: ./lambdaDir
FunctionName: LambdaName
Events:
APIEvent:
Type: Api
Properties:
RestApiId: !Ref MyApi
Path: /products
Method: POST
MyApi:
Type: AWS::Serverless::Api
Properties:
Name: MyApi
StageName: dev
ProductsResource:
Type: AWS::ApiGateway::Resource
Properties:
ParentId:
Fn::GetAtt:
- "MyApi"
- "RootResourceId"
PathPart: products
RestApiId: !Ref MyApi
ProductsCreateApiMethod:
Type: AWS::ApiGateway::Method
Properties:
AuthorizationType: NONE
AuthorizerId: !Ref Authorizer
AuthorizationScopes:
- someScope
RestApiId: !Ref MyApi
HttpMethod: POST
ResourceId: !Ref ProductsResource
不幸的是,我得到了一个错误:
Another resource with the same parent already has this name: products (Service: AmazonApiGateway; Status Code: 409; Error Code: ConflictException; Request ID: 03ca26de-27be-11e9-82bb-536e557773f3)
看起来,当Cloud Formation试图显式创建产品资源时,它已经由lambda定义隐式创建,我建议SAM(无服务器应用程序模型)使用swagger部署此类资源。SAM的模板类似于CloudFormation。我建议SAM(无服务器应用程序模型)使用swagger部署此类资源。SAM的模板就像一个云结构。