serverless / template

Compose & provision a collection of Serverless Components
https://serverless.com
Apache License 2.0
10 stars 6 forks source link

Add Support for System Environmental Variables - v2 #5

Closed laardee closed 5 years ago

laardee commented 5 years ago

This is version 2. In this version, the env. prefix is used with system environmental variables.

A dummy test service yaml, executed with NAME=name STAGE=dev slsdev

name-dev: dev-service
envStage: ${env.STAGE}
envName: ${env.NAME}
name: ${${envName}-${envStage}} # first resolves to '${name-dev}' and then to 'dev-service'

# this is just a mock component, it only passes inputs to output
test-component:
  component: "../env-vars"
  inputs:
    stage1: ${env.STAGE}
    stage2: ${envStage}
    name: ${name}

output is

  test-component: 
    stage1: dev
    stage2: dev
    name:   dev-service