import boto3
sm = boto3.client('sagemaker')
role_arn = 'arn:aws:iam:::role/'
try:
sm.list_notebook_instances()
except sm.exceptions.ClientError as e:
if "AccessDenied" in str(e) and "is not authorized to perform" in str(e):
print("Role does not have required permissions.\n")
print("Missing %s permission on the role: %s" % (e.response['Error']['Code'], role_arn))
else:
print(e)
else:
print("Role has required permissions.")
import boto3
sagemaker = boto3.client('sagemaker')
sagemaker_response = sagemaker.create_notebook_instance(
NotebookInstanceName='my-notebook-instance-####',
# ... Other arguments ...
ExecutionRoleArn='arn:aws:iam:::role/my-execution-role',
# ... Other arguments ...
)
response_status = sagemaker.describe_notebook_instance(NotebookInstanceName=sagemaker_response['NotebookInstanceName'])
print("Notebook Instance status: ", response_status['NotebookInstanceStatus'])
在上面的代码中,注意提供ExecutionRoleArn
参数以指定假定角色的ARN。
如果这些解决方法均不起作用,则建议您检查Sagemaker服务的更新,并联系AWS支持团队寻求帮助。