

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

# 啟用 Amazon S3 Tables 整合
<a name="enable-s3-tables-catalog-integration"></a>

您可以使用 Amazon S3 主控台建立 Amazon S3 資料表儲存貯體，並將其與 AWS 分析服務整合。如需詳細資訊，請參閱[搭配 AWS 分析服務使用 Amazon S3 Tables](https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-tables-integrating-aws.html)。

 在 中 AWS Lake Formation，您可以使用 Lake Formation 主控台或使用 啟用與 AWS Glue Data Catalog 和 的 Amazon S3 Tables AWS Lake Formation 整合 AWS CLI。

## 將 Amazon S3 Tables 與 Data Catalog 和 Lake Formation （主控台） 整合
<a name="w2aac13c27c23b7b1"></a>

1. 開啟 Lake Formation 主控台，網址為 [https://console.aws.amazon.com/lakeformation/](https://console.aws.amazon.com/lakeformation/)。

1. 在導覽窗格中，選擇資料**目錄**下的目錄。 ****

1. 在**目錄**頁面上選擇**啟用 S3 資料表整合**。  
![\[目錄頁面上的啟用 S3 資料表整合選項。\]](http://docs.aws.amazon.com/zh_tw/lake-formation/latest/dg/images/enable-s3-table-integration.png)

1.  選擇具有 Lake Formation 所需許可的 IAM 角色，以擔任將登入資料提供給分析查詢引擎。如需角色存取資料所需的許可，請參閱先決條件一節[step3-permissions](s3tables-catalog-prerequisites.md#step3-permissions)中的 。  
![\[啟用具有 IAM 角色的 S3 整合畫面。\]](http://docs.aws.amazon.com/zh_tw/lake-formation/latest/dg/images/enable-s3-table-catalog.png)

1.  選取**允許外部引擎使用完整資料表存取選項存取 Amazon S3 位置中的資料**。當您為第三方引擎啟用完整資料表存取時，Lake Formation 會直接將登入資料傳回給第三方引擎，而不執行 IAM 工作階段標籤驗證。這表示您無法將 Lake Formation 精細存取控制套用至要存取的資料表。

1. 選擇**啟用**。S3 Tables 的新目錄會新增至目錄清單。當您啟用 S3 資料表目錄整合時，服務會向 Lake Formation 註冊 S3 資料表儲存貯體的資料位置。

1. 選擇目錄以檢視目錄物件，並將許可授予其他主體。  
![\[S3 資料表目錄\]](http://docs.aws.amazon.com/zh_tw/lake-formation/latest/dg/images/s3-table-catalog.png)

   若要建立多層級目錄，請參閱《Amazon Simple Storage Service 使用者指南》中的[建立資料表儲存貯](https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-tables-buckets-create.html)體一節。

## 將 Amazon S3 資料表與資料目錄和 Lake Formation (CLI) 整合
<a name="w2aac13c27c23b7b3"></a>

在先決條件區段之後，建立允許 Lake Formation 存取資料表資源的 IAM 服務角色。

1. 建立名為 `Role-Trust-Policy.json` 的檔案，其中包含下列信任政策：

   ```
   {
       "Version": "2012-10-17",		 	 	 
       "Statement": [
         {
           "Sid": "LakeFormationDataAccessPolicy",
           "Effect": "Allow",
           "Principal": {
             "Service": "lakeformation.amazonaws.com"
           },
           "Action": [
               "sts:AssumeRole",
               "sts:SetContext",
               "sts:SetSourceIdentity"
           ],
           "Condition": {
             "StringEquals": {
               "aws:SourceAccount": "111122223333"
             }
           }
         }
       ]
   }
   ```

1. 使用下列命令建立 IAM 服務角色：

   ```
   aws iam create-role \
     --role-name S3TablesRoleForLakeFormation \
     --assume-role-policy-document file://Role-Trust-Policy.json
   ```

1. 建立包含下列政策之名為 `LF-GluePolicy.json` 的檔案：

   ```
   {
       "Version": "2012-10-17",		 	 	 
       "Statement": [
           {
               "Sid": "LakeFormationPermissionsForS3ListTableBucket",
               "Effect": "Allow",
               "Action": [
                   "s3tables:ListTableBuckets"
               ],
               "Resource": [
                   "*"
               ]
           },
           {
               "Sid": "LakeFormationDataAccessPermissionsForS3TableBucket",
               "Effect": "Allow",
               "Action": [
                   "s3tables:CreateTableBucket",
                   "s3tables:GetTableBucket",
                   "s3tables:CreateNamespace",
                   "s3tables:GetNamespace",
                   "s3tables:ListNamespaces",
                   "s3tables:DeleteNamespace",
                   "s3tables:DeleteTableBucket",
                   "s3tables:CreateTable",
                   "s3tables:DeleteTable",
                   "s3tables:GetTable",
                   "s3tables:ListTables",
                   "s3tables:RenameTable",
                   "s3tables:UpdateTableMetadataLocation",
                   "s3tables:GetTableMetadataLocation",
                   "s3tables:GetTableData",
                   "s3tables:PutTableData"
               ],
               "Resource": [
                   "arn:aws:s3tables:us-east-1:111122223333:bucket/*"
               ]
           }
       ]
   }
   ```

1. 使用下列命令以將政策連接至角色：

   ```
   aws iam put-role-policy \
     --role-name S3TablesRoleForLakeFormation \
     --policy-name LakeFormationDataAccessPermissionsForS3TableBucket \
     --policy-document file://LF-GluePolicy.json
   ```

1. 建立包含下列內容之名為 `input.json` 的檔案：

   ```
   {
       "ResourceArn": "arn:aws:s3tables:us-east-1:111122223333:bucket/*",
       "WithFederation": true,
       "RoleArn": "arn:aws:iam::111122223333:role/S3TablesRoleForLakeFormation"
   }
   ```

1. 使用下列命令向 Lake Formation 註冊資料表儲存貯體：

   ```
   aws lakeformation register-resource \
     --region us-east-1 \
     --with-privileged-access \
     --cli-input-json file://input.json
   ```

1. 建立包含下列型錄之名為 `catalog.json` 的檔案：

   ```
   {
      "Name": "s3tablescatalog",
      "CatalogInput": {
         "FederatedCatalog": {
             "Identifier": "arn:aws:s3tables:us-east-1:111122223333:bucket/*",
             "ConnectionName": "aws:s3tables"
          },
          "CreateDatabaseDefaultPermissions": [],
          "CreateTableDefaultPermissions": [],
          "AllowFullTableExternalDataAccess": "True"
      }
   }
   ```

1. 使用下列命令列來建立 `s3tablescatalog` 型錄。建立此目錄會將對應至資料表儲存貯體、命名空間和資料表的 AWS Glue Data Catalog 物件填入 。

   ```
   aws glue create-catalog \
     --region us-east-1 \
     --cli-input-json file://catalog.json
   ```

1.  AWS Glue 使用以下命令確認`s3tablescatalog`目錄已新增至 ：

   ```
   aws glue get-catalog --catalog-id s3tablescatalog
   ```