AWS Lambda environment variables cleared/removed on sls deploy

Hi there!

I wanted a bit of clarification on what the sls deploy command does to existing AWS environment variables.

The issue my team is having is the following:

  • We setup Circle CI to deploy our AWS lambdas via sls deploy --stage command
  • When Circle CI runs sls deploy it looks like all existing environment variables get removed since we are not setting them in serverless.yml

We don’t want our environment variables to get wiped for every deploy, is there a way around this?

I wrote something on this a while ago Why are my environment variables replaced during Serverless Framework deployments?

You can’t prevent it from happening but you can probably work around it.