Multi-Repo and Referencing Table names and other resources


#1

In the API Gateway Domains chapter the guides talks about referencing table names from a different serverless.yml file but if the database service is in a different repo we can’t do this:

provider:
  name: aws
  runtime: nodejs8.10
  stage: dev
  region: us-east-1

  # These environment variables are made available to our functions
  # under process.env.
  environment:
    tableName:
      ${file(../database/serverless.yml):custom.tableName} <-- serverless.yml won't be available
...

How would we reference the dynamo table name if we split out the database into a different repo?


#2

Ok I think I answered my own question … in the previous chapter the tablename is exported like this:

Outputs:
    Value:
      Ref: NotesTable
    Export:
      Name: NotesTableName

So it should be trivial to add do this:

provider:
  name: aws
  runtime: nodejs8.10
  stage: dev
  region: us-east-1

  # These environment variables are made available to our functions
  # under process.env.
  environment:
    tableName:
      'Fn::ImportValue': NotesTableName
...

#3

Yup that is one way. You can also directly refer to the table through the file.


#4

Right but how would you access …/database/serverless.yml if its in a different repo?


#5

Yeah this one is only applicable to the mono-repo case.