A developer is configuring an Amazon ECS task definition to run a containerized application on AWS Fargate. The application code needs to query an Amazon DynamoDB table. Additionally, the ECS container agent must pull the container image from Amazon ECR and send container logs to Amazon CloudWatch Logs. Which configuration of IAM roles meets these requirements with the least privilege?
- Specify an IAM role with permissions to query DynamoDB as the taskRoleArn (Task Role), and specify a separate IAM role with permissions to pull from ECR and write to CloudWatch Logs as the executionRoleArn (Task Execution Role).Cevap
- BSpecify an IAM role with permissions to query DynamoDB, pull from ECR, and write to CloudWatch Logs as the executionRoleArn (Task Execution Role), and leave the taskRoleArn (Task Role) empty.
- CSpecify an IAM role with permissions to pull from ECR and write to CloudWatch Logs as the executionRoleArn (Task Execution Role), and hardcode the access key ID and secret access key of an IAM user with DynamoDB permissions inside the application code.
- DSpecify an IAM role with permissions to query DynamoDB as the taskRoleArn (Task Role), but configure the trust policy of this role to allow the ecs.amazonaws.com service principal to assume the role.
Cevap
Specify an IAM role with permissions to query DynamoDB as the taskRoleArn (Task Role), and specify a separate IAM role with permissions to pull from ECR and write to CloudWatch Logs as the executionRoleArn (Task Execution Role).
The correct configuration uses the Task Role (taskRoleArn) to grant the application code running inside the container permissions to access DynamoDB. Meanwhile, the Task Execution Role (executionRoleArn) grants the ECS container agent permissions to pull the container image from ECR and send logs to CloudWatch. This follows the principle of least privilege and separates infrastructure permissions from application permissions.
Adım Adım Çözüm
Anahtar Kavram
Separation of concerns between ECS Task Role and ECS Task Execution Role
Tahmini Süre:1m 30s