File tree Expand file tree Collapse file tree 3 files changed +16
-2
lines changed Expand file tree Collapse file tree 3 files changed +16
-2
lines changed Original file line number Diff line number Diff line change 22CHANGELOG
33=========
44
5+ 1.16.4.dev
6+ ==========
7+
8+ * 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+
5101.16.3
611======
712
8- * bug-fix: Local Mode: Allow support for SSH in local mode
13+ * bug-fix: Local Mode: Allow support for SSH in local mode
914* bug-fix: Append retry id to default Airflow job name to avoid name collisions in retry
1015* bug-fix: Local Mode: No longer requires s3 permissions to run local entry point file
1116* feature: Estimators: add support for PyTorch 1.0.0
Original file line number Diff line number Diff line change @@ -1212,7 +1212,7 @@ def get_execution_role(sagemaker_session=None):
12121212 sagemaker_session = Session ()
12131213 arn = sagemaker_session .get_caller_identity_arn ()
12141214
1215- if 'role' in arn :
1215+ if ': role/ ' in arn :
12161216 return arn
12171217 message = 'The current AWS identity is not a role: {}, therefore it cannot be used as a SageMaker execution role'
12181218 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():
6565 assert 'ValueError: The current AWS identity is not a role' in str (error )
6666
6767
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+
6877def test_get_caller_identity_arn_from_an_user (boto_session ):
6978 sess = Session (boto_session )
7079 arn = 'arn:aws:iam::369233609183:user/mia'
You can’t perform that action at this time.
0 commit comments