An operations team is designing a secure privilege model for a containerized processing job running on Amazon ECS with the AWS Fargate launch type. The task definition specifies a single container built from a private Docker image in Amazon ECR. At launch, the container must have sensitive database credentials injected as environment variables from AWS Systems Manager Parameter Store using the container definition `secrets` parameter. During runtime, the application code inside the container must write processing events to an Amazon DynamoDB table and stream standard output to Amazon CloudWatch Logs. Which configuration will successfully run the container while adhering to the principle of least privilege?
- Configure an IAM task execution role with permissions for ECR image pull actions, CloudWatch log streaming actions, and SSM Parameter Store access. Configure a separate IAM task role with permissions for DynamoDB write actions. Set the trust policy of both roles to trust the `ecs-tasks.amazonaws.com` service principal.Cevap
- BConfigure an IAM task role with permissions for ECR image pull actions, CloudWatch log streaming actions, SSM Parameter Store access, and DynamoDB write actions. Set the trust policy of this task role to trust the `ecs.amazonaws.com` service principal, and leave the task execution role unassigned.
- CConfigure an IAM task execution role with permissions for DynamoDB write actions, ECR image pull actions, CloudWatch log streaming actions, and SSM Parameter Store access. Do not configure a task role, as the containerized application code automatically inherits the credentials of the task execution role.
- DConfigure an IAM task execution role with permissions for ECR image pull actions, CloudWatch log streaming actions, and SSM Parameter Store access. Embed the AWS Access Key ID and Secret Access Key of a user with DynamoDB write permissions as environment variables in the Dockerfile to authenticate the application client.
Cevap
Configure an IAM task execution role with permissions for ECR, CloudWatch, and SSM Parameter Store, and configure an IAM task role with DynamoDB write permissions, ensuring both roles trust the ecs-tasks.amazonaws.com service principal.
The correct configuration assigns the ECS agent startup permissions (pulling the container image, setting up awslogs logging, and fetching secrets from SSM Parameter Store) to the Task Execution Role. The application runtime permissions (writing to DynamoDB) are assigned to the Task Role. Both roles must have a trust policy allowing the `ecs-tasks.amazonaws.com` service principal to assume them.
Adım Adım Çözüm
Anahtar Kavram
Differentiating between the ECS Task Role (application runtime permissions) and the ECS Task Execution Role (ECS agent startup permissions), and configuring their trust policies.
Tahmini Süre:2m 0s