I want to reuse my serverless.yml in different environments (dev, test, prod).
In the config I have:
provider:
  name: aws
  stage: ${opt:stage, 'dev'}
  environment:
    NODE_ENV: ${self:provider.stage}
Right now the value will be dev, test or prod (all in lower-case).
Is there a way to convert it toUpperCase() in a way that the input and self:provider:stage will stay as it is (i.e. lower-case) but the value of NODE_ENV will be UPPER-CASE?
AFAIK, there is no such function in YAML.
You can achieve what you want though by using a map between the lowercase and uppercase names.
custom:
  environments:
    dev: DEV
    test: TEST
    prod: PROD
provider:
  name: aws
  stage: ${opt:stage, 'dev'}
  environment:
    NODE_ENV: ${self:custom.environments.${self:provider.stage}}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With