QuestionQ88

VerifiedContinuous Improvement for Existing Solutions

A solutions architect is creating an AWS CloudFormation template from an existing manually created non-production AWS environment. The CloudFormation template can be destroyed and recreated as needed. The environment contains an Amazon EC2 instance. The EC2 instance has an instance profile that the EC2 instance uses to assume a role in a parent account.

The solutions architect recreates the role in a CloudFormation template and uses the same role name. When the CloudFormation template is launched in the child account, the EC2 instance can no longer assume the role in the parent account because of insufficient permissions

What should the solutions architect do to resolve this issue?

Explanation

IAM resolves the principal ARN in a trust policy to an internal unique ID at the moment the policy is saved, so deleting and recreating a role with the same name produces a new unique ID that no longer matches the binding stored in the parent account's trust policy, even though the ARN text looks identical. Re-editing and saving the trust policy in the parent account forces it to re-resolve against the current role, restoring the EC2 instance's ability to assume it; adding a root-principal statement instead would grant overly broad cross-account access rather than fixing the actual cause.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!