EMR Studio サービスロールを作成する - Amazon EMR

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

EMR Studio サービスロールを作成する

EMR Studio サービスロールについて

各 EMR Studio は、Studio が他の AWS のサービスと対話できるようにするアクセス許可を備えた IAM ロールを使用します。このサービスロールには、EMR Studio が Workspace とクラスター間のセキュアなネットワークチャネルを確立し、Amazon S3 Control にノートブックファイルを保存し、Workspace を Git リポジトリにリンクしているとき AWS Secrets Manager にアクセスできるようにするアクセス許可を含める必要があります。

(セッションポリシーの代わりに) Studio サービスロールを使用して、ノートブックファイルを保存するためのすべての Amazon S3 アクセス許可を定義し、AWS Secrets Manager アクセス許可を定義します。

Amazon EC2 または Amazon EKS で EMR Studio 用にサービスロールを作成する方法

  1. AWS のサービスにアクセス許可を委任するロールの作成」の指示に従って、次の信頼ポリシーを使用してサービスロールを作成します。

    重要

    次の信頼ポリシーには、EMR Studio に付与するアクセス許可をアカウント内の特定のリソースに制限するための aws:SourceArn および aws:SourceAccount グローバル条件キーが含まれています。そうすることで、「混乱した代理」問題から保護できます。

    { "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 Studio サービスロールのアクセス許可 を使用するカスタムポリシーを作成できます。

    重要
    • による Amazon EC2 タグベースのアクセスコントロールを EMR Studio と連携させるには、次のポリシーに示すように ModifyNetworkInterfaceAttribute API へのアクセスを設定する必要があります。

    • EMR Studio がサービス ロールを操作するには、次のステートメント AllowAddingEMRTagsDuringDefaultSecurityGroupCreation および AllowAddingTagsDuringEC2ENICreation を変更しないでください。

    • サンプルポリシーを使用するには、キー "for-use-with-amazon-emr-managed-policies" および値 "true" を使用して次のリソースにタグ付けする必要があります。

      • EMR Studio の Amazon Virtual Private Cloud (VPC)。

      • Studio で使用する各サブネット。

      • カスタム EMR Studio セキュリティグループ。EMR Studio のプレビュー期間中に作成したセキュリティグループを引き続き使用する場合は、そのセキュリティグループにタグを付ける必要があります。

      • Studio ユーザーが Git リポジトリを Workspace にリンクするために使用する、AWS Secrets Manager に保存されたシークレット。

      AWS Management Console の関連するリソース画面の [Tag] (タグ) タブを使用してリソースにタグを適用できます。

    該当する場合は、以下のポリシーの "Resource":"*"* を変更して、ご使用のユースケースでステートメントがカバーする 1 つ以上のリソースの 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 Studio の 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 シークレットへのアクセスをユーザーレベルで制御する場合は、EMR Studio ユーザーロールポリシーsecretsmanager:GetSecretValue へタグベースのアクセス許可を追加し、EMR Studio サービスロールポリシーから secretsmanager:GetSecretValue ポリシーへのアクセス許可を削除します。きめ細かいユーザーのアクセス許可の設定方法の詳細については、「EMR Studio ユーザーのアクセス許可ポリシーの作成」を参照してください。

EMR Serverless の最小限のサービスロール

EMR Studio ノートブックを介して EMR Serverless でインタラクティブなワークロードを実行する場合は、前のセクション (Amazon EC2 または Amazon EKS で EMR Studio 用にサービスロールを作成する方法) で EMR Studio の設定に使用したのと同じ信頼ポリシーを使用します。

IAM ポリシーでは、実用最小限のポリシーには次のようなアクセス許可があります。EMR Studio と Workspace を設定するときに使用する予定のバケットの名前で bucket-name を更新します。EMR Studio はこのバケットを使用して Studio 内の Workspace とノートブックファイルをバックアップします。

{ "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 Studio サービスロールのアクセス許可

次の表に、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"
AWS Secrets Manager に保存されている Git 認証情報を使用して Git リポジトリを Workspace にリンクする。
"secretsmanager:GetSecretValue"
EMR Studio がセキュアネットワークチャネルの設定時に作成するネットワークインターフェイスおよびデフォルトのセキュリティグループに AWS タグを適用する。詳細については、「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"