-
Notifications
You must be signed in to change notification settings - Fork 1.2k
sagemaker.get_execution_role() returns incorrect ARN #2089
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Do the auto-generated roles always have the same format? Could replace the if with: if re.match(r'/.*AmazonSageMaker-ExecutionRole-\d{8}T\d{6}.*/',assumed_role):
... But if any other pattern has been used in the past then this could cause issues for anyone using the alternative role name. I'm guessing i should just change the role name for my account? |
I have similar issues when using get_execution_role() within a SageMaker Processing Job, for example. I just ended up doing the hack that you suggested above @hughack by converting assumed-role => role or role/service-role specific to each variant that I’m struggling with. My code is up to 3-4 if statements. Hoping there is a cleaner way. Sagemaker Engineering: any suggestions? |
Hey @hughack, Apologies on the late response. Thank you for bringing this issue to our attention. I'm not entirely sure why we have a conditional to essentially hardcode the path "service-role" if the role name contains "AmazonSageMaker-ExecutionRole". This code seems to have been part of the Python SDK since its inception, so I am bit worried of removing this logic, as many of the original writers... don't work on SageMaker anymore :(, but clearly it is causing issues. Based on the code that comes after that specific conditional, it looks like it was looking to avoid making calls to IAM, since I am guessing due to missing permissions? I believe at the time the code was introduced and even at the time of writing this response, it looks like the default SageMaker IAM policy doesn't account for IAM read permissions. I don't think it is actually possible to get the proper IAM Role ARN without having IAM permissions, at least from the Python SDK perspective. I think the best course of action is to move line of code into the except block of the try/except clause, as a safe compromise, to maintain supporting users of this conditional. |
Describe the bug
I manually created an execution role for SageMaker Studio called
AmazonSageMaker-ExecutionRole-ap-southeast-2
Calling
sagemaker.get_execution_role()
within a SageMaker Studio Notebook returns the incorrect role ARN:Actual ARN:
To reproduce
Create role in CloudFormation:
Setup SageMaker Studio with this role as execution role.
Open a notebook and run:
Expected behavior
Output role ARN:
Actual output:
Note addition of
service-role/
.Additional context
Looks like this line is the culprit:
sagemaker-python-sdk/src/sagemaker/session.py
Line 3501 in 1fdefe0
The text was updated successfully, but these errors were encountered: