步骤 6:为 SageMaker 笔记本创建 IAM policy - Amazon Glue
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

步骤 6:为 SageMaker 笔记本创建 IAM policy

如果您计划将 SageMaker 笔记本与开发终端节点结合使用,则必须在创建笔记本时指定权限。您通过使用 Amazon Identity and Access Management(IAM)提供这些权限。

为 SageMaker 笔记本创建 IAM policy
  1. 登录 Amazon Web Services Management Console,然后通过以下网址打开 IAM 控制台:https://console.aws.amazon.com/iam/

  2. 在左侧导航窗格中,选择 Policies(策略)

  3. 请选择创建策略

  4. Create Policy (创建策略) 页面上,导航到用于编辑 JSON 的选项卡。使用以下 JSON 语句创建一个策略文档。编辑环境的 bucket-nameregion-codeaccount-id

    { "Version": "2012-10-17", "Statement": [ { "Action": [ "s3:ListBucket" ], "Effect": "Allow", "Resource": [ "arn:aws:s3:::bucket-name" ] }, { "Action": [ "s3:GetObject" ], "Effect": "Allow", "Resource": [ "arn:aws:s3:::bucket-name*" ] }, { "Action": [ "logs:CreateLogStream", "logs:DescribeLogStreams", "logs:PutLogEvents", "logs:CreateLogGroup" ], "Effect": "Allow", "Resource": [ "arn:aws:logs:region-code:account-id:log-group:/aws/sagemaker/*", "arn:aws:logs:region-code:account-id:log-group:/aws/sagemaker/*:log-stream:aws-glue-*" ] }, { "Action": [ "glue:UpdateDevEndpoint", "glue:GetDevEndpoint", "glue:GetDevEndpoints" ], "Effect": "Allow", "Resource": [ "arn:aws:glue:region-code:account-id:devEndpoint/*" ] }, { "Action": [ "sagemaker:ListTags" ], "Effect": "Allow", "Resource": [ "arn:aws:sagemaker:region-code:account-id:notebook-instance/*" ] } ] }

    然后,选择查看策略

    下表描述了此策略授予的权限。

    操作 资源 描述

    "s3:ListBucket*"

    "arn:aws:s3:::bucket-name"

    授予对 Amazon S3 存储桶的列出权限

    "s3:GetObject"

    "arn:aws:s3:::bucket-name*"

    授予权限以获取 SageMaker 笔记本使用的 Amazon S3 对象。

    "logs:CreateLogStream", "logs:DescribeLogStreams", "logs:PutLogEvents", "logs:CreateLogGroup"

    "arn:aws:logs:region-code:account-id:log-group:/aws/sagemaker/*", "arn:aws:logs:region-code:account-id:log-group:/aws/sagemaker/*:log-stream:aws-glue-*"

    授予从笔记本向 Amazon CloudWatch logs 写入日志的权限。

    命名约定:向名称以 aws-glue 开头的日志组写入内容。

    "glue:UpdateDevEndpoint", "glue:GetDevEndpoint", "glue:GetDevEndpoints"

    "arn:aws:glue:region-code:account-id:devEndpoint/*"

    授予权限以使用 SageMaker 笔记本中的开发终端节点。

    "sagemaker:ListTags"

    "arn:aws:sagemaker:region-code:account-id:notebook-instance/*"

    授予返回 SageMaker 资源标签所需的权限。SageMaker 笔记本需要 aws-glue-dev-endpoint 标签才能连接到开发终端节点。

  5. Review Policy (查看策略) 屏幕上,输入您的 Policy Name (策略名称),例如 AWSGlueSageMakerNotebook。输入可选描述,然后在您对该策略满意时选择 Create policy (创建策略)