Reputation: 167
Do I always need to specify endpoint_url
when creating boto3 client?
Why can't I specify QueueUrl
as method argument?
# boto3==1.16.51
import boto3
client = boto3.client('sqs')
messages = client.receive_message(
QueueUrl='https://sqs.eu-central-1.amazonaws.com/325672072888/event-queue-test',
WaitTimeSeconds=2,
MaxNumberOfMessages=1,
AttributeNames=["All"],
)
Exception:
botocore.exceptions.ClientError: An error occurred (InvalidAddress) when calling the ReceiveMessage operation: The address https://eu-central-1.queue.amazonaws.com/ is not valid for this endpoint.
Seems like it takes default values for sqs queue. But why it does not take value from QueueUrl
Upvotes: 4
Views: 7226
Reputation: 238051
The url from the error msg is different then QueueUrl
because AWS CLI and boto3 use legacy endpoint, one of which is eu-central-1.queue.amazonaws.com
. From docs:
If you use the AWS CLI or SDK for Python, you can use the following legacy endpoints.
You can check this using:
print(client._endpoint)
Upvotes: 4