AWS Batch
User Guide

AWS Batch Job Environment Variables

AWS Batch automatically sets specific environment variables in container jobs. These environment variables provide introspection for the containers inside jobs, and you can use the values of these variables in the logic of your applications. All variables that are set by AWS Batch begin with the prefix, AWS_BATCH_; this is a protected environment variable prefix, and you cannot use this prefix for your own variables in job definitions or overrides.

The following environment variables are available in job containers:


This variable is set to the name of the compute environment that your job is placed in.


This variable is only set in child array jobs. The array job index begins at 0, and each child job receives a unique index number. For example, an array job with 10 children has index values of 0-9. You can use this index value to control how your array job children are differentiated. For more information, see Tutorial: Using the Array Job Index to Control Job Differentiation.


This variable is set to the job attempt number. The first attempt is numbered 1. For more information, see Automated Job Retries.


This variable is set to the AWS Batch job ID.


This variable is set to the name of the job queue that your job was submitted to.