I’m trying to write a simple serverless plugin. The main reason for this tool to exist as a plugin is so that I can make the serverless.yml serve as source of truth for some configuration data that needs to exist in some lambda’s as well as some other automation invoked by plugin.
How do I resolve the variable references in the serverless.yml from my plugin?
For example – i have a key in serverless.yml:
custom:
defaultStage: stage
stage: ${opt:stage, self:custom.defaultStage}
config: ${file(env-vars/${self:custom.stage}.yml)}
within my plugin constructor:
constructor(serverless: any) {
console.log(serverless.service.custom.config);
}
above prints:
${file(env-vars/${self:custom.stage}.yml)}
…
Thanks!