A SysOps administrator has the following IAM policy attached to their IAM user:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "EC2LaunchPermissions",
"Effect": "Allow",
"Action": [
"ec2:RunInstances",
"ec2:AssociateIamInstanceProfile"
],
"Resource": "*"
}
]
}
The administrator attempts to launch an Amazon EC2 instance and associate it with an existing IAM role named `WebServerRole` by running the following AWS CLI command:
`aws ec2 run-instances --image-id ami-0c55b159cbfafe1f0 --instance-type t3.micro --iam-instance-profile Name=WebServerProfile`
The command fails with the following error message:
`An error occurred (UnauthorizedOperation) when calling the RunInstances operation: User: arn:aws:iam::123456789012:user/AdminUser is not authorized to perform: iam:PassRole on resource: arn:aws:iam::123456789012:role/WebServerRole`
What modification should the administrator make to their user's IAM policy to successfully run the command?
- Add a statement to the user's IAM policy that allows the iam:PassRole action with the resource set to the ARN of the WebServerRole.Answer
- BAdd a statement to the user's IAM policy that allows the sts:AssumeRole action with the resource set to the ARN of the WebServerRole.
- CAdd a statement to the user's IAM policy that allows the iam:PassRole action with the resource set to the ARN of the WebServerProfile instance profile.
- DModify the trust relationship policy of the WebServerRole to allow the administrator's user to perform the sts:AssumeRole action.