A developer is deploying an application on an Amazon EC2 instance. The application is configured to read configuration templates from an Amazon S3 bucket. The developer creates an IAM role named `AppConfigReadRole` with an attached policy that allows `s3:GetObject` on the target bucket. However, the application fails to retrieve the templates and receives an 'Access Denied' error. The developer inspects the trust policy of `AppConfigReadRole` and finds the following document:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "lambda.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
Which of the following modifications to the trust policy will resolve the Access Denied error and allow the EC2 instance to assume the role?
- AModify the trust policy statement to allow the `s3:GetObject` action instead of `sts:AssumeRole`.
- BEmbed the AWS Access Key ID and Secret Access Key of a security administrator directly in the application code.
- Change the principal service in the trust policy from `lambda.amazonaws.com` to `ec2.amazonaws.com`.Answer
- DChange the principal service in the trust policy to `ecs-tasks.amazonaws.com` and attach it to the EC2 host's task execution role.