A developer is configuring an AWS Lambda function in Account A () that needs to write items to an Amazon DynamoDB table in Account B (). The developer wants to use cross-account IAM roles to implement secure access following the principle of least privilege. An IAM role named `CrossAccountDynamoDBWriter` has been created in Account B with the necessary permission policy to write to the DynamoDB table.
Which two configuration steps must the developer perform to enable the Lambda function to access the DynamoDB table?
- In Account B, configure the trust policy of the `CrossAccountDynamoDBWriter` role to allow the Lambda function's execution role in Account A to assume the role.Answer
- In Account A, attach an identity-based policy to the Lambda function's execution role that grants the `sts:AssumeRole` permission on the ARN of the `CrossAccountDynamoDBWriter` role in Account B.Answer
- CIn Account A, configure the trust policy of the Lambda function's execution role to trust the `CrossAccountDynamoDBWriter` role in Account B.
- DIn Account A, configure the Lambda function to use hardcoded access keys of an IAM user from Account B that has write access to the DynamoDB table.
- EIn Account A, configure the Lambda function to assume the `CrossAccountDynamoDBWriter` role by adding a resource-based policy directly to the Lambda function.
Answer
In Account B, configure the trust policy of the role to allow the Lambda function's execution role in Account A to assume the role, and in Account A, attach an identity-based policy to the Lambda function's execution role that grants the `sts:AssumeRole` permission on the ARN of the role in Account B.
For cross-account access, a two-way permission handshake is required. The role in the trusting account (Account B) must have a trust policy allowing the trusted identity (Account A's Lambda execution role) to assume it. Concurrently, the trusted identity in Account A must have an identity-based policy allowing it to call `sts:AssumeRole` on the target role in Account B.
Step-by-Step Solution
Key Concept
Cross-account IAM role access requires configuring both a trust policy on the resource role and an identity-based permission policy on the calling principal.
Estimated Time:2m 0s