Deploy a package with diferent environment variables?

Hi there,
I have a serverless.yaml file that defines certain environmental variables and functions.
Is it possible to package those functions to a zip file and then deploy them using a different set of environment variables?
I mean, it’s not clear to me what happens with the env vars defined in the serverless.yml when it creates the package. Are they embedded in it in some way?
And when deploying a specific package, is there a way to overwrite, or set them?


@hernanc checkout the serverless-dotenv-plugin module @ u can use it to load .env, then u can have a .env file for each environment

For lambda they are part of the lambda settings, sls use cloudformation to configure lambda env variables

Maybe you can take a look on the serverless-plugin-ifelse

  currentStage: ${opt:stage, self:provider.stage}
      - If: '"${self:custom.currentStage}" == "dev"'
          - functions.yourfunction1.environment.variable1 = abc
      - If: '"${self:custom.currentStage}" == "uat"'
          - functions.yourfunction1.environment.variable1 = zyx

Are you the plugin author or promoting it, its been 3 posts in a row that you nane it hehe

@jfn0 Hahaa, no. I just found this plugin yesterday and it solved all my problem like having different env have different stageVar etc. My serverless.yaml file reduces from 700++ lines to less than 200.