amazon-sagemaker-examples icon indicating copy to clipboard operation
amazon-sagemaker-examples copied to clipboard

Sagemaker get_execution_role failing due to invalid endpoint

Open baereilon opened this issue 7 years ago • 2 comments

Working on AWS jupyter notebook instance, I'm getting an error running:

import sagemaker
sagemaker.get_execution_role()

For some reason it's not recognising sts.us-east-1.amazonaws.com as a valid endpoint although I do see it as valid here.

The error is as following:

ValueError: Invalid endpoint: sts.us-east-1.amazonaws.com

The region is in sync with the region of the Notebook Instance. Notebook instance settings: ARN arn:aws:sagemaker:us-east-1:{ARN ID}:notebook-instance/{Instance Name} Creation time Aug 28, 2019 17:03 UTC Last updated Sep 10, 2019 11:28 UTC Notebook instance type ml.t2.medium

Full Error:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-2-75a7f97fe552> in <module>()
----> 1 sagemaker.get_execution_role()

~/anaconda3/envs/python3/lib/python3.6/site-packages/sagemaker/session.py in get_execution_role(sagemaker_session)
   1679     if not sagemaker_session:
   1680         sagemaker_session = Session()
-> 1681     arn = sagemaker_session.get_caller_identity_arn()
   1682 
   1683     if ":role/" in arn:

~/anaconda3/envs/python3/lib/python3.6/site-packages/sagemaker/session.py in get_caller_identity_arn(self)
   1384         """
   1385         assumed_role = self.boto_session.client(
-> 1386             "sts", endpoint_url=sts_regional_endpoint(self.boto_region_name)
   1387         ).get_caller_identity()["Arn"]
   1388 

~/anaconda3/envs/python3/lib/python3.6/site-packages/boto3/session.py in client(self, service_name, region_name, api_version, use_ssl, verify, endpoint_url, aws_access_key_id, aws_secret_access_key, aws_session_token, config)
    261             aws_access_key_id=aws_access_key_id,
    262             aws_secret_access_key=aws_secret_access_key,
--> 263             aws_session_token=aws_session_token, config=config)
    264 
    265     def resource(self, service_name, region_name=None, api_version=None,

~/anaconda3/envs/python3/lib/python3.6/site-packages/botocore/session.py in create_client(self, service_name, region_name, api_version, use_ssl, verify, endpoint_url, aws_access_key_id, aws_secret_access_key, aws_session_token, config)
    837             is_secure=use_ssl, endpoint_url=endpoint_url, verify=verify,
    838             credentials=credentials, scoped_config=self.get_scoped_config(),
--> 839             client_config=config, api_version=api_version)
    840         monitor = self._get_internal_component('monitor')
    841         if monitor is not None:

~/anaconda3/envs/python3/lib/python3.6/site-packages/botocore/client.py in create_client(self, service_name, region_name, is_secure, endpoint_url, verify, credentials, scoped_config, api_version, client_config)
     84         client_args = self._get_client_args(
     85             service_model, region_name, is_secure, endpoint_url,
---> 86             verify, credentials, scoped_config, client_config, endpoint_bridge)
     87         service_client = cls(**client_args)
     88         self._register_retries(service_client)

~/anaconda3/envs/python3/lib/python3.6/site-packages/botocore/client.py in _get_client_args(self, service_model, region_name, is_secure, endpoint_url, verify, credentials, scoped_config, client_config, endpoint_bridge)
    326         return args_creator.get_client_args(
    327             service_model, region_name, is_secure, endpoint_url,
--> 328             verify, credentials, scoped_config, client_config, endpoint_bridge)
    329 
    330     def _create_methods(self, service_model):

~/anaconda3/envs/python3/lib/python3.6/site-packages/botocore/args.py in get_client_args(self, service_model, region_name, is_secure, endpoint_url, verify, credentials, scoped_config, client_config, endpoint_bridge)
     83             timeout=(new_config.connect_timeout, new_config.read_timeout),
     84             socket_options=socket_options,
---> 85             client_cert=new_config.client_cert)
     86 
     87         serializer = botocore.serialize.create_serializer(

~/anaconda3/envs/python3/lib/python3.6/site-packages/botocore/endpoint.py in create_endpoint(self, service_model, region_name, endpoint_url, verify, response_parser_factory, timeout, max_pool_connections, http_session_cls, proxies, socket_options, client_cert)
    259         if not is_valid_endpoint_url(endpoint_url):
    260 
--> 261             raise ValueError("Invalid endpoint: %s" % endpoint_url)
    262         if proxies is None:
    263             proxies = self._get_proxies(endpoint_url)

ValueError: Invalid endpoint: sts.us-east-1.amazonaws.com

baereilon avatar Sep 10 '19 12:09 baereilon

Hi @baereilon,

It looks like you are facing the same issue as described here. That issue has been fixed, could you restart your notebook instance and try again?

neelamgehlot avatar Oct 09 '19 01:10 neelamgehlot

Closing the issue, please reopen if the issue persist even after restarting Notebook Instance.

neelamgehlot avatar Oct 10 '19 21:10 neelamgehlot