A developer is configuring an Amazon ECS task definition to deploy a containerized application on AWS Fargate. The application running inside the container needs to write records to an Amazon Kinesis data stream. During task startup, the Amazon ECS container agent must pull the private container image from Amazon Elastic Container Registry (Amazon ECR) and retrieve a database password from AWS Secrets Manager.
The developer creates an IAM role named AppTaskRole to grant the application access to the Kinesis data stream. However, when attempting to run the task, the container agent fails to pull the image and cannot retrieve the secret.
Which TWO actions must the developer perform to resolve this issue?
- Configure the task definition by specifying an IAM role with policies that allow ECR image pull and Secrets Manager read permissions as the Task Execution Role (executionRoleArn).Cevap
- Configure the task definition by specifying the AppTaskRole, which contains Kinesis write permissions, as the Task Role (taskRoleArn).Cevap
- CAttach the ECR image pull and Secrets Manager read permissions directly to AppTaskRole and omit the Task Execution Role configuration in the task definition.
- DModify the trust policy of the IAM roles to allow the ecs.amazonaws.com service principal to assume the roles.
- EInject static AWS access keys and secret keys as container environment variables in the task definition to authenticate the application client.
Cevap
Specify an IAM role with ECR and Secrets Manager permissions as the Task Execution Role, and associate the AppTaskRole with Kinesis permissions as the Task Role in the task definition.
The correct configurations describe the separate roles required by ECS Fargate tasks: the Task Execution Role (executionRoleArn) is used by the ECS container agent to pull ECR images and retrieve Secrets Manager secrets, while the Task Role (taskRoleArn) is assumed by the application code running inside the container to make AWS API requests like writing to a Kinesis data stream.
Adım Adım Çözüm
Anahtar Kavram
Distinguishing ECS Task Role from ECS Task Execution Role