Wrapping up the Best Practices

Link to chapter - https://serverless-stack.com/chapters/wrapping-up-the-best-practices.html

I am attempting to expand the tutorial to include a /notes2-api as part of the project. I can’t seem to edit the notes2 serverless.yml to create it. I can create it as a separate url. but can’t figure out how to create it so there is a structure:

/billing
/notes
/notes2

I use parts of the billing-api yml such as the api imports

apiGateway:
restApiId:
‘Fn::ImportValue’: {self:custom.stage}-ExtApiGatewayRestApiId restApiRootResourceId: 'Fn::ImportValue': {self:custom.stage}-ExtApiGatewayRestApiRootResourceId

but it still fails with:
The CloudFormation template is invalid: Template format error: Unresolved resource dependencies [ApiGatewayRestApi] in the Resources block of the template.

I obviously have something wrong that causes the error in the cloudformation template, but I don’t see many moving parts and which ones need some change to get the correct values.

notes2 serverless.yml

service: notes-app-ext-notes2-api

plugins:
  - serverless-bundle
  - serverless-offline

custom: ${file(../../serverless.common.yml):custom}

package:
  individually: true

provider:
  name: aws
  runtime: nodejs10.x
  stage: dev
  region: us-west-2
  tracing:
    lambda: true

  apiGateway:
    restApiId:
      'Fn::ImportValue': ${self:custom.stage}-ExtApiGatewayRestApiId
    restApiRootResourceId:
      'Fn::ImportValue': ${self:custom.stage}-ExtApiGatewayRestApiRootResourceId    

  environment:
    stage: ${self:custom.stage}
    resourcesStage: ${self:custom.resourcesStage}

  iamRoleStatements:
    - ${file(../../serverless.common.yml):lambdaPolicyXRay}
    - Effect: Allow
      Action:
        - dynamodb:DescribeTable
        - dynamodb:Query
        - dynamodb:Scan
        - dynamodb:GetItem
        - dynamodb:PutItem
        - dynamodb:UpdateItem
        - dynamodb:DeleteItem

      Resource:
        - 'Fn::ImportValue': ${self:custom.resourcesStage}-ExtNotes2TableArn

functions:
  create:
    handler: create.main
    events:
      - http:
          path: notes2
          method: post
          cors: true
          authorizer: aws_iam

  get:
    handler: get.main
    events:
      - http:
          path: notes2/{id}
          method: get
          cors: true
          authorizer: aws_iam

  list:
    handler: list.main
    events:
      - http:
          path: notes2
          method: get
          cors: true
          authorizer: aws_iam

  update:
    handler: update.main
    events:
      - http:
          path: notes2/{id}
          method: put
          cors: true
          authorizer: aws_iam

  delete:
    handler: delete.main
    events:
      - http:
          path: notes2/{id}
          method: delete
          cors: true
          authorizer: aws_iam

resources:
  - ${file(resources/api-gateway-errors.yml)}
  - ${file(resources/cognito-policy.yml)}

I think we talked about this. But we needed to remove the included files in the resources section.