RonyA
RonyA

Reputation: 625

AWS EndPoint connection error using python

I have seen few posts and there has been issue with config file for Endpoint connection issue, but seems my config file is ok, still facing issue my .aws/config file

[default]
aws_access_key_id=XXX
aws_secret_access_key=XXX
region=ap-south-1
output = text


>>> import boto3
>>> translate = boto3.client(service_name='translate',region_name='ap-south-1', use_ssl=True)
>>> result = translate.translate_text(Text="Hello, World", 
            SourceLanguageCode="en", TargetLanguageCode="de")


Traceback (most recent call last):
  File "<pyshell#2>", line 2, in <module>
    SourceLanguageCode="en", TargetLanguageCode="de")
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/botocore/client.py", line 314, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/botocore/client.py", line 599, in _make_api_call
    operation_model, request_dict)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/botocore/endpoint.py", line 148, in make_request
    return self._send_request(request_dict, operation_model)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/botocore/endpoint.py", line 177, in _send_request
    success_response, exception):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/botocore/endpoint.py", line 273, in _needs_retry
    caught_exception=caught_exception, request_dict=request_dict)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/botocore/hooks.py", line 227, in emit
    return self._emit(event_name, kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/botocore/hooks.py", line 360, in _emit
    aliased_event_name, kwargs, stop_on_response
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/botocore/hooks.py", line 210, in _emit
    response = handler(**kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/botocore/retryhandler.py", line 183, in __call__
    if self._checker(attempts, response, caught_exception):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/botocore/retryhandler.py", line 251, in __call__
    caught_exception)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/botocore/retryhandler.py", line 277, in _should_retry
    return self._checker(attempt_number, response, caught_exception)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/botocore/retryhandler.py", line 317, in __call__
    caught_exception)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/botocore/retryhandler.py", line 223, in __call__
    attempt_number, caught_exception)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/botocore/retryhandler.py", line 359, in _check_caught_exception
    raise caught_exception
botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "https://translate.ap-south-1.amazonaws.com/"
>>> 

I had created IAM user with AdministratorAccess

Upvotes: 0

Views: 3261

Answers (2)

Abhishek Jain
Abhishek Jain

Reputation: 4199

I came across same error when my connection went down - botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "https://ec2.us-east-2.amazonaws.com/"

When connection is restored then it worked without any issue. Probable reason for this error could be

Connection error Region is not available to cater your request as every request hits endpoint on AWS (more detail can be found on https://docs.aws.amazon.com/general/latest/gr/rande.html#billing-pricing ) It seems like Boto3 has matured enough to throw exception for more proper reason of failure to precisely know what is going.

Also if you have any issue related to your config then most of them are encapsulated with ClientError exception.

Upvotes: 0

John Hanley
John Hanley

Reputation: 81356

Amazon Translate is not available in the ap-south-1 (Mumbai) region. This is why boto3 cannot connect to the endpoint. You will need to select a supported region.

Refer to this link for the current list of supported regions: Amazon Translate Supported Regions

Amazon Translate Region Table

Upvotes: 2

Related Questions