Create a cross-account role in the management account that the new account's Lambda execution role can assume
A company uses an organization in AWS Organizations to manage its AWS accounts. The company's DevOps team has developed an AWS Lambda function that calls the Organizations API to create new AWS accounts. The Lambda function runs in the organization's management account. The DevOps team needs to move the Lambda function from the management account to a dedicated AWS account. The DevOps team must ensure that the Lambda function has the ability to create new AWS accounts only in Organizations before the team deploys the Lambda function to the new account. Which solution will meet these requirements?
Community Votes
100% of anonymous learners picked answer A. Votes are pick records left by other test-takers — they are not the verified answer.
Community Insight
Account creation is a management-account-only operation, so the permission has to live in the management account and be reached by role assumption, which means the trust policy must name the specific principal that will assume the role (A). The trust principal must be the Lambda execution role in the new account, not the Lambda service principal, because it is that execution role which presents the credentials when the function runs (A rather than C). Option B's delegation policy cannot delegate the Organizations CreateAccount action because that permission is not delegable in this way. Option D misuses Control Tower, whose CreateManagedAccount permission belongs to its own service flow and cannot be granted to an arbitrary account's Lambda.
Only the Organizations management account can create new accounts, so moving the Lambda function to a dedicated account requires the new account's Lambda to obtain that authority indirectly. An IAM role created in the management account holds the permissions needed to create accounts in Organizations, its trust policy allows the Lambda execution role in the new account to assume it, the Lambda code is updated to assume that role when calling the Organizations CreateAccount API, and the execution role is granted permission to perform sts:AssumeRole. This gives the function exactly the account-creation authority it needs and nothing broader.
Allowing the Lambda service principal to assume the new role (C) — the principal presenting credentials is the function's execution role, not the Lambda service principal, so trusting the service principal does not connect the new account's function to the management-account role. Turning on delegated administration for Organizations and granting the new account permission to create accounts with a delegation policy (B) — account creation is not a permission that Organizations delegation can grant to a member account in this way, so the delegation policy would not authorize CreateAccount. Enabling Control Tower and using controltower:CreateManagedAccount in the new account (D) — that permission is part of the Control Tower service workflow, not a general grant to an account's Lambda function.
Community Discussion (3 comments)
- Create IAM Role in Management Account: include actions like "organizations:CreateAccount" - Allow Role Assumption: specifying the ARN of the Lambda execution role in the new account in the trust policy of the IAM role. - Using the AWS SDK to assume the role and get temporary credentials in Lambda's code - Ensure that the Lambda execution role in the new account has the necessary permissions to assume the IAM role created in the management account.
Comments & Corrections
No comments yet — spotted an error or have a note? Share it below.
Expert Analysis
Why the Answer Is Correct
Creating AWS accounts is an operation only the Organizations management account can perform, so after moving the Lambda function to a dedicated account the function can no longer call it with its own credentials. The correct pattern is to create an IAM role in the management account that carries the Organizations account-creation permissions, and to have the new account's function assume it. The role's trust policy therefore names the Lambda execution role in the new account as the principal permitted to assume it, which is the identity that actually presents credentials when the function runs. The function code is updated to assume the role when it calls CreateAccount, and the execution role is granted sts:AssumeRole so it can perform that assumption (A). This confines the function's authority to exactly the account-creation capability while keeping the permission in the management account where it must live. A is the correct answer.Why the Other Options Are Wrong
B turns on delegated administration for Organizations and creates a delegation policy granting the new account permission to create accounts. Account creation is not a permission that Organizations delegation can grant to a member account in this way, so the delegation policy would not authorize the CreateAccount call and the requirement that the function be able to create accounts before deployment would not be met. C creates the same management-account role but allows the Lambda service principal to assume it. The principal that presents credentials when the function executes is its execution role, not the Lambda service principal, so trusting the service principal does not establish the required trust relationship for the new account's function. D enables AWS Control Tower, turns on delegated administration for it, creates a resource policy allowing the new account to create accounts, and switches the function to the Control Tower API with the controltower:CreateManagedAccount permission. That permission is part of the Control Tower account-provisioning workflow and is not a general grant to an arbitrary account's Lambda function, so this approach does not give the function the account-creation authority it needs. A is correct.Community Comment Notes
Community voted A unanimously. jamesf described the three parts of option A, the management-account role with Organizations permissions, the trust relationship allowing assumption by the new account's Lambda execution role, and the function code updated to assume the role when creating accounts. trungtd enumerated the implementation details, that the role includes actions such as organizations:CreateAccount and that the trust policy specifies the ARN of the Lambda execution role in the new account. tgv confirmed A. No alternative received support.Official Reference
Related Analysis
Practice All DOP-C02 Questions
Access 85 questions with complete answers and detailed explanations.
View Full DOP-C02 Practice Test →