AWS Certified Solutions Architect Professional SAP-C02 Practice Question
A financial services company operates a multi-account AWS environment with a dedicated 'Developer Tools' account (ID: 111122223333) and a 'Production' account (ID: 999988887777). A CI/CD pipeline, running on an EC2 instance in the Developer Tools account, needs to deploy updates to a specific Lambda function named 'TradeProcessor' (ARN: arn:aws:lambda:us-east-1:999988887777:function:TradeProcessor). A solutions architect has been tasked with designing an IAM configuration that provides the necessary cross-account access while adhering strictly to the principle of least privilege. Which of the following configurations is the most secure and meets the requirements?
In the Production account, create an IAM user with programmatic access. Attach a policy to the user that allows the lambda:UpdateFunctionCode action on the TradeProcessor function ARN. Store the user's access key and secret key in AWS Secrets Manager in the Developer Tools account and grant the EC2 instance's IAM role permission to retrieve them.
In the Production account, create an IAM role named LambdaUpdateRole with an IAM policy that allows the lambda:UpdateFunctionCode action on the resource arn:aws:lambda:us-east-1:999988887777:function:TradeProcessor. Configure the role's trust policy to allow sts:AssumeRole actions from the specific IAM role ARN associated with the EC2 instance in the Developer Tools account.
In the Production account, create an IAM role named LambdaUpdateRole with a policy allowing lambda:UpdateFunctionCode on the TradeProcessor function ARN. Configure the role's trust policy to allow sts:AssumeRole actions from the root of the Developer Tools account ("Principal": {"AWS": "arn:aws:iam::111122223333:root"}).
In the Production account, create an IAM role named LambdaUpdateRole with an IAM policy that allows the lambda:* action on all resources ("Resource": "*"). Configure the role's trust policy to allow sts:AssumeRole actions from the IAM role associated with the EC2 instance in the Developer Tools account.
The correct answer provides the most secure and least-privilege access by using a specific role-to-role trust relationship and resource-level permissions. An IAM role in the Production account (LambdaUpdateRole) is granted a narrow permission (lambda:UpdateFunctionCode) limited only to the specific Lambda function's ARN. Its trust policy explicitly allows only the EC2 instance's role (ToolsEC2Role) from the Developer Tools account to assume it. This ensures that only the designated EC2 instance can assume the role, and once assumed, the credentials can only be used to update that single Lambda function's code.
Using wildcards for the resource or action is overly permissive and violates the principle of least privilege, as it would allow the role to update any Lambda function, or perform any Lambda action, respectively.
Using an IAM user with long-lived access keys is not a best practice for programmatic access from an EC2 instance. IAM roles provide temporary, automatically rotated credentials, which is a more secure mechanism than managing static keys.
Configuring the trust policy in the Production account's role to trust the entire Developer Tools account root is less secure than trusting the specific role ARN. This configuration would allow any principal in the Developer Tools account with sts:AssumeRole permissions to assume the LambdaUpdateRole, not just the intended EC2 instance.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is the purpose of 'sts:AssumeRole' in the trust policy?
Open an interactive chat with Bash
Why is using specific role-to-role trust relationships more secure than trusting the account root?
Open an interactive chat with Bash
Why is using IAM roles preferred over IAM users with long-lived credentials?
Open an interactive chat with Bash
AWS Certified Solutions Architect Professional SAP-C02
Design for New Solutions
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
IT & Cybersecurity Package Join Premium for Full Access