Reputation: 31
We have a Lambda function that sends messages to SQS queue. We are using boto3.
We have built a new environment and Lambda is running in a VPC on a private subnet. The VPC end point is com.amazonaws.eu-west-2.sqs
Lambda code
sqs = boto3.resource('sqs')
# Get the queue
queue = sqs.get_queue_by_name(QueueName=QueueID)
This gives us the following error EndpointConnectionError: Could not connect to the endpoint URL: "https://eu-west-2.queue.amazonaws.com/"
We have tried the following change
sqs = boto3.client('sqs')
# Get the queue
queue = sqs.get_queue_url(QueueName=QueueID, QueueOwnerAWSAccountId='xxxxxxxxxxxx')
We get the same error
It is a legacy endpoint issue but we do not know how to use the new endpoints in the Lambda function.
Upvotes: 1
Views: 3018
Reputation: 852
Because you're using a VPC endpoint for SQS you need to override the address that boto3 is using by default.
Something like this:
sqs = boto3.resource('sqs', endpoint_url="https://com.amazonaws.eu-west-2.sqs")
Upvotes: 3