建立EMR工作室服務角色 - Amazon EMR

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

建立EMR工作室服務角色

關於EMR工作室服務角色

每個 EMR Studio 都使用一個具有權限的IAM角色,讓 Studio 與其他人互動 AWS 服務。此服務角色必須包含允許 EMR Studio 在工作區和叢集之間建立安全網路通道的權限,以便將筆記本檔案儲存在 Amazon S3 Control,並存取 AWS Secrets Manager 同時將工作區鏈接到 Git 存儲庫。

使用 Studio 服務角色 (而非工作階段政策) 定義用於存放筆記本檔案的所有 Amazon S3 存取許可,並定義 AWS Secrets Manager 存取權限。

如何在 Amazon EC2 或 Amazon 上為EMR工作室創建服務角色 EKS

  1. 依照建立角色中的指示將權限委派給 AWS service,以建立具有下列信任原則的服務角色。

    重要

    下列信任原則包含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限原則的權限。或者,可以建立使用 EMR工作室服務角色權限 的自訂政策。

    重要
    • 若要使用 Amazon EC2 標籤式存取控制才能與 EMR Studio 搭配使用,您必須設定存取權,ModifyNetworkInterfaceAttributeAPI如下列政策所示。

    • 若要讓 EMR Studio 與服務角色搭配使用,您不得變更下列陳述式:AllowAddingEMRTagsDuringDefaultSecurityGroupCreationAllowAddingTagsDuringEC2ENICreation

    • 若要使用範例政策,必須使用索引鍵 "for-use-with-amazon-emr-managed-policies" 和值 "true" 來標記下列資源。

      • 適用於EMR工作室的 Amazon Virtual Private Cloud(VPC)。

      • 要搭配 Studio 使用的每個子網路。

      • 任何自訂EMR工作室安全性群組。如果您要繼續使用,則必須標記您在 EMR Studio 預覽期間建立的任何安全群組。

      • 保存在的秘密 AWS Secrets Manager 該工作室用戶用來將 Git 存儲庫鏈接到工作區。

      您可以使用相關資源畫面上的「標籤」標籤將標籤套用至資源 AWS Management Console.

    如果適用,請變更以下政策*"Resource":"*"中的中的,以指定陳述式針對您的使用案例所涵蓋的資源的 Amazon 資源名稱 (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. 為您的服務角色提供對EMR工作室之 Amazon S3 位置的讀取和寫入存取權。請使用下列最小許可集。如需詳細資訊,請參閱 Amazon S3:允許透過程式設計方式和主控台對 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"
  4. 如果您想要在使用者層級控制 Git 密碼的存取,請在 Studio 使用者角色原則secretsmanager:GetSecretValue中新增標籤型權限,並從 EMR EMR Studio 服務角色secretsmanager:GetSecretValue原則移除原則的權限。如需有關設定精細使用者許可的詳細資訊,請參閱 為 EMR Studio 使用者建立權限原則

無伺服器的最低EMR服務角色

如果您想要透過 EMR Studio 筆記本使用EMR無伺服器執行互動式工作負載,請使用上一節中用來設定 EMR Studio 的相同信任原則。如何在 Amazon EC2 或 Amazon 上為EMR工作室創建服務角色 EKS

對於您的IAM政策,最低限度的可行策略具有以下權限。使bucket-name用您計劃在設定 EMR Studio 和工作區時使用的值區名稱進行更新。EMRStudio 使用存儲桶備份工作室中的工作區和筆記本文件。

{ "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"

EMR工作室服務角色權限

下表列出 EMR Studio 使用服務角色執行的作業,以及每個作業所需的IAM動作。

作業 動作
在 Workspace 和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"
啟用並設定工作區協同合作。
"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"