Reference variables in multiple files

As a newb, i was thinking that i could “import” multiple files into a serverless.yml file, say like this:

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

But, only the “custom” variables work. The others show up all weird when i run sls print. For example:

  name: !<,2002:js/undefined> ''
  runtime: !<,2002:js/undefined> ''

Is there something special about “custom”?

I don’t see there is the keyword named common in serverless framework

If you need to reference from two files, you can do this:

  common:  ${file(../common.yml)}
  env: ${file(../.env.yml)}

Then you can reference those variables with (example):

    comm_variable1: ${self:custom.common.comm_var1}
    env_var2: ${self:custom.env.env_var2}

Hope that helps.

Yes, it does. Thanks Bill. I guess my confusion is because there doesn’t seem to be any mention in the docs that “custom” is a keyword. My assumption was that i could choose whatever keys i wanted.


If you need to know the list of all available properties in serverless.yml when the provider is set to aws. Please go through this document Serverless.ym Reference

Interesting part is, custom is not in the list. Seems the document need be updated.