Serverless YML toUpperCase

You can achieve something to this effect using the reference variables in javascript files functionality provided.

To take your example, this should work (assuming you're running in a node.js environment that supports modern syntax)

serverless.yml

...
provider:
  name: aws
  stage: ${opt:stage, 'dev'}
  environment:
    NODE_ENV: ${file(./yml-helpers.js):provider.stage.uppercase}
...

yml-helpers.js (adjacent to serverless.yml)

module.exports.provider = serverless => {
  // The `serverless` argument containers all the information in the .yml file
  const provider = serverless.service.provider;

  return Object.entries(provider).reduce(
    (accumulator, [key, value]) => ({
      ...accumulator,
      [key]:
        typeof value === 'string'
          ? {
              lowercase: value.toLowerCase(),
              uppercase: value.toUpperCase()
            }
          : value
    }),
    {}
  )
};

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}}