Skip to content

"role=get_execution_role" throws region error #1303

@purplexed

Description

@purplexed

Describe the bug
Using this sdk within a codebuild job, I run the get_execution_role and I get the following error:

Traceback (most recent call last):
--
341 | File "xxx/xxx.py", line 23, in <module>
342 | role = get_execution_role()
343 | File "/usr/local/lib/python3.7/site-packages/sagemaker/session.py", line 3293, in get_execution_role
344 | arn = sagemaker_session.get_caller_identity_arn()
345 | File "/usr/local/lib/python3.7/site-packages/sagemaker/session.py", line 2891, in get_caller_identity_arn
346 | endpoint_url=sts_regional_endpoint(self.boto_region_name),
347 | File "/usr/local/lib/python3.7/site-packages/botocore/client.py", line 357, in _api_call
348 | return self._make_api_call(operation_name, kwargs)
349 | File "/usr/local/lib/python3.7/site-packages/botocore/client.py", line 661, in _make_api_call
350 | raise error_class(parsed_response, operation_name)
351 | botocore.exceptions.ClientError: An error occurred (SignatureDoesNotMatch) when calling the GetCallerIdentity operation: Credential should be scoped to a valid region, not 'eu-west-1'.

This only happens in the latest 1.50.14 version of sagemaker. 1.50.13 works fine.

To reproduce

  1. Create a codebuild job
  2. The buildspec should firstly install the requirements.txt installation, which should include the sagemaker 1.50.14 package
  3. The buildspec should run a python script that includes the following code:
from sagemaker import get_execution_role

role = get_execution_role()
print(role)

Expected behavior
Expected to get the sagemaker execution role for the notebook instance and run the script.

System information

  • Python 3.7:
  • sagemaker 1.50.14:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions