代码之家  ›  专栏  ›  技术社区  ›  gka

云形成定义的lambda和api网关

  •  1
  • gka  · 技术社区  · 7 年前

    因为我不能在Lambda定义中设置它,所以我显式地创建方法。

     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)
    

    0 回复  |  直到 7 年前