A developer is deploying a microservice to Amazon Elastic Container Service (Amazon ECS) on AWS Fargate. The microservice needs to read messages from an Amazon SQS queue and write records to an Amazon DynamoDB table. During startup, the ECS container agent must pull the container image from Amazon Elastic Container Registry (Amazon ECR) and send container logs to Amazon CloudWatch Logs. Which configuration of IAM roles should the developer specify in the task definition to satisfy these requirements with the least privilege?
- Assign an IAM role with permissions for SQS and DynamoDB as the Task Role, and assign an IAM role with permissions for ECR and CloudWatch Logs as the Task Execution Role.Cevap
- BAssign an IAM role with permissions for ECR and CloudWatch Logs as the Task Role, and assign an IAM role with permissions for SQS and DynamoDB as the Task Execution Role.
- CAssign an IAM role with permissions for SQS, DynamoDB, ECR, and CloudWatch Logs as the Task Role, and do not assign a Task Execution Role.
- DAssign an IAM role with permissions for ECR and CloudWatch Logs as the Task Execution Role, and hardcode the AWS access keys for SQS and DynamoDB in the application configuration inside the container.
Cevap
Assign an IAM role with permissions for SQS and DynamoDB as the Task Role, and assign an IAM role with permissions for ECR and CloudWatch Logs as the Task Execution Role.
The correct configuration assigns the application permissions (SQS and DynamoDB) to the Task Role, and infrastructure/agent permissions (ECR image pull and CloudWatch logging) to the Task Execution Role. The ECS agent needs the Task Execution Role to pull the container image and set up logs before starting the container, while the application code inside the container uses the Task Role to interact with AWS services.
Adım Adım Çözüm
Anahtar Kavram
ECS Task Role vs. ECS Task Execution Role distinction in IAM configurations
Tahmini Süre:1m 30s