How to check the list of AWS Lambda default environment variables

Tadashi Shigeoka ·  Thu, December 20, 2018

I’ll introduce the official documentation for AWS Lambda default environment variables, Node.js sample code to check the list, and execution results.

AWS | Amazon Web Services

[Documentation] Environment Variables Available in Lambda

It’s documented in the AWS official documentation Environment variables available in Lambda functions - AWS Lambda.

How to investigate Lambda environment variables yourself

Prerequisites

  • Node.js v8.10.0
  • Serverless Framework v1.35.1

Sample code to output Lambda environment variable list

Let’s assume you have the following Node.js code deployed with Serverless Framework.

You can check the list of environment variables by outputting process.env with console.log().

module.exports.showEnv = async (event, context) => {
  return console.log(process.env);
};

Lambda environment variable list output results

The execution result of the showEnv function looks like this:

{
  PATH: '/var/lang/bin:/usr/local/bin:/usr/bin/:/bin:/opt/bin',
  LD_LIBRARY_PATH: '/var/lang/lib:/lib64:/usr/lib64:/var/runtime:/var/runtime/lib:/var/task:/var/task/lib:/opt/lib',
  LANG: 'en_US.UTF-8',
  TZ: ':UTC',
  LAMBDA_TASK_ROOT: '/var/task',
  LAMBDA_RUNTIME_DIR: '/var/runtime',
  AWS_REGION: 'us-east-1',
  AWS_DEFAULT_REGION: 'us-east-1',
  AWS_LAMBDA_LOG_GROUP_NAME: '/aws/lambda/aws-nodejs-dev-showEnv',
  AWS_LAMBDA_LOG_STREAM_NAME: '2018/12/24/[$LATEST]xxxxxxxxxx',
  AWS_LAMBDA_FUNCTION_NAME: 'aws-nodejs-dev-showEnv',
  AWS_LAMBDA_FUNCTION_MEMORY_SIZE: '1024',
  AWS_LAMBDA_FUNCTION_VERSION: '$LATEST',
  _AWS_XRAY_DAEMON_ADDRESS: '169.254.xxx.xxx',
  _AWS_XRAY_DAEMON_PORT: '2000',
  AWS_XRAY_DAEMON_ADDRESS: '169.254.xxx.xxx:2000',
  AWS_XRAY_CONTEXT_MISSING: 'LOG_ERROR',
  _X_AMZN_TRACE_ID: 'Root=1-xxxxxxxxxx;Parent=xxxxxxxxxx;Sampled=0',
  AWS_EXECUTION_ENV: 'AWS_Lambda_nodejs8.10',
  _HANDLER: 'handler.showEnv',
  NODE_PATH: '/opt/nodejs/node8/node_modules:/opt/nodejs/node_modules:/var/runtime/node_modules:/var/runtime:/var/task:/var/runtime/node_modules',
  AWS_ACCESS_KEY_ID: 'xxxxxxxxxx',
  AWS_SECRET_ACCESS_KEY: 'xxxxxxxxxxxxxxxxxxxx',
  AWS_SESSION_TOKEN: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=='
}

That’s all from the Gemba about AWS Lambda default environment variables.