An integration specialist is deploying a data ingestion service as a task on Amazon ECS with the EC2 launch type. The application code inside the container must read message payloads from an Amazon SQS queue and write processing logs to Amazon CloudWatch. During deployment, the ECS container agent successfully pulls the image and initializes the container, but the application throws an Access Denied error when attempting to poll the SQS queue. Which action should the developer take to resolve this issue?
- AHardcode the AWS credentials of an IAM user with SQS permissions inside the application configuration file within the Docker container.
- Attach the SQS permission policy to the ECS Task Role specified by the taskRoleArn parameter, and configure its trust policy to trust ecs-tasks.amazonaws.com.Answer
- CAttach the SQS permission policy to the ECS Task Execution Role specified by the executionRoleArn parameter in the task definition.
- DAttach the SQS permission policy to the ECS Task Role, but configure the trust policy of the role to trust ec2.amazonaws.com.
Answer
Attach the SQS permission policy to the ECS Task Role specified by the taskRoleArn parameter, and configure its trust policy to trust ecs-tasks.amazonaws.com.
The containerized application code running inside the ECS task needs permissions to access SQS. These application-level permissions must be defined in an IAM role assigned as the Task Role (via the taskRoleArn parameter). Additionally, the IAM role must have a trust policy that allows the Amazon ECS tasks service (ecs-tasks.amazonaws.com) to assume the role. This permits the container itself to assume the role and make authorized AWS API calls.
Step-by-Step Solution
Key Concept
Distinguishing between Amazon ECS Task Role and Task Execution Role configurations
Estimated Time:1m 30s