创建 EMR Studio 服务角色 - Amazon EMR

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

创建 EMR Studio 服务角色

关于 EMR Studio 服务角色

每个 EMR Studio 都使用一个具有允许 Studio 与其他 AWS 服务进行交互权限的IAM角色。此服务角色必须包括允许 EMR Studio 在工作空间和集群之间建立安全的网络通道 Amazon S3 Control、在其中存储笔记本文件以及在将工作区链接到 Git 存储库 AWS Secrets Manager 时进行访问的权限。

使用 Studio 服务角色(而不是会话策略)定义所有 Amazon S3 访问权限以存储笔记本文件,并定义 AWS Secrets Manager 访问权限。

如何在亚马逊EC2或亚马逊上为 EMR Studio 创建服务角色 EKS

  1. 按照创建角色中的说明向 AWS 服务委派权限,使用以下信任策略创建服务角色。

    重要

    以下信任策略包括aws:SourceArnaws:SourceAccount全局条件密钥,用于限制您向 EMR Studio 授予您账户中特定资源的权限。这样做可以防止混淆代理人问题

    { "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>:*" } } } ] }
  2. 删除默认角色权限。然后,包括以下示例权限策略中的IAM权限。或者,您也可以创建使用 EMRStudio 服务角色权限 的自定义策略。

    重要
    • 要使EC2基于亚马逊标签的访问控制与 EMR Studio 配合使用,您必须为设置访问权限,ModifyNetworkInterfaceAttributeAPI如以下策略所示。

    • 要EMR让 Studio 使用服务角色,您不得更改以下语句:AllowAddingEMRTagsDuringDefaultSecurityGroupCreationAllowAddingTagsDuringEC2ENICreation

    • 要您使用示例策略,必须使用密钥 "for-use-with-amazon-emr-managed-policies" 和值 "true" 标记以下资源。

      • 你的 EMR Studio 版亚马逊虚拟私有云 (VPC)。

      • 您要与 Studio 配合使用的每个子网。

      • 任何自定义 EMR Studio 安全组。如果您想继续使用在 EMR Studio 预览期内创建的任何安全组,则必须对其进行标记。

      • Studio 用户用来将 Git 存储库链接到工作空间的秘密。 AWS Secrets Manager

      您可以在 AWS Management Console中,使用相关资源屏幕上的 Tags (标签) 选项卡将标签应用于资源。

    如果适用,请更改以下政策*"Resource":"*"中的内容,为您的使用案例指定该声明所涵盖的资源的亚马逊资源名称 (ARN)。

    { "Version": "2012-10-17", "Statement": [ { "Sid": "AllowEMRReadOnlyActions", "Effect": "Allow", "Action": [ "elasticmapreduce:ListInstances", "elasticmapreduce:DescribeCluster", "elasticmapreduce:ListSteps" ], "Resource": "*" }, { "Sid": "AllowEC2ENIActionsWithEMRTags", "Effect": "Allow", "Action": [ "ec2:CreateNetworkInterfacePermission", "ec2:DeleteNetworkInterface" ], "Resource": [ "arn:aws:ec2:*:*:network-interface/*" ], "Condition": { "StringEquals": { "aws:ResourceTag/for-use-with-amazon-emr-managed-policies": "true" } } }, { "Sid": "AllowEC2ENIAttributeAction", "Effect": "Allow", "Action": [ "ec2:ModifyNetworkInterfaceAttribute" ], "Resource": [ "arn:aws:ec2:*:*:instance/*", "arn:aws:ec2:*:*:network-interface/*", "arn:aws:ec2:*:*:security-group/*" ] }, { "Sid": "AllowEC2SecurityGroupActionsWithEMRTags", "Effect": "Allow", "Action": [ "ec2:AuthorizeSecurityGroupEgress", "ec2:AuthorizeSecurityGroupIngress", "ec2:RevokeSecurityGroupEgress", "ec2:RevokeSecurityGroupIngress", "ec2:DeleteNetworkInterfacePermission" ], "Resource": "*", "Condition": { "StringEquals": { "aws:ResourceTag/for-use-with-amazon-emr-managed-policies": "true" } } }, { "Sid": "AllowDefaultEC2SecurityGroupsCreationWithEMRTags", "Effect": "Allow", "Action": [ "ec2:CreateSecurityGroup" ], "Resource": [ "arn:aws:ec2:*:*:security-group/*" ], "Condition": { "StringEquals": { "aws:RequestTag/for-use-with-amazon-emr-managed-policies": "true" } } }, { "Sid": "AllowDefaultEC2SecurityGroupsCreationInVPCWithEMRTags", "Effect": "Allow", "Action": [ "ec2:CreateSecurityGroup" ], "Resource": [ "arn:aws:ec2:*:*:vpc/*" ], "Condition": { "StringEquals": { "aws:ResourceTag/for-use-with-amazon-emr-managed-policies": "true" } } }, { "Sid": "AllowAddingEMRTagsDuringDefaultSecurityGroupCreation", "Effect": "Allow", "Action": [ "ec2:CreateTags" ], "Resource": "arn:aws:ec2:*:*:security-group/*", "Condition": { "StringEquals": { "aws:RequestTag/for-use-with-amazon-emr-managed-policies": "true", "ec2:CreateAction": "CreateSecurityGroup" } } }, { "Sid": "AllowEC2ENICreationWithEMRTags", "Effect": "Allow", "Action": [ "ec2:CreateNetworkInterface" ], "Resource": [ "arn:aws:ec2:*:*:network-interface/*" ], "Condition": { "StringEquals": { "aws:RequestTag/for-use-with-amazon-emr-managed-policies": "true" } } }, { "Sid": "AllowEC2ENICreationInSubnetAndSecurityGroupWithEMRTags", "Effect": "Allow", "Action": [ "ec2:CreateNetworkInterface" ], "Resource": [ "arn:aws:ec2:*:*:subnet/*", "arn:aws:ec2:*:*:security-group/*" ], "Condition": { "StringEquals": { "aws:ResourceTag/for-use-with-amazon-emr-managed-policies": "true" } } }, { "Sid": "AllowAddingTagsDuringEC2ENICreation", "Effect": "Allow", "Action": [ "ec2:CreateTags" ], "Resource": "arn:aws:ec2:*:*:network-interface/*", "Condition": { "StringEquals": { "ec2:CreateAction": "CreateNetworkInterface" } } }, { "Sid": "AllowEC2ReadOnlyActions", "Effect": "Allow", "Action": [ "ec2:DescribeSecurityGroups", "ec2:DescribeNetworkInterfaces", "ec2:DescribeTags", "ec2:DescribeInstances", "ec2:DescribeSubnets", "ec2:DescribeVpcs" ], "Resource": "*" }, { "Sid": "AllowSecretsManagerReadOnlyActionsWithEMRTags", "Effect": "Allow", "Action": [ "secretsmanager:GetSecretValue" ], "Resource": "arn:aws:secretsmanager:*:*:secret:*", "Condition": { "StringEquals": { "aws:ResourceTag/for-use-with-amazon-emr-managed-policies": "true" } } }, { "Sid": "AllowWorkspaceCollaboration", "Effect": "Allow", "Action": [ "iam:GetUser", "iam:GetRole", "iam:ListUsers", "iam:ListRoles", "sso:GetManagedApplicationInstance", "sso-directory:SearchUsers" ], "Resource": "*" } ] }
  3. 为你的服务角色授予对你的 Amazon S3 工作地点的 EMR Studio 的读写权限。使用以下最小权限集。有关更多信息,请参阅 Amazon S3:允许以编程方式和在控制台中对 S3 Bucket 中的对象进行读写访问示例。

    "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"
  4. 如果要在用户级别控制对 Git 密钥的访问权限,请在 Studi EMR o 用户角色策略secretsmanager:GetSecretValue中添加基于标签的权限,并从 St EMR udio 服务角色secretsmanager:GetSecretValue策略中删除策略权限。有关设置精细用户权限的更多信息,请参阅 为 EMR Studio 用户创建权限策略

EMR无服务器的最低服务角色

如果您想通过 EMR Studio 笔记本使用 EMR Serverless 运行交互式工作负载,请使用与上一节中设置 EMR Studio 相同的信任策略。如何在亚马逊EC2或亚马逊上为 EMR Studio 创建服务角色 EKS

对于您的IAM策略,最低可行策略具有以下权限。bucket-name使用您计划在配置 EMR Studio 和工作区时使用的存储桶名称进行更新。EMRStudio 使用存储桶来备份 Studio 中的工作区和笔记本文件。

{ "Version": "2012-10-17", "Statement": [ { "Sid": "ObjectActions", "Effect": "Allow", "Action": [ "s3:PutObject", "s3:GetObject", "s3:DeleteObject" ], "Resource": ["arn:aws:s3:::bucket-name/*"] }, { "Sid": "BucketActions", "Effect": "Allow", "Action": [ "s3:ListBucket", "s3:GetEncryptionConfiguration" ], "Resource": ["arn:aws:s3:::bucket-name"] } ] }

如果您计划使用加密的 Amazon S3 存储桶,则请在策略中添加以下权限:

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

EMRStudio 服务角色权限

下表列出了 EMR Studio 使用服务角色执行的操作以及每项操作所需的IAM操作。

操作 操作
在工作空间和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"
使用存储在中的 Git 凭据 AWS Secrets Manager 将 Git 存储库链接到工作区。
"secretsmanager:GetSecretValue"
将 AWS 标签应用于 EMR Studio 在设置安全网络通道时创建的网络接口和默认安全组。有关更多信息,请参阅标记 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"
启用和配置 Workspace 协作。
"iam:GetUser", "iam:GetRole", "iam:ListUsers", "iam:ListRoles", "sso:GetManagedApplicationInstance", "sso-directory:SearchUsers"
使用客户管理的密钥 (CMK) 加密 EMR Studio 工作空间笔记本和文件 AWS Key Management Service
"kms:Decrypt", "kms:GenerateDataKey", "kms:ReEncryptFrom", "kms:ReEncryptTo", "kms:DescribeKey"