本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
第 2 步:Lake Formation 跨账户共享先决条件
在与 Lake Formation 共享资源之前,基于标签的访问控制方法和命名资源方法都需要满足一些先决条件。
完成基于标签的访问控制跨账户数据共享先决条件
-
有关跨账户数据共享要求的更多信息,请参阅“跨账户数据共享”一章中的先决条件一节。
要在跨账户版本设置为版本 3 或更高版本的情况下共享数据目录资源,授予者需要拥有您账户的 Amazon 托管策略
AWSLakeFormationCrossAccountManager
中定义的 IAM 权限。如果您使用的跨账户版本设置为版本 1 或版本 2,则必须先将以下
JSON
权限对象添加到制作者账户中的数据目录资源策略中,然后才能使用基于标签的访问控制方法授予对资源的跨账户访问权限。当glue:EvaluatedByLakeFormationTags
为 true 时,这可授予使用者账户访问数据目录的权限。此外,对于您使用 Lake Formation 权限标签向使用者账户授予其权限的资源,此条件也适用。您要向其授予权限的每个 Amazon Web Services 账户都需要此策略。以下策略必须位于
Statement
元素内。我们会在下一节中讨论完整的 IAM 策略。{ "Effect": "Allow", "Action": [ "glue:*" ], "Principal": { "AWS": [ "
consumer-account-id
" ] }, "Resource": [ "arn:aws:glue:region:account-id
:table/*", "arn:aws:glue:region:account-id
:database/*", "arn:aws:glue:region:account-id
:catalog" ], "Condition": { "Bool": { "glue:EvaluatedByLakeFormationTags": true } } }
完成命名资源方法跨账户共享先决条件
-
如果您的账户中没有数据目录资源策略,则您执行的 Lake Formation 跨账户授权将照常进行。但是,如果存在数据目录资源策略,则必须在其中添加以下语句,以便能够成功使用命名资源方法完成跨账户授权。如果您计划仅使用命名资源方法或仅使用基于标签的访问控制方法,则可以跳过这一步。在本教程中,我们评估了这两种方法,并且我们需要添加以下策略。
以下策略必须位于
Statement
元素内。我们会在下一节中讨论完整的 IAM 策略。{ "Effect": "Allow", "Action": [ "glue:ShareResource" ], "Principal": { "Service":"ram.amazonaws.com" }, "Resource": [ "arn:aws:glue:
region:account-id
:table/*/*", "arn:aws:glue:region:account-id
:database/*", "arn:aws:glue:region:account-id
:catalog" ] } 接下来,使用 Amazon Command Line Interface (Amazon CLI) 添加 Amazon Glue Data Catalog 资源策略。
如果您同时使用基于标签的访问控制方法和命名资源方法授予跨账户权限,则在添加上述策略时必须将
EnableHybrid
参数设置为“true”。因为控制台目前不支持此选项,因此您必须使用glue:PutResourcePolicy
API 和 Amazon CLI。首先,创建一个策略文档(例如 policy.json),然后添加上述两个策略。将
consumer-account-id
替换为获得授权的 Amazon Web Services 账户的账户 ID
,将region
替换为包含您将授予对其权限的数据库和表的数据目录区域,并将account-id
替换为制作者 Amazon Web Services 账户ID。{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": "ram.amazonaws.com" }, "Action": "glue:ShareResource", "Resource": [ "arn:aws:glue:
region:account-id
:table/*/*", "arn:aws:glue:region:account-id
:database/*", "arn:aws:glue:region:account-id
:catalog" ] }, { "Effect": "Allow", "Principal": { "AWS": "region:account-id
" }, "Action": "glue:*", "Resource": [ "arn:aws:glue:region:account-id
:table/*/*", "arn:aws:glue:region:account-id
:database/*", "arn:aws:glue:region:account-id
:catalog" ], "Condition": { "Bool": { "glue:EvaluatedByLakeFormationTags": "true" } } } ] }输入以下 Amazon CLI 命令。将
glue-resource-policy
替换为正确的值(例如 file://policy.json)。aws glue put-resource-policy --policy-in-json
glue-resource-policy
--enable-hybrid TRUE有关更多信息,请参阅 put-resource-policy。