Accessing stage or env variables in lambda

I was battling this. After looking around a lot I finally found the solution in the sls deploy function reference.

Note: Because this command is only deploying the function code, function properties such as environment variables and events will not be deployed. Those properties are deployed via CloudFormation, which does not execute with this command.

In other words, you gotta use sls deploy (without function) to update environment vars.

3 Likes