A developer is deploying a Java application on Amazon EC2 instances in AWS account `123456789012`. The application requires access to retrieve database credentials from AWS Systems Manager Parameter Store. The developer creates an IAM role named `SSMParameterReaderRole` and attaches a permissions policy that allows the `ssm:GetParameter` action. The developer then configures an Amazon EC2 Instance Profile to associate the EC2 instances with this role. During startup, the application fails to retrieve the parameters, and CloudTrail logs show that the EC2 service was unable to assume the role.
The trust policy currently attached to `SSMParameterReaderRole` is as follows:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::123456789012:root"
},
"Action": "sts:AssumeRole"
}
]
}
Which modification must the developer make to the trust policy of `SSMParameterReaderRole` to resolve this issue?
- AAttach a permissions policy directly to the Amazon EC2 instances that grants the `sts:AssumeRole` permission for the IAM role.
- BChange the trust policy's Action field to specify the `ssm:GetParameter` API action instead of the `sts:AssumeRole` API action.
- Update the trust policy's Principal block to specify the EC2 service principal (`"Service": "ec2.amazonaws.com"`) instead of the AWS account root principal.Answer
- DModify the application's SDK client configuration to hardcode the IAM role's temporary credentials directly in the code.