A developer is deploying a containerized application to an Amazon ECS cluster using the Amazon EC2 launch type. The application, which runs in a container with the `bridge` network mode, is designed to write records to an Amazon DynamoDB table. The developer specifies an IAM role named `DynamoDBWorkerRole` in the `taskRoleArn` parameter of the task definition. This IAM role has a policy that allows `dynamodb:PutItem` on the target table. However, at runtime, the application fails to write to DynamoDB and logs the following error:
`AccessDeniedException: User: arn:aws:sts::123456789012:assumed-role/ECSInstanceRole/i-0abcdef123456789 is not authorized to perform: dynamodb:PutItem on resource`
(Note: `` is the AWS account ID, and `ECSInstanceRole` is the IAM role associated with the EC2 container instances.)
Which of the following actions will resolve this issue?
- AAttach the DynamoDB permission policy to the ECS Task Execution Role (taskExecutionRoleArn) instead of the Task Role (taskRoleArn).
- BModify the application code inside the container to query the EC2 Instance Metadata Service (IMDS) at to retrieve temporary credentials for the DynamoDBWorkerRole.
- Update the trust relationship of the DynamoDBWorkerRole to trust the ecs-tasks.amazonaws.com service principal instead of ec2.amazonaws.com.Cevap
- DStore the AWS access key and secret access key for an IAM user with DynamoDB permissions in AWS Secrets Manager, and reference them in the secrets section of the task definition.