A developer is configuring an Amazon ECS task definition to deploy a microservice on AWS Fargate. The microservice retrieves database credentials from AWS Secrets Manager by referencing the secret's ARN in the container definition's `secrets` parameter. Additionally, the application code inside the container reads messages from an Amazon SQS queue. The container uses the `awslogs` log driver to send standard output logs to Amazon CloudWatch Logs. Which configuration of IAM roles correctly implements the principle of least privilege for this deployment?
- Configure the Task Execution Role with permissions to retrieve the database credentials from AWS Secrets Manager and write to Amazon CloudWatch Logs. Configure the Task Role with permissions to receive and delete messages from the Amazon SQS queue. Ensure both roles trust the ecs-tasks.amazonaws.com service principal.Cevap
- BConfigure the Task Role with permissions to retrieve the database credentials from AWS Secrets Manager and read from the Amazon SQS queue. Configure the Task Execution Role with permissions to write to Amazon CloudWatch Logs. Ensure both roles trust the ecs-tasks.amazonaws.com service principal.
- CConfigure the Task Execution Role with permissions to write to Amazon CloudWatch Logs. Use Systems Manager Parameter Store with standard unencrypted parameters to store the database credentials, referencing them in the task definition environment variables, and grant the Task Role permission to read them. Configure the Task Role with permissions to read from the Amazon SQS queue.
- DConfigure the Task Execution Role with permissions to retrieve the database credentials from AWS Secrets Manager and write to Amazon CloudWatch Logs. Configure the Task Role with permissions to receive and delete messages from the Amazon SQS queue. Ensure both roles trust the ecs.amazonaws.com service principal.
Cevap
Configure the Task Execution Role with permissions to retrieve the database credentials from AWS Secrets Manager and write to Amazon CloudWatch Logs, configure the Task Role with permissions to receive and delete messages from the Amazon SQS queue, and ensure both roles trust the ecs-tasks.amazonaws.com service principal.
The Task Execution Role grants the ECS agent permissions to pull container images, write logs to CloudWatch using the awslogs log driver, and retrieve secrets from AWS Secrets Manager. The Task Role grants permissions directly to the application running inside the container, allowing it to communicate with Amazon SQS. Both roles must have a trust relationship allowing the ecs-tasks.amazonaws.com service principal to assume them.
Adım Adım Çözüm
Anahtar Kavram
Distinction between ECS Task Role and ECS Task Execution Role, including proper IAM trust policies.
Tahmini Süre:2m 30s