EMR Notebooks 的服务角色 - Amazon EMR

EMR Notebooks 的服务角色

每个 EMR Notebooks 都需要权限来访问其它AWS资源和执行操作。附加到该服务角色的 IAM policy 为笔记本提供了与其它AWS服务进行交互操作的权限。当您使用AWS Management Console创建笔记本时,您指定一个AWS服务角色。您可以使用默认角色 EMR_Notebooks_DefaultRole,也可以指定您创建的角色。如果之前尚未创建笔记本,则可以选择创建默认角色。

  • 默认角色名为 EMR_Notebooks_DefaultRole

  • 默认情况下,附加到 EMR_Notebooks_DefaultRole 的托管式策略是 AmazonElasticMapReduceEditorsRoleS3FullAccessPolicy

您的服务角色应该使用下面的信任策略。

重要

下面的信任策略包括 aws:SourceArnaws:SourceAccount 全局条件密钥,该密钥将限制您为 Amazon EMR 授予的、针对您账户中特定资源的权限。使用这些策略可以防止混淆代理问题

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": "elasticmapreduce.amazonaws.com" }, "Action": "sts:AssumeRole", "Condition": { "StringEquals": { "aws:SourceAccount": "<account-id>" }, "ArnLike": { "aws:SourceArn": "arn:aws:elasticmapreduce:<region>:<account-id>:*" } } } ] }

版本 1 的内容 AmazonElasticMapReduceEditorsRole 如下所示。

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "ec2:AuthorizeSecurityGroupEgress", "ec2:AuthorizeSecurityGroupIngress", "ec2:CreateSecurityGroup", "ec2:DescribeSecurityGroups", "ec2:RevokeSecurityGroupEgress", "ec2:CreateNetworkInterface", "ec2:CreateNetworkInterfacePermission", "ec2:DeleteNetworkInterface", "ec2:DeleteNetworkInterfacePermission", "ec2:DescribeNetworkInterfaces", "ec2:ModifyNetworkInterfaceAttribute", "ec2:DescribeTags", "ec2:DescribeInstances", "ec2:DescribeSubnets", "ec2:DescribeVpcs", "elasticmapreduce:ListInstances", "elasticmapreduce:DescribeCluster", "elasticmapreduce:ListSteps" ], "Resource": "*" }, { "Effect": "Allow", "Action": "ec2:CreateTags", "Resource": "arn:aws:ec2:*:*:network-interface/*", "Condition": { "ForAllValues:StringEquals": { "aws:TagKeys": [ "aws:elasticmapreduce:editor-id", "aws:elasticmapreduce:job-flow-id" ] } } } ] }

下面是 S3FullAccessPolicy 的内容。S3FullAccessPolicy 允许 EMR Notebooks 的服务角色对 AWS 账户 中的对象执行所有 Amazon S3 操作。当您为 EMR Notebooks 创建自定义服务角色时,必须向服务角色授予 Amazon S3 权限。

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "s3:*", "Resource": "*" } ] }

您可以将服务角色的读写权限范围缩小到要保存笔记本文件的 Amazon S3 位置。使用以下最小 Amazon S3 权限集。

"s3:PutObject", "s3:GetObject", "s3:GetEncryptionConfiguration", "s3:ListBucket", "s3:DeleteObject"

如果您的 Amazon S3 存储桶已加密,您必须为 AWS Key Management Service 包含以下权限。

"kms:Decrypt", "kms:GenerateDataKey", "kms:ReEncryptFrom", "kms:ReEncryptTo", "kms:DescribeKey"

当您将 Git 存储库链接到笔记本并需要为存储库创建密钥时,您必须在附加到 Amazon EMR Notebooks 的服务角色的 IAM policy 中添加 secretsmanager:GetSecretValue 权限。下面演示了一个示例策略:

{ "Version": "2012-10-17", "Statement": [ { "Sid": "VisualEditor0", "Effect": "Allow", "Action": "secretsmanager:GetSecretValue", "Resource": "*" } ] }

EMR Notebooks 服务角色权限

此表列出了 EMR Notebooks 使用服务角色执行的操作,以及每个操作所需的权限。

操作 权限
在笔记本和 Amazon EMR 集群之间建立安全的网络通道,并执行必要的清理操作。
"ec2:CreateNetworkInterface", "ec2:CreateNetworkInterfacePermission", "ec2:DeleteNetworkInterface", "ec2:DeleteNetworkInterfacePermission", "ec2:DescribeNetworkInterfaces", "ec2:ModifyNetworkInterfaceAttribute", "ec2:AuthorizeSecurityGroupEgress", "ec2:AuthorizeSecurityGroupIngress", "ec2:CreateSecurityGroup", "ec2:DescribeSecurityGroups", "ec2:RevokeSecurityGroupEgress", "ec2:DescribeTags", "ec2:DescribeInstances", "ec2:DescribeSubnets", "ec2:DescribeVpcs", "elasticmapreduce:ListInstances", "elasticmapreduce:DescribeCluster", "elasticmapreduce:ListSteps"
使用存储在 AWS Secrets Manager 中的 Git 凭证将 Git 存储库链接到笔记本。
"secretsmanager:GetSecretValue"
将AWS标签应用于 EMR Notebooks 在设置安全网络通道时创建的网络接口和默认安全组。有关更多信息,请参阅标记AWS资源
"ec2:CreateTags"
访问笔记本文件和元数据或将它们上载到 Amazon S3。
"s3:PutObject", "s3:GetObject", "s3:GetEncryptionConfiguration", "s3:ListBucket", "s3:DeleteObject"

仅当您使用加密的 Amazon S3 存储桶时才需要以下权限。

"kms:Decrypt", "kms:GenerateDataKey", "kms:ReEncryptFrom", "kms:ReEncryptTo", "kms:DescribeKey"

AWS 托管策略的 EMR Notebooks 更新

查看有关自 2021 年 3 月 1 日以来针对 EMR Notebooks 的 AWS 托管策略更新的详细信息。

更改 说明 日期
AmazonElasticMapReduceEditorsRole - Added permissions

EMR Notebooks 已将 ec2:describeVPCselastmicmapreduce:ListSteps 权限添加至 AmazonElasticMapReduceEditorsRole

2023 年 2 月 8 日

EMR Notebooks 开启了跟踪修订

EMR Notebooks 为 AWS 托管策略开启了跟踪修订。

2023 年 2 月 8 日