Correct the cross-account role trust policy after recreating a role with CloudFormation
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?
Community Votes
70% of anonymous learners picked answer A. Votes are pick records left by other test-takers — they are not the verified answer.
Community Insight
Deleting and recreating a role generates a new unique role identifier, so a trust policy that names the old role as the principal now points at an ARN that no longer exists, and the sts:AssumeRole call fails.
A CloudFormation template recreates a role in a child account with the same role name, after which the EC2 instance profile can no longer assume the role in the parent account. The name is unchanged but the underlying principal has changed.
Adding a statement that trusts the root principal of the child account. That grants every principal in the child account the ability to assume the role, which is far broader than intended and introduces a privilege escalation path, and it also would not fix an already stale ARN reference.
Community Discussion (14 comments)
Comments & Corrections
No comments yet — spotted an error or have a note? Share it below.
Expert Analysis
Why the Answer Is Correct
The trust policy lives in the parent account and controls who may assume the role. When CloudFormation deletes and recreates the role, the role receives a new unique identifier, so the ARN referenced by the existing sts:AssumeRole statement in the trust policy no longer matches. Editing the parent account trust policy so the statement points at the correct target role ARN restores the assumption path without changing any permissions.Why the Other Options Are Wrong
B: Trusting the root principal of the child account allows any principal in that account to assume the role, which is a much broader grant than the specific instance profile and is a privilege escalation risk. C: CAPABILITY_NAMED_IAM alone is only a CloudFormation acknowledgement flag and does not change any trust relationship, and specifying only that capability would fail for named IAM resources. D: Specifying both capabilities is also only an acknowledgement of the IAM resources being created and does not repair the trust policy in the parent account.Community Comment Notes
The community voted 67 to 29 for A over B. The key argument was that trusting the child account root opens the role to any principal in that account permitted to call sts:AssumeRole, whereas correcting the ARN in the existing statement keeps the grant scoped to the instance profile. One dissenting comment noted the phrasing of option A, but the intent is the target principal in the trust statement.Official Reference
Related Analysis
Practice All SAP-C02 Questions
Access 85 questions with complete answers and detailed explanations.
View Full SAP-C02 Practice Test →