A developer is creating an Amazon ECS task definition to deploy a containerized application on AWS Fargate. The application needs to pull its container image from a private Amazon ECR repository in the same AWS account. Additionally, the application code itself must make calls to the Amazon Translate API to translate user reviews at runtime. Which configuration of IAM roles will allow the task to pull the image and run successfully with the least privilege?
- Specify an IAM role in the taskExecutionRoleArn parameter that allows the Amazon ECS agent to pull the image from Amazon ECR, and specify a different IAM role in the taskRoleArn parameter that allows the containerized application to call the Amazon Translate API.Cevap
- BSpecify an IAM role in the taskRoleArn parameter that allows ECR image retrieval, and specify a different IAM role in the taskExecutionRoleArn parameter that allows the containerized application to call the Amazon Translate API.
- CSpecify an IAM role in the taskRoleArn parameter that allows Amazon Translate access with a trust policy that trusts the ec2.amazonaws.com service, and specify an IAM role in the taskExecutionRoleArn parameter that allows ECR image retrieval.
- DSpecify an IAM role in the taskExecutionRoleArn parameter that allows ECR image retrieval, and configure the container environment variables to pass the AWS access key and secret access key of an IAM user with Amazon Translate permissions.
Cevap
Specify an IAM role in the taskExecutionRoleArn parameter that allows the Amazon ECS agent to pull the image from Amazon ECR, and specify a different IAM role in the taskRoleArn parameter that allows the containerized application to call the Amazon Translate API.
The correct configuration uses the Task Execution Role (taskExecutionRoleArn) to grant the Amazon ECS agent permissions to pull the image from Amazon ECR, and uses the Task Role (taskRoleArn) to grant the application running inside the container permission to call the Amazon Translate API. This respects the least-privilege model and aligns with how ECS handles agent-level versus container-level permissions.
Adım Adım Çözüm
Anahtar Kavram
Distinction between ECS Task Role and ECS Task Execution Role