I want to send a message to SQS queue on another account (Ohio) from lambda in North Virginia account. How can I achieve this?
Things I tried so far:
Created a queue in Ohio and gave lambda role arn to the queue.
Sent message from the lambda in North Virigina , got following error:
"errorMessage": "An error occurred (AWS.SimpleQueueService.NonExistentQueue) when calling the SendMessage operation:
If you are sending cross-account messages, you have to do the following things.
{
"Version": "2012-10-17",
"Id": "Queue1_Policy_UUID",
"Statement": [
{
"Sid": "Queue1_AllActions",
"Effect": "Allow",
"Principal": {
"AWS": [
"arn:aws:iam::111122223333:role/lambdaRole"
]
},
"Action": [
"sqs:SendMessage",
"sqs:ReceiveMessage"
],
"Resource": "arn:aws:sqs:us-east-2:123456789012:queue1"
}
]
}
The principal here is the Lambda role from the account where the Lambda is deployed.