Reputation: 159
I am trying to set cross account data transfer from AWS Lambda in AWS account A to SQS in AWS account B using boto3. Below are the steps which I have followed.
================================================================================
After that when I am trying to test my lambda function, it is giving me below error.
[ERROR] ClientError: An error occurred (AccessDenied) when calling the SendMessage operation: Access to the resource https://queue.amazonaws.com/ is denied.
=====================================================================================
Can anybody please help to understand what's wrong here?.
Upvotes: 1
Views: 1676
Reputation: 2400
This error can occur if you are attempting to access SQS via the boto3 Python library (e.g. OP's lambda) from inside a VPC with private DNS enabled.
Per AWS documentation:
Private DNS doesn't support legacy endpoints such as queue.amazonaws.com or us-east-2.queue.amazonaws.com.
(emphasis mine)
To solve this error:
com.amazonaws.<region>.sqs
in your VPCboto3.client()
constructor:
import boto3
client = boto3.client('sqs', endpoint_url=f'https://sqs.{region}.amazonaws.com')
IAM permissions are left as an exercise to the reader.
Upvotes: 4