View a markdown version of this page

启用 Lake Formation with S3 表格与数据目录集成 - AWS Lake Formation

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

启用 Lake Formation with S3 表格与数据目录集成

本节介绍使用与集成的 Amazon S3 表的 AWS Lake Formation 授权,将访问控制从 IAM 权限迁移到 IAM 的工作流程 AWS Glue Data Catalog。

重要

启用 AWS Lake Formation 访问控制将撤消对您的 S3 Tables 资源的所有现有基于 IAM 的访问权限。完成步骤 1 后,之前通过 IAM 权限访问数据的用户和角色将立即失去访问权限。用户必须先在步骤 2 中授予 Lake Formation 权限,然后用户才能再次查询数据。在维护时段内规划此次迁移,并与您的数据团队进行协调。

先决条件

要 read/write 访问 S3 表,除了 Lake Formation 权限外,委托人还需要 lakeformation:GetDataAccess IAM 权限。获得此权限后,Lake Formation 将授权访问数据的临时凭证请求。

使用 AWS CLI

  1. 第 1 步:使用 IAM 角色向 Lake Formation 注册存储桶

    在 Lake Formation 中注册 S3 表格资源。

    注意

    如果您已有角色,请确保混合访问权限为 false。

    aws lakeformation register-resource \ --resource-arn "arn:aws:s3tables:us-east-1:AWSAccountID:bucket/*" \ --role-arn "arn:aws:iam::AWSAccountID:role/service-role/LFAccessRole" \ --with-federation
  2. 第 2 步:更新 AWS Glue 目录以启用 Lake Formation 访问控制

    使用空CreateDatabaseDefaultPermissionsCreateTableDefaultPermissions(设置为[])更新目录,然后设置OverwriteChildResourcePermissionsWithDefaultAccept。这将从所有现有子资源中移除基于 IAM 的访问权限,并允许使用 Lake Formation 授权管理目录及其对象。

    aws glue update-catalog \ --catalog-id "s3tablescatalog" \ --catalog-input '{ "FederatedCatalog": { "Identifier": "arn:aws:s3tables:us-east-1:AWSAccountID:bucket/*", "ConnectionName": "aws:s3tables" }, "CreateDatabaseDefaultPermissions": [], "CreateTableDefaultPermissions": [], "OverwriteChildResourcePermissionsWithDefault": "Accept", "AllowFullTableExternalDataAccess": "True" }'
  3. 第 3 步:向你的数据团队授予 Lake Formation 权限

    向需要访问的委托人(角色、用户或群组)授予 Lake Formation 权限。例如,要向角色授予全表读取权限,请执行以下操作:

    aws lakeformation grant-permissions \ --principal DataLakePrincipalIdentifier=arn:aws:iam::AWSAccountID:role/DataTeamRole \ --resource '{ "Table": { "CatalogId": "AWSAccountID", "DatabaseName": "s3tablescatalog/table-bucket-name/namespace", "TableWildcard": {} } }' \ --permissions "SELECT" "DESCRIBE"

    根据需要对每个委托人和资源组合重复此操作。