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
- 
AWS_REGION- The region the function is running in (we all know it'sus-east-1).
- 
AWS_EXECUTION_ENV- The AWS Lambda runtime identifier. 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 eitheron-demandorprovisioned-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. Be careful with those, read SAS-7: Insecure Application Secrets Storage for guidance. This post on Security for AWS Lambda Serverless Applications is also a good place to start.
- 
AWS_LAMBDA_RUNTIME_API- The host and port of the AWS Lambda runtime API, 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: "For X-Ray tracing, Lambda sets this toLOG_ERRORto 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 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: "For the .NET 3.1 runtime, set this variable to enable or disable .NET 3.1 specific runtime optimizations. Values includealways,never, andprovisioned-concurrency."
Stay on top of your logs. ⚡️
Introducing Cloudash, 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.
 

 
                      
 
    
Top comments (0)