Pass an individual environment variable to an Amazon ECS container (original) (raw)
Important
We recommend storing your sensitive data in either AWS Secrets Manager secrets or AWS Systems Manager Parameter Store parameters. For more information, see Pass sensitive data to an Amazon ECS 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 container 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"
}
],
...
}
],
...
}
Pass sensitive data to a container
Pass environment variables to a container
Did this page help you? - Yes
Thanks for letting us know we're doing a good job!
If you've got a moment, please tell us what we did right so we can do more of it.
Did this page help you? - No
Thanks for letting us know this page needs work. We're sorry we let you down.
If you've got a moment, please tell us how we can make the documentation better.