A developer has configured an AWS Lambda function in AWS Account A to send messages to an Amazon Simple Queue Service (Amazon SQS) queue located in AWS Account B. During execution, the Lambda function fails with an AccessDenied error when attempting to write to the queue. Which two actions are required to resolve this authorization failure? (Select TWO.)
- Add a policy to the Lambda function's IAM execution role in Account A that allows the sqs:SendMessage action on the queue in Account B.Answer
- Update the SQS queue policy in Account B to grant the Lambda function's IAM execution role in Account A permission to perform the sqs:SendMessage action.Answer
- CModify the IAM trust policy of the SQS queue in Account B to trust the Lambda service principal.
- DConfigure the Lambda function to use an Amazon Cognito Identity Pool to obtain temporary credentials to write to Account B.
- EHardcode the AWS Access Key ID and Secret Access Key of an IAM user from Account B in the Lambda function's initialization code.
Answer
Add a policy to the Lambda function's IAM execution role in Account A that allows the sqs:SendMessage action on the queue in Account B, and update the SQS queue policy in Account B to grant the Lambda function's IAM execution role in Account A permission to perform the sqs:SendMessage action.
The correct answers describe the two necessary steps for cross-account resource access: granting identity-based permissions to the caller's IAM execution role in the source account and granting resource-based permissions in the queue's policy in the target account to allow access from that execution role principal.
Step-by-Step Solution
Key Concept
Cross-account resource access requires authorization in both the caller's IAM identity-based policy and the target's resource-based policy.
Estimated Time:1m 0s