如何消除 aws sagemaker 中的 IAM 角色错误?
How do I make this IAM role error in aws sagemaker go away?
我怀疑这更多地与 IAM 角色有关,而不是与 Sagemaker 有关。
我正在效仿这个例子here
具体来说,当它进行此调用时
tf_estimator.fit('s3://bucket/path/to/training/data')
我收到这个错误
ClientError: An error occurred (AccessDenied) when calling the GetRole operation: User: arn:aws:sts::013772784144:assumed-role/AmazonSageMaker-ExecutionRole-20181022T195630/SageMaker is not authorized to perform: iam:GetRole on resource: role SageMakerRole
我的笔记本实例附加了一个 IAM 角色。
该角色具有 AmazonSageMakerFullAccess
政策。它还有一个自定义策略,如下所示
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:PutObject",
"s3:DeleteObject",
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3:::*"
]
}
]
}
我的输入文件和 .py 脚本在一个 s3 存储桶中,其中包含短语 sagemaker
。
我还缺少什么?
这不是 S3 存储桶策略的问题,而是 IAM 的问题,您选择的用户角色附加了一个策略,没有授予它管理其他 IAM 角色的权限.您需要确保您使用的角色可以管理(创建、读取、更新)IAM 角色。
希望对您有所帮助!
如果您是 运行 SageMaker notebook 实例上的示例代码,则可以使用 execution_role,其中附加了 AmazonSageMakerFullAccess
。
from sagemaker import get_execution_role
sagemaker_session = sagemaker.Session()
role = get_execution_role()
并且可以在初始化tf_estimator
时传递这个角色。
您可以查看示例 here,了解如何在笔记本实例上使用 execution_role
和 S3。
我怀疑这更多地与 IAM 角色有关,而不是与 Sagemaker 有关。
我正在效仿这个例子here
具体来说,当它进行此调用时
tf_estimator.fit('s3://bucket/path/to/training/data')
我收到这个错误
ClientError: An error occurred (AccessDenied) when calling the GetRole operation: User: arn:aws:sts::013772784144:assumed-role/AmazonSageMaker-ExecutionRole-20181022T195630/SageMaker is not authorized to perform: iam:GetRole on resource: role SageMakerRole
我的笔记本实例附加了一个 IAM 角色。
该角色具有 AmazonSageMakerFullAccess
政策。它还有一个自定义策略,如下所示
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:PutObject",
"s3:DeleteObject",
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3:::*"
]
}
]
}
我的输入文件和 .py 脚本在一个 s3 存储桶中,其中包含短语 sagemaker
。
我还缺少什么?
这不是 S3 存储桶策略的问题,而是 IAM 的问题,您选择的用户角色附加了一个策略,没有授予它管理其他 IAM 角色的权限.您需要确保您使用的角色可以管理(创建、读取、更新)IAM 角色。
希望对您有所帮助!
如果您是 运行 SageMaker notebook 实例上的示例代码,则可以使用 execution_role,其中附加了 AmazonSageMakerFullAccess
。
from sagemaker import get_execution_role
sagemaker_session = sagemaker.Session()
role = get_execution_role()
并且可以在初始化tf_estimator
时传递这个角色。
您可以查看示例 here,了解如何在笔记本实例上使用 execution_role
和 S3。