Dealing with file path changes when using the --config option

I’m quite new to serverless and trying to find out more about best practices. Currently I’m working on a serverless project where we are trying to make use of the --config option when doing our deployments.

This is primarily due to our automated deployments. The way our repo is structured, our serverless.yml file is not located in the root directory of the project. Ideally we wouldn’t want to have our pipeline cd down to the directory containing serverless.yml file to run the serverless deploy command. We would however like to keep this an option for manual deployments while testing.

The problem occurs when we try make use of {file(...)} when importing additional configuration. At this point, the project is large enough that this is a bit of a necessity.

For example we currently have a path set as:

functions: 
  - ${file(functions.yml)}

When running this from the root directory however this breaks as the proper path should be:

functions: 
  - ${file(serverless/functions.yml)}

The best idea we can come up with is to use environment variables to set these paths. This is something that I would like to avoid however because in my experience they can quickly become hard to keep track of and make debugging rather difficult.

Would love to get some more opinions from the community,
Thanks!