

# 审核 ETL 任务所需的 IAM 权限


当您使用 Amazon Glue Studio 创建任务时，该任务代入您在创建它时指定的 IAM 角色的权限。此 IAM 角色必须有权限从您的数据源中提取数据，将其写入您的目标，并访问 Amazon Glue 资源。

为任务创建的角色的名称必须以字符串 `AWSGlueServiceRole` 开头，以便其能够正确地被 Amazon Glue Studio 使用。例如，您可以将角色命名为 `AWSGlueServiceRole-FlightDataJob`。

## 数据源和数据目标权限


Amazon Glue Studio 任务必须具有您在任务中使用的任何源、目标、脚本和临时目录等 Amazon S3 的访问权限。您可以创建策略，提供对特定 Amazon S3 资源的精细访问权限。
+ 数据源需要 `s3:ListBucket` 和 `s3:GetObject` 权限。
+ 数据目标需要`s3:ListBucket`、`s3:PutObject` 和 `s3:DeleteObject` 权限。

**注意**  
 您的 IAM 策略需要允许对用于托管 Amazon Glue 转换的特定存储桶执行 `s3:GetObject` 操作。  
 以下存储桶由 Amazon 服务账户所有，并且可在全球范围内读取。这些存储桶充当与可通过 Amazon Glue Studio 可视化编辑器访问的转换子集相关的源代码存储库。存储桶上的权限设置为拒绝对该存储桶执行任何其他 API 操作。任何人都可以读取我们提供的转换脚本，但是除我们的服务团队外，任何人都不能向其中“放入”任何内容。当您的 Amazon Glue 作业运行时，将通过本地导入的方式拉取该文件，因此会将该文件下载到本地容器中。之后，将不再与该账户进行其他通信。

 区域：存储桶名称 
+ af-south-1：aws-glue-studio-transforms-762339736633-prod-af-south-1
+ ap-east-1：aws-glue-studio-transforms-125979764932-prod-ap-east-1
+ ap-northeast-2：aws-glue-studio-transforms-673535381443-prod-ap-northeast-2
+ ap-northeast-3：aws-glue-studio-transforms-149976050262-prod-ap-northeast-3
+ ap-south-1：aws-glue-studio-transforms-584702181950-prod-ap-south-1
+ ap-south-2：aws-glue-studio-transforms-380279651983-prod-ap-south-2
+ ap-southeast-1：aws-glue-studio-transforms-737106620487-prod-ap-southeast-1
+ ap-southeast-2：aws-glue-studio-transforms-234881715811-prod-ap-southeast-2
+ ap-southeast-3：aws-glue-studio-transforms-151265630221-prod-ap-southeast-3
+ ap-southeast-4：aws-glue-studio-transforms-052235663858-prod-ap-southeast-4
+ ca-central-1：aws-glue-studio-transforms-622716468547-prod-ca-central-1
+ ca-west-1：aws-glue-studio-transforms-915795495192-prod-ca-west-1
+ eu-central-1：aws-glue-studio-transforms-560373232017-prod-eu-central-1
+ eu-central-2：aws-glue-studio-transforms-907358657121-prod-eu-central-2
+ eu-north-1：aws-glue-studio-transforms-312557305497-prod-eu-north-1
+ eu-south-1：aws-glue-studio-transforms-939684186351-prod-eu-south-1
+ eu-south-2：aws-glue-studio-transforms-239737454084-prod-eu-south-2
+ eu-west-1：aws-glue-studio-transforms-244479516193-prod-eu-west-1
+ eu-west-2：aws-glue-studio-transforms-804222392271-prod-eu-west-2
+ eu-west-3：aws-glue-studio-transforms-371299348807-prod-eu-west-3
+ il-central-1：aws-glue-studio-transforms-806964611811-prod-il-central-1
+ me-central-1：aws-glue-studio-transforms-733304270342-prod-me-central-1
+ me-south-1：aws-glue-studio-transforms-112120182341-prod-me-south-1
+ sa-east-1：aws-glue-studio-transforms-881619130292-prod-sa-east-1
+ us-east-1：aws-glue-studio-transforms-510798373988-prod-us-east-1
+ us-east-2：aws-glue-studio-transforms-251189692203-prod-us-east-2
+ us-west-1：aws-glue-studio-transforms-593230150239-prod-us-west-1
+ us-west-2：aws-glue-studio-transforms-818035625594-prod-us-west-2
+ ap-northeast-1：aws-glue-studio-transforms-200493242866-prod-ap-northeast-1
+ cn-north-1：aws-glue-studio-transforms-071033555442-prod-cn-north-1
+ cn-northwest-1：aws-glue-studio-transforms-070947029561-prod-cn-northwest-1
+ us-gov-west-1：aws-glue-studio-transforms-227493901923-prod-us-gov-west-1-2604
+ eusc-de-east-1：aws-glue-studio-transforms-780995497573-prod-eusc-de-east-1-555

如果选择 Amazon Redshift 作为数据源，那么您可以为集群权限提供角色。针对 Amazon Redshift 集群运行的任务会发出命令，使用临时凭证访问 Amazon S3 进行临时存储。如果您的任务运行超过一小时，这些凭证将会过期，导致任务失败。若要避免此问题，您可以将角色分配给 Amazon Redshift 集群本身，其授予使用临时凭证的任务所需的权限。有关更多信息，请参阅《Amazon Glue 开发人员指南》**中的[将数据移入和移出 Amazon Redshift](https://docs.amazonaws.cn/glue/latest/dg/aws-glue-programming-etl-redshift.html)。

如果任务使用 Amazon S3 以外的数据源或目标，则您必须为任务使用的 IAM 角色附上所需的权限，从而访问这些数据源和目标。有关更多信息，请参阅《Amazon Glue 开发人员指南》**中的[设置环境以访问数据存储](https://docs.amazonaws.cn/glue/latest/dg/start-connecting.html)。

如果要为数据存储使用连接器和连接，则您需要在[使用连接器所需的权限](#getting-started-min-privs-connectors)中描述的其他权限。

## 删除任务所需的权限


在 Amazon Glue Studio 中，您可以在控制台选择多个任务删除。若要执行此操作，您必须具有 `glue:BatchDeleteJob` 权限。这不同于需要 `glue:DeleteJob` 权限来删除任务的 Amazon Glue 控制台。

## Amazon Key Management Service 权限


如果您计划访问使用 Amazon Key Management Service（Amazon KMS）进行服务器端加密的 Amazon S3 源和目标，则需为任务使用的 Amazon Glue Studio 角色附上策略，从而使任务能够解密数据。任务角色需要 `kms:ReEncrypt`、`kms:GenerateDataKey` 和 `kms:DescribeKey` 权限。此外，任务角色需要 `kms:Decrypt` 权限来上载或下载使用 Amazon KMS 客户主密钥（CMK）加密的 Amazon S3 对象。

使用 Amazon KMS CMK 需支付额外费用。有关更多信息，请参阅《Amazon Key Management Service 开发人员指南》**中的 [Amazon Key Management Service 概念 – 客户主密钥（CMK）](https://docs.amazonaws.cn/kms/latest/developerguide/concepts.html#master_keys)和 [Amazon Key Management Service 定价](https://www.amazonaws.cn/kms/pricing)。

## 使用连接器所需的权限


如果您使用 Amazon Glue 自定义连接器和连接来访问数据存储，则需要为用于运行 Amazon Glue ETL 任务的角色附上其他权限：
+ 亚马逊云科技托管式策略 `AmazonEC2ContainerRegistryReadOnly`，用于访问购买于 Amazon Web Services Marketplace 的连接器。
+ `glue:GetJob` 和 `glue:GetJobs` 权限。
+ Amazon Secrets Manager 权限，用于访问与连接一起使用的密钥。有关示例 IAM 策略，请参阅 [Example: Permission to retrieve secret values](https://docs.amazonaws.cn/secretsmanager/latest/userguide/auth-and-access_examples.html#auth-and-access_examples_read)（示例：检索密钥值的权限）。

如果您的 Amazon Glue ETL 任务在运行 Amazon VPC 的 VPC 中运行，则 VPC 必须按照[为 ETL 任务配置 VPC](getting-started-vpc-config.md)中的描述进行配置。