I have a file containing custom settings that are shared across multiple serverless services. custom: ${file(../shared/all)}
Is it possible to add additional custom settings in my serverless yml configuration that are specific to the one service? What is the syntax? Below is an example of what doesn’t work
# serverless.yml
service: new-service
provider: aws
custom: ${file(../myCustomFile.yml)} # You can reference the entire file
functions:
hello:
handler: handler.hello
events:
- schedule: ${file(../myCustomFile.yml):globalSchedule} # Or you can reference a specific property
world:
handler: handler.world
events:
- schedule: ${self:custom.globalSchedule} # This would also work in this case
This does not answer my question. This response demonstrates how to use an external file that contains custom values. I’m already doing that as stated in my original post.
The goal is to use the common custom file plus those custom settings specific to just this single service.
Hmm… in earlier releases of Serverless ${self:provider.stage} was always the stage you’re actually deploying into (i.e. if you changed it using -s it would contain that value instead of the one in the config). I’ve just tested with the latest release and it’s no longer doing that. Time to upgrade my configs
Using ${self:opt.stage, provider.stage} failed for me with an Invalid variable reference syntax for variable provider.stage error. I had to specify the self: prefix for provider.stage as well, so this is what I ultimately used that worked: ${self:opt.stage, self:provider.stage}