A developer is configuring an Amazon ECS task definition to run a microservice on AWS Fargate. The containerized application must retrieve database credentials stored as SecureString parameters in Systems Manager Parameter Store and inject them as environment variables during container startup. Additionally, the application code inside the container needs to read and write items in an Amazon DynamoDB table at runtime. Which configuration of IAM roles should the developer specify in the task definition to satisfy these requirements?
- ASpecify a Task Execution Role containing permissions to retrieve the Parameter Store parameters, and a Task Role containing permissions to access the DynamoDB table, but configure the trust policy of the Task Role to trust the DynamoDB service.
- Specify a Task Execution Role containing permissions to retrieve the Parameter Store parameters, and a Task Role containing permissions to access the DynamoDB table.Answer
- CSpecify a Task Role containing permissions to both retrieve the Parameter Store parameters and access the DynamoDB table, leaving the Task Execution Role empty.
- DSpecify a Task Execution Role containing permissions to both retrieve the Parameter Store parameters and access the DynamoDB table, leaving the Task Role empty.
Answer
Specify a Task Execution Role containing permissions to retrieve the Parameter Store parameters, and a Task Role containing permissions to access the DynamoDB table.
The correct answer properly separates the concerns of task bootstrapping and container runtime execution. The Task Execution Role is utilized by the Amazon ECS container agent to pull secrets from Systems Manager Parameter Store and inject them into the container's environment variables before startup. The Task Role is assumed by the application code running inside the container to make AWS SDK calls to Amazon DynamoDB at runtime. Both roles must trust the ECS tasks service principal to be assumed correctly.
Step-by-Step Solution
Key Concept
Distinction between ECS Task Role and ECS Task Execution Role
Estimated Time:1m 30s