A developer is deploying a containerized application to Amazon ECS using AWS Fargate. The application needs to perform read and write operations on an Amazon DynamoDB table. Additionally, the ECS agent must pull the container image from a private Amazon ECR repository and send container startup logs to Amazon CloudWatch Logs.
To satisfy these security requirements using the principle of least privilege, how should the developer configure the IAM roles?
- Define an ECS Task Role with a permissions policy allowing DynamoDB actions and assign it to the task definition. Define an ECS Task Execution Role with a permissions policy allowing ECR and CloudWatch logs actions, and assign it as the execution role in the task definition.Cevap
- BDefine an ECS Task Execution Role with a permissions policy allowing DynamoDB actions and assign it to the task definition. Define an ECS Task Role with a permissions policy allowing ECR and CloudWatch logs actions, and assign it as the execution role.
- CConfigure the application code to initialize the AWS SDK client with static IAM user access keys that have DynamoDB, ECR, and CloudWatch permissions, rather than using ECS IAM roles.
- DDefine a single IAM role with a trust policy that allows both the DynamoDB service and the ECR service to assume the role, and attach a permissions policy allowing all actions to this role.
Cevap
Define an ECS Task Role with a permissions policy allowing DynamoDB actions and assign it to the task definition. Define an ECS Task Execution Role with a permissions policy allowing ECR and CloudWatch logs actions, and assign it as the execution role in the task definition.
The correct configuration uses two distinct roles to enforce the principle of least privilege. The ECS Task Role is designated for credentials needed by the application itself running inside the container (e.g., calling DynamoDB APIs). The ECS Task Execution Role is designated for actions performed by the Amazon ECS container agent (e.g., pulling the Docker image from Amazon ECR and sending container logs to Amazon CloudWatch). Specifying both correctly in the task definition allows the containerized workload to execute securely.
Adım Adım Çözüm
Anahtar Kavram
ECS Task Role vs ECS Task Execution Role separation of duties