

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

# EMR Notebooks 的服務角色
<a name="emr-managed-notebooks-service-role"></a>

每個 EMR 筆記本都需要存取其他 AWS 資源和執行動作的許可。連接到此服務角色的 IAM 政策提供許可，讓筆記本與其他 AWS 服務互通。當您使用 建立筆記本時 AWS 管理主控台，您可以指定 *AWS 服務角色*。您可以使用預設的角色 `EMR_Notebooks_DefaultRole` 或指定您建立的角色。如果先前未建立筆記本，您可以選擇建立預設的角色。
+ 預設角色名稱為 `EMR_Notebooks_DefaultRole`。
+ 附接至 `EMR_Notebooks_DefaultRole` 的預設受管政策是 `AmazonElasticMapReduceEditorsRole` 和 `S3FullAccessPolicy`。

您的服務角色應使用下列信任政策。

**重要**  
下列信任政策包括 [https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-sourcearn](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-sourcearn) 和 [https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-sourceaccount](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-sourceaccount) 全域條件金鑰，這些金鑰會將您授予 Amazon EMR 的許可限制在帳戶中的特定資源。使用它們可以保護您免受[混淆代理人問題](https://docs.aws.amazon.com/IAM/latest/UserGuide/confused-deputy.html)。

------
#### [ JSON ]

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": [
    {
      "Sid": "AllowSTSAssumerole",
      "Effect": "Allow",
      "Principal": {
        "Service": "elasticmapreduce.amazonaws.com"
      },
      "Action": "sts:AssumeRole",
      "Condition": {
        "StringEquals": {
          "aws:SourceAccount": "123456789012"
        },
        "ArnLike": {
          "aws:SourceArn": "arn:aws:elasticmapreduce:*:123456789012:*"
        }
      }
    }
  ]
}
```

------

`AmazonElasticMapReduceEditorsRole` 第 1 版的內容如下。

------
#### [ JSON ]

****  

```
{
  "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": [
        "*"
      ],
      "Sid": "AllowEC2Authorizesecuritygroupegress"
    },
    {
      "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"
          ]
        }
      },
      "Sid": "AllowEC2Createtags"
    }
  ]
}
```

------

以下是 `S3FullAccessPolicy` 的內容。`S3FullAccessPolicy` 可讓 EMR Notebooks 的服務角色對您 AWS 帳戶中的物件執行所有 Amazon S3 動作。為 EMR Notebooks 建立自訂服務角色時，您必須授予服務角色 Amazon S3 許可。

------
#### [ JSON ]

****  

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

------

您可以將服務角色的讀取和寫入存取權範圍縮減至要儲存筆記本檔案的 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 政策中新增 `secretsmanager:GetSecretValue` 許可。範例政策如下所示：

------
#### [ JSON ]

****  

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

------

## EMR Notebooks 服務角色許可
<a name="emr-managed-notebooks-service-role-permissions"></a>

下表列出 EMR Notebooks 使用服務角色所採取的動作，以及每個動作所需的許可。


****  

| Action | 許可 | 
| --- | --- | 
| 在筆記本與 Amazon EMR 叢集之間建立安全的網路通道，並執行必要的清除動作。 |  <pre>"ec2:CreateNetworkInterface", <br />"ec2:CreateNetworkInterfacePermission", <br />"ec2:DeleteNetworkInterface", <br />"ec2:DeleteNetworkInterfacePermission", <br />"ec2:DescribeNetworkInterfaces", <br />"ec2:ModifyNetworkInterfaceAttribute", <br />"ec2:AuthorizeSecurityGroupEgress", <br />"ec2:AuthorizeSecurityGroupIngress", <br />"ec2:CreateSecurityGroup",<br />"ec2:DescribeSecurityGroups", <br />"ec2:RevokeSecurityGroupEgress",<br />"ec2:DescribeTags",<br />"ec2:DescribeInstances",<br />"ec2:DescribeSubnets",<br />"ec2:DescribeVpcs",<br />"elasticmapreduce:ListInstances", <br />"elasticmapreduce:DescribeCluster", <br />"elasticmapreduce:ListSteps"</pre>  | 
| 使用儲存在 AWS Secrets Manager 中的 Git 憑證，以將 Git 儲存庫連結至筆記本。 |  <pre>"secretsmanager:GetSecretValue"</pre>  | 
| 將 AWS 標籤套用至 EMR Notebooks 在設定安全網路頻道時建立的網路界面和預設安全群組。如需詳細資訊，請參閱[標記 AWS 資源](https://docs.aws.amazon.com/general/latest/gr/aws_tagging.html)。 |  <pre>"ec2:CreateTags"</pre>  | 
| 存取筆記本檔案和中繼資料或將其上傳至 Amazon S3。 | <pre>"s3:PutObject",<br />"s3:GetObject",<br />"s3:GetEncryptionConfiguration",<br />"s3:ListBucket",<br />"s3:DeleteObject" </pre>僅當您使用加密的 Amazon S3 儲存貯體時，才需要下列許可。<pre>"kms:Decrypt",<br />"kms:GenerateDataKey",<br />"kms:ReEncryptFrom",<br />"kms:ReEncryptTo",<br />"kms:DescribeKey"</pre> | 

## AWS 受管政策的 EMR Notebooks 更新
<a name="notebooks-slr-updates"></a>

檢視自 2021 年 3 月 1 日起 EMR Notebooks AWS 受管政策更新的詳細資訊。


| 變更 | 描述 | Date | 
| --- | --- | --- | 
| AmazonElasticMapReduceEditorsRole - Added permissions | EMR Notebooks 已將 `ec2:describeVPCs` 和 `elastmicmapreduce:ListSteps` 許可新增至 `AmazonElasticMapReduceEditorsRole`。 | 2023 年 2 月 8 日  | 
| EMR Notebooks 已開始追蹤變更 | EMR Notebooks 開始追蹤其 AWS 受管政策的變更。 | 2023 年 2 月 8 日  | 