Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services 云形成定义的lambda和api网关_Amazon Web Services_Aws Lambda_Amazon Cloudformation_Aws Api Gateway - Fatal编程技术网

Amazon web services 云形成定义的lambda和api网关

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:

我想向用于lambda的端点添加授权。 因为我不能在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)
看起来,当Cloud Formation试图显式创建产品资源时,它已经由lambda定义隐式创建,

我建议SAM(无服务器应用程序模型)使用swagger部署此类资源。SAM的模板类似于CloudFormation。我建议SAM(无服务器应用程序模型)使用swagger部署此类资源。SAM的模板就像一个云结构。