Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Serverless YML toUpperCase

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?

like image 648
iaforek Avatar asked Jan 12 '18 12:01

iaforek


1 Answers

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}}
like image 182
Noel Llevares Avatar answered Sep 25 '22 18:09

Noel Llevares