# Define explicitly resource method for lambda

**URL:** <https://forum.serverless.com/t/define-explicitly-resource-method-for-lambda/7248>\
**Category:** Serverless Framework\
**Created:** [February 3, 2019, 2:49pm UTC](https://forum.serverless.com/t/define-explicitly-resource-method-for-lambda/7248 "2019-02-03T14:49:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![5minutes2start](https://avatars.discourse-cdn.com/v4/letter/5/c67d28/32.png) [@5minutes2start](https://forum.serverless.com/u/5minutes2start)\
**Post date:** [February 3, 2019, 2:49pm UTC](https://forum.serverless.com/t/define-explicitly-resource-method-for-lambda/7248/1 "2019-02-03T14:49:07Z")

</div>

Hi,

I want to add authorization to endpoints used for lambda.  
Since I can not set up this in Lambda definition, I create methods explicitly.

```
 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

```

Unfortunately I get error:

```
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)

```

It seems like when Cloud Formation tries to create explicitly products resource, it is already there created implicitly by lambda definition,
