How to set and get environment variables for Lambda functions (Node.js)

How to set and get environment variables for Lambda functions (Node.js)

This is how to set environment variables for the Lambda function (Node.js).

Click on “Environment Variables” under the Lambda function to display the settings screen.

How to set and get environment variables for Lambda functions (Node.js)

To retrieve the environment variables set by the Lambda function, retrieve them as follows

process.env.NODE_ENV

It is customary to start with NODE_. Also, environment variables are strings, even if they are numbers.

Here is an example

process.env.NODE_ENV = 1;
console.log(process.env.NODE_ENV);
console.log(typeof process.env.NODE_ENV);

The result will be STRING as follows

1
string

コメント

Discover more from 株式会社CONFRAGE ITソリューション事業部

Subscribe now to keep reading and get access to the full archive.

Continue reading

Copied title and URL