Use task definition parameters to pass environment variables to a container - Amazon Elastic Container Service
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Use task definition parameters to pass environment variables to a container

Important

We recommend storing your sensitive data in either Amazon Secrets Manager secrets or Amazon Systems Manager Parameter Store parameters. For more information, see Passing sensitive data to a container.

Environment variables specified in the task definition are readable by all users and roles that are allowed the DescribeTaskDefinition action for the task definition.

You can pass environment variables to your containers in the following ways:

  • Individually using the environment container definition parameter. This maps to the --env option to docker run.

  • In bulk, using the environmentFiles container definition parameter to list one or more files that contain the environment variables. The file must be hosted in Amazon S3. This maps to the --env-file option to docker run.

The following is a snippet of a task definition showing how to specify individual environment variables.

{ "family": "", "containerDefinitions": [ { "name": "", "image": "", ... "environment": [ { "name": "variable", "value": "value" } ], ... } ], ... }