Skip to content

Set stage based on environment variable #21

@hbarcelos

Description

@hbarcelos

I'm combining the use of this plugin with serverless-dotenv-plugin.
ifelse is declared AFTER dotenv:

plugins:
  - serverless-webpack
  - serverless-dotenv-plugin
  - serverless-plugin-ifelse

Then I have the following:

  chainId: ${env:CHAIN_ID, "42"}
  serverlessIfElse:
    - If: '"${self:custom.chainId}" == "1"'
      Set:
        provider.stage: mainnet
      ElseSet:
        provider.stage: kovan

Even though the following line is logged when I run serverless deploy,

> Serverless: serverless-plugin-ifelse - Value Changed for : provider.stage to: mainnet

the stack created use kovan as the value set, as the CloudFormation template contains things like:

    "HelloLogGroup": {
      "Type": "AWS::Logs::LogGroup",
      "Properties": {
        "LogGroupName": "/aws/lambda/linguo-bot-kovan-hello"
      }
    },

So basically even though the plugin says it changed the stage value, it has no effect.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions