A developer is configuring an Amazon ECS task definition to deploy a containerized application to AWS Fargate. The application needs a database password at startup. The password is saved as a secret in AWS Secrets Manager. The developer wants the Amazon ECS container agent to automatically retrieve the secret value and inject it as an environment variable into the container. Which configuration is required to achieve this?
- AAssociate an IAM policy that allows the secretsmanager:GetSecretValue action with the ECS task role, and reference the secret in the secrets section of the container definition.
- BReference the secret ARN in the environment section of the container definition, and configure AWS Systems Manager Parameter Store to sync the credentials.
- Associate an IAM policy that allows the secretsmanager:GetSecretValue action with the ECS task execution role, and reference the secret in the secrets section of the container definition.Answer
- DHardcode AWS access keys in the application's container environment variables to allow the application code to retrieve the secret value from Secrets Manager.
Answer
Associate an IAM policy that allows the secretsmanager:GetSecretValue action with the ECS task execution role, and reference the secret in the secrets section of the container definition.
The correct option is correct because the Amazon ECS container agent is responsible for calling AWS Secrets Manager to retrieve the secret value before starting the container. To do this, the agent uses the permissions defined in the ECS task execution role. The developer must then map the secret to an environment variable inside the container definition's secrets section.
Step-by-Step Solution
Key Concept
ECS Task Role vs. ECS Task Execution Role for Secret Injection