Multi-Repo and Referencing Table names and other resources

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?

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
...
1 Like

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

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

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