title: Sharing an API gateway between micro services in Serverless
body: <p>I'm fairly new to Serverless. I recently hit the dreaded 200 resource limit issue on Serverless and hence I'm trying to break down my services and use a common API gateway between them but I keep getting <code>Another resource with the same parent already has this name: assets</code>. I am using the common api gateway property because I don't have a domain for this service. </p>
  
  <p>This is my main <code>serverless.yml</code></p>
  
  <pre><code>    app: xxx
      org: xxx
      service: xxx
      provider:
        name: aws
        runtime: nodejs12.x
        region: xxx
  functions: 
  ....
      resources:
        Outputs:
  
          ApiGatewayRestId:
            Value:
              Ref: ApiGatewayRestApi
            Export:
              Name: assetsapi-${opt:stage, self:provider.stage}-ApiGatewayRestId
          RootResourceId:
            Value:
              Fn::GetAtt:
                - ApiGatewayRestApi
                - RootResourceId
            Export:
              Name: assetsapi-${opt:stage, self:provider.stage}-RootResourceId
          IamRoleLambdaExecution:
            Value:
              Fn::GetAtt: IamRoleLambdaExecution.Arn
            Export:
              Name: assetsapi-${opt:stage, self:provider.stage}-IamRoleLambdaExecution
          ApiGatewayResourceMaintainence:
            Value:
              Ref: ApiGatewayResourceMaintainence
            Export:
              Name: assetsapi-${opt:stage, self:provider.stage}-ApiGatewayResourceMaintainence
      Resources:
          # Rest API
          ApiGatewayRestApi:
            Type: AWS::ApiGateway::RestApi
            Properties:
              Name: assetsapi
              Description: assets API Gateway
  
          # Rest API Paths
          ApiGatewayResourceMaintainence:
            Type: AWS::ApiGateway::Resource
            Properties:
              RestApiId: { Ref: 'ApiGatewayRestApi' }
              ParentId: { Fn::GetAtt: 'ApiGatewayRestApi.RootResourceId' }
              PathPart: maintain
  </code></pre>
  
  <p>This the serverless.yml file for the second service which resides inside the path <code>api/maintainence/serverless.yml</code></p>
  
  <pre><code>    service: maintainencemanagementservice
      custom:
        stage: '${opt:stage, self:provider.stage}'
        region: ${opt:region, self:provider.region}
        prefix: ${self:service}-${self:custom.region}-${self:custom.stage}
        rootApiGatewayId: 'assets-api-${self:custom.region}-${self:custom.stage}-restApiId'
        rootApiGatewayResourceId: 'assets-api-${self:custom.region}-${self:custom.stage}-rootResourceId'
      provider:
        name: aws
        runtime: nodejs12.x
        stage: dev
        region: xxxx
        apiGateway:
          restApiId:
            Fn::ImportValue: assetsapi-${opt:stage, self:provider.stage}-ApiGatewayRestId
          restApiRootResourceId:
            Fn::ImportValue: assetsapi-${opt:stage, self:provider.stage}-RootResourceId
          restApiResources:
            /maintainence:
              Fn::ImportValue: assetsapi-${opt:stage, self:provider.stage}-ApiGatewayResourceMaintainence,
        role:
          Fn::ImportValue: assetsapi-${opt:stage, self:provider.stage}-IamRoleLambdaExecution
  </code></pre>