Search code examples
amazon-web-servicesdocker-composeamazon-ecs

How to specify sensitive environment variables with ECS CLI and ECS tasks?


In the environment: section of docker-compose docs for AWS CLI (cmd-ecs-cli-compose), the following is stated:

Important

We do not recommend using plaintext environment variables for sensitive > information, such as credential data.

What is the recommended way of storing sensitive information, like passwords, with docker-compose and ECS task definitions? Why is plain text not recommended?


Solution

  • Plain text is not recommended for environment variables because well docker is not a security container and environment variables are readable to all processes that have access to the top level Docker namespace. So if someone has access to /proc on your EC2 instance, they can read the secrets by querying the process running inside the container.

    I recommend either encrypting them with KMS or storing them in Parameter Store or DynamoDB and downloading on startup.