4

Why do we need to provide region_name if we are already using regional endpoints?

And also, If I don't specify region_name for sqs then It'll give an Error (NoRegionError : You must specify a region). While creating client for s3, region_name is not required.

client = boto3.client(
    "sqs",
    aws_access_key_id=key_id,
    aws_secret_access_key=secret_key,
    aws_session_token=token,
    endpoint_url="https://sqs.us-east-1.amazonaws.com",
    region_name="us-east-1",  # For some reason region name is required here
)

client = boto3.client(
    "s3",
    aws_access_key_id=key_id,
    aws_secret_access_key=secret_key,
    aws_session_token=token,
    endpoint_url="https://s3.ap-south-1.amazonaws.com", # While this works perfect
    )
  • 2
    Because the `region_name` is used to construct the endpoint URL in the botocore, but it's not the other way around. – jellycsc Feb 24 '21 at 13:12
  • S3 existed before AWS had multiple regions. I'm guessing backwards compatibility. – jordanm Feb 24 '21 at 21:17

0 Answers0