An organization has an AWS Lambda function running in Account A (). The Lambda function needs to be triggered by an Amazon SQS queue located in Account B (). A developer is configuring a cross-account event source mapping in Account A to process messages from the queue. During setup, the event source mapping enters an `ERR` status with a permission-related error.
Which combination of actions will resolve this authorization failure? (Choose two.)
- Update the Lambda function's IAM execution role policy in Account A to grant permission for `sqs:ReceiveMessage`, `sqs:DeleteMessage`, and `sqs:GetQueueAttributes` on the SQS queue's ARN in Account B.Answer
- Update the SQS queue policy in Account B to grant `sqs:ReceiveMessage`, `sqs:DeleteMessage`, and `sqs:GetQueueAttributes` permissions to the ARN of the Lambda function's execution role in Account A.Answer
- CUpdate the trust policy of the Lambda execution role in Account A to allow the SQS service principal (`sqs.amazonaws.com`) to assume the role.
- DModify the Lambda function code to initialize the SQS client using hardcoded temporary AWS access keys and secret keys generated from Account B.
- ECreate an Amazon Cognito Identity Pool in Account B to authenticate the Lambda function and issue temporary credentials allowing SQS access.
Answer
Updating the Lambda function's execution role policy in Account A to allow SQS actions on the Account B queue, and updating the SQS queue policy in Account B to allow the Lambda execution role ARN.
To configure a cross-account SQS event source mapping, the Lambda function's execution role in Account A must be granted IAM permissions to receive, delete, and get attributes from the queue in Account B. Additionally, the SQS queue policy in Account B must be updated to trust and grant those same permissions to the Lambda function's execution role ARN in Account A.
Step-by-Step Solution
Key Concept
Cross-account authorization for poll-based event sources (SQS) in AWS Lambda requires both identity-based policies (on the Lambda execution role) and resource-based policies (on the SQS queue) to grant permissions.