File tree Expand file tree Collapse file tree 3 files changed +11
-1
lines changed Expand file tree Collapse file tree 3 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ CHANGELOG
6
6
======
7
7
8
8
* bug-fix: Revert appending Airflow retry id to default job name
9
+ * bug-fix: Session: don't allow get_execution_role() to return an ARN that's not a role but has "role" in the name
9
10
10
11
1.16.3
11
12
======
Original file line number Diff line number Diff line change @@ -1212,7 +1212,7 @@ def get_execution_role(sagemaker_session=None):
1212
1212
sagemaker_session = Session ()
1213
1213
arn = sagemaker_session .get_caller_identity_arn ()
1214
1214
1215
- if 'role' in arn :
1215
+ if ': role/ ' in arn :
1216
1216
return arn
1217
1217
message = 'The current AWS identity is not a role: {}, therefore it cannot be used as a SageMaker execution role'
1218
1218
raise ValueError (message .format (arn ))
Original file line number Diff line number Diff line change @@ -65,6 +65,15 @@ def test_get_execution_role_throws_exception_if_arn_is_not_role():
65
65
assert 'ValueError: The current AWS identity is not a role' in str (error )
66
66
67
67
68
+ def test_get_execution_role_throws_exception_if_arn_is_not_role_with_role_in_name ():
69
+ session = Mock ()
70
+ session .get_caller_identity_arn .return_value = 'arn:aws:iam::369233609183:user/marcos-role'
71
+
72
+ with pytest .raises (ValueError ) as error :
73
+ get_execution_role (session )
74
+ assert 'ValueError: The current AWS identity is not a role' in str (error )
75
+
76
+
68
77
def test_get_caller_identity_arn_from_an_user (boto_session ):
69
78
sess = Session (boto_session )
70
79
arn = 'arn:aws:iam::369233609183:user/mia'
You can’t perform that action at this time.
0 commit comments