Guide to default AWS Lambda environment variables
Tags: aws, serverless, lambda
Published: 2022-06-06 19:34:43

---
title: Guide to default AWS Lambda environment variables
published: true
description: A walkthrough of the default AWS Lambda environment variables
tags: aws, serverless, lambda
canonical_url: https://cloudash.dev/blog/aws-lambda-default-environment-variables
---

AWS Lambda runtimes set a number of default environment variables during initialization of every serverless function.

The following variables are **reserved** and cannot be set in your function configuration:

- `_HANDLER` - The location of a functions's handler.
- `_X_AMZN_TRACE_ID` - [X-Ray tracing header](https://docs.aws.amazon.com/lambda/latest/dg/services-xray.html)
- `AWS_REGION` - The region the function is running in (we all know it's `us-east-1`).
- `AWS_EXECUTION_ENV` - The [AWS Lambda runtime identifier](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html). Examples: `AWS_Lambda_nodejs14.x`, `AWS_Lambda_java8`.
- `AWS_LAMBDA_FUNCTION_NAME` - The name of the function (which is either "hello world" or IaC randomly generated one, there's no between).
- `AWS_LAMBDA_FUNCTION_MEMORY_SIZE` - The amount of memory allocated to the function (e.g. 1024MB).
- `AWS_LAMBDA_FUNCTION_VERSION` - The version of the function (e.g. `$LATEST`).
- `AWS_LAMBDA_INITIALIZATION_TYPE` - The initialization type of the function, can be either `on-demand` or `provisioned-concurrency`.
- `AWS_LAMBDA_LOG_GROUP_NAME` - The name of the CloudWatch log group.
- `AWS_LAMBDA_LOG_STREAM_NAME` - The name of the CloudWatch stream.
- `AWS_ACCESS_KEY`, `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_SESSION_TOKEN` - The access keys obtained from the [function's execution role](https://docs.aws.amazon.com/lambda/latest/dg/lambda-intro-execution-role.html). Be careful with those, read [SAS-7: Insecure Application Secrets Storage](https://github.com/puresec/sas-top-10#sas-7-insecure-application-secrets-storage) for guidance. This post on [Security for AWS Lambda Serverless Applications](https://www.trendmicro.com/fr_fr/devops/21/g/security-for-aws-lambda-serverless-applications.html) is also a good place to start.
- `AWS_LAMBDA_RUNTIME_API` - The host and port of the [AWS Lambda runtime API](https://docs.aws.amazon.com/lambda/latest/dg/runtimes-api.html), example: `127.0.0.1:9001`
- `LAMBDA_TASK_ROOT` - The path to your Lambda function code
- `LAMBDA_RUNTIME_DIR` - The path to runtime libraries
- `TZ` - The timezone information, e.g. `:UTC'`

In addition to that, AWS Lambda runtime sets additional variables that are **not** reserved and can be extended in your function configuration:

- `LANG` - The language of your function's runtime, e.g. `en_US.UTF-8`
- `PATH` - The execution path, e.g. `/var/lang/bin:/usr/local/bin:/usr/bin/:/bin:/opt/bin`
- `LD_LIBRARY_PATH` - The system library path, e.g. `/var/lang/lib:/lib64: /usr/lib64:/var/runtime: /var/runtime/lib:/var/task:/var/task/lib:/opt/lib`
- `AWS_XRAY_CONTEXT_MISSING` - Quoting [the docs](https://docs.aws.amazon.com/lambda/latest/dg/configuration-envvars.html#configuration-envvars-runtime): "For X-Ray tracing, Lambda sets this to `LOG_ERROR` to avoid throwing runtime errors from the X-Ray SDK."
- `AWS_XRAY_DAEMON_ADDRESS` - The IP address and port of the X-Ray daemon.

There are also a few runtime-specific environment variables:

- `NODE_PATH` - A [node.js](https://docs.aws.amazon.com/lambda/latest/dg/lambda-nodejs.html) env variable, containing node.js library path, e.g. `/opt/nodejs/node14/node_modules: /opt/nodejs/node_modules: /var/runtime/node_modules:/var/runtime:/var/task`
- `PYTHONPATH` - The Python library path
- `GEM_PATH` - The Ruby library path
- `AWS_LAMBDA_DOTNET_PREJIT` - Quoting [the docs](https://docs.aws.amazon.com/lambda/latest/dg/configuration-envvars.html#configuration-envvars-runtime): "For the .NET 3.1 runtime, set this variable to enable or disable .NET 3.1 specific runtime optimizations. Values include `always`, `never`, and `provisioned-concurrency`."

## Stay on top of your logs. ⚡️

![Cloudash screenshot](https://cloudash.dev/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Fcloudash_function.6e0454ea.png&w=3840&q=75)

Introducing [Cloudash](https://cloudash.dev), a desktop app for monitoring your serverless services performance, invocations, errors and more.

Did a production incident happen last week? Or 20 seconds ago? With Cloudash you can search, filter and browse your serverless logs and metrics effortlessly.