Can serverless framework "invoke local" CLI pass lambda environment variables?

I am going to create several lambdas configured with some environment variables using serverless framework, and use “sls invoke local” to verify it before rolling out.

My question is how to pass the lambda environment variables to my lambda when using “sls invoke local”?

The environment variables defined in the serverless.yml configuration file are automatically populated when using sls.

You can then access them normally within your Lambda functions. For example, if you are using Node.js, it would be via process.env.

1 Like