A SysOps administrator is configuring a Python script hosted on an Amazon EC2 instance in Account A () to automate the provisioning of temporary worker instances. The script uses the AWS SDK to call the `RunInstances` API and associates the new instances with an IAM instance profile that contains an IAM role named `WorkerExecutionRole`.
The EC2 instance running the script is associated with an IAM role named `AutomationAdminRole` which has the following IAM policy attached:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:RunInstances",
"ec2:DescribeInstances"
],
"Resource": "*"
}
]
}
When the script execution is triggered, it fails with an `UnauthorizedOperation` error during instance launch.
Which modification to the IAM configuration of `AutomationAdminRole` is required to resolve this error?
- Add a statement to the IAM policy of AutomationAdminRole that allows the iam:PassRole action on the WorkerExecutionRole resource.Answer
- BModify the trust policy of the WorkerExecutionRole to allow the AutomationAdminRole to perform the sts:AssumeRole action.
- CModify the trust policy of the AutomationAdminRole to allow the ec2.amazonaws.com service principal to perform the sts:AssumeRole action.
- DAdd a statement to the IAM policy of AutomationAdminRole that allows the iam:PassRole action on the WorkerInstanceProfile resource.