Method sagemaker.get_execution_role() generates error

Hi experts,

Method sagemaker.get_execution_role() in PDS Course2 Week1 notebook generates the following error:

KeyError Traceback (most recent call last)
in
3
4 sess = sagemaker.Session()
----> 5 role = sagemaker.get_execution_role()
6 bucket = sess.default_bucket()
7 region = boto3.Session().region_name

/opt/conda/lib/python3.7/site-packages/sagemaker/session.py in get_execution_role(sagemaker_session)
4167 if not (
4168 error_code == “ValidationException”
→ 4169 and “Could not find” in ce.response[“Error”][“Message”]
4170 ):
4171 raise ce

/opt/conda/lib/python3.7/site-packages/sagemaker/session.py in get_caller_identity_arn(self)
3516 try:
3517 role = self.boto_session.client(“iam”).get_role(RoleName=role_name)[“Role”][“Arn”]
→ 3518 except ClientError:
3519 LOGGER.warning(
3520 “Couldn’t call ‘get_role’ to get Role ARN from role name %s to get Role path.”,

Is there a work-around?

Thanks,
Stefan

Hello @steff and welcome to PDS

The error is a SageMaker issue and has not been fixed yet. The only workaround is to restart the kernel and try again.

kind regards,

2 Likes