A developer is deploying a containerized microservice to Amazon ECS on AWS Fargate. The application code inside the container must read and write data to an Amazon DynamoDB table. During startup, the Amazon ECS container agent must retrieve sensitive API keys from AWS Secrets Manager to inject as environment variables and send container logs to Amazon CloudWatch Logs. Which of the following configurations must the developer perform to meet these requirements securely? (Select TWO.)
- Associate an IAM role containing DynamoDB read and write permissions as the Task Role (taskRoleArn) in the task definition.Answer
- Associate an IAM role containing Secrets Manager decryption and CloudWatch Logs creation permissions as the Task Execution Role (executionRoleArn) in the task definition.Answer
- CAssociate an IAM role containing DynamoDB read and write permissions as the Task Execution Role (executionRoleArn) in the task definition.
- DConfigure the trust policy of the Task Role to allow the Systems Manager service principal (ssm.amazonaws.com) to assume the role.
- EStore the AWS access keys in the application's configuration file inside the Docker container to authenticate DynamoDB SDK requests.
Answer
The developer must associate the IAM role containing DynamoDB permissions as the Task Role (taskRoleArn) and associate the IAM role containing Secrets Manager and CloudWatch permissions as the Task Execution Role (executionRoleArn).
The correct configurations involve assigning the correct responsibilities to the Task Role and the Task Execution Role. The Task Role is used by the containers running inside the task to make AWS API calls, so the permission to read and write to the DynamoDB table must be attached to the Task Role. The Task Execution Role is used by the Amazon ECS container agent to perform actions on behalf of the task before the containers start, such as pulling the container image, writing logs to CloudWatch Logs, and retrieving secrets from Secrets Manager to inject as environment variables.
Step-by-Step Solution
Key Concept
Separation of concerns between the ECS Task Role and the ECS Task Execution Role.
Estimated Time:2m 0s