A developer is deploying a microservice as an Amazon ECS task on AWS Fargate. The microservice needs to read configuration files from an Amazon S3 bucket. The developer creates an IAM role with the necessary S3 permissions and associates it with the ECS Task Definition as the `taskRoleArn`. However, when the container starts, the application logs show an error indicating that the task is unable to retrieve temporary credentials to access Amazon S3.
The trust policy currently configured on the IAM role is as follows:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "ecs.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
Which modification to the IAM role configuration will resolve this issue?
- AAdd the `s3:GetObject` action and the S3 bucket ARN directly to the trust policy statements.
- BRemove the trust policy and hardcode a set of long-term AWS access keys with S3 permissions directly into the application's SDK client configuration.
- Change the principal service in the trust policy to `ecs-tasks.amazonaws.com`.Cevap
- DChange the trust policy action to `sts:AssumeRoleWithWebIdentity` to allow container-level authentication.