設定爬行者程式以使用 Lake Formation 認證 - AWS Glue

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

設定爬行者程式以使用 Lake Formation 認證

您可以將爬蟲設定為使用 AWS Lake Formation 登入資料存取 Amazon S3 資料存放區或資料目錄表格,其中的基礎 Amazon S3 位置位於相同 AWS 帳戶 或另一個 AWS 帳戶位置。如果爬蟲程式和資料型錄資料表位於同一帳戶中,您可以將現有的資料型錄資料表設定為爬蟲程式的目標。目前,使用資料型錄資料表作為爬蟲程式的目標時,僅允許具有單一型錄資料表的單一型錄目標。

注意

將資料型錄資料表定義為爬蟲程式目標時,請確定資料型錄資料表的基礎位置是 Amazon S3 位置。使用 Lake Formation 憑證的爬蟲程式僅支援具有基礎 Amazon S3 位置的資料型錄目標。

當爬蟲程式和已註冊的 Amazon S3 位置或資料型錄資料表位於同一帳戶 (帳戶內網路爬取) 時,需要進行設定

若要允許爬蟲程式使用 Lake Formation 憑證存取資料存放區或資料型錄資料表,您需要向 Lake Formation 註冊資料位置。此外,爬行者程式的IAM角色必須具有從註冊 Amazon S3 儲存貯體的目的地讀取資料的權限。

您可以使用 AWS Management Console 或 AWS Command Line Interface (AWS CLI) 完成下列組態步驟。

AWS Management Console
  1. 在設定爬蟲程式以存取爬蟲程式來源之前,請先向 Lake Formation 註冊資料存放區或資料型錄的資料位置。在 Lake Formation 主控台 (https://console.aws.amazon.com/lakeformation/) 中,將 Amazon S3 位置註冊為定義爬蟲程式所 AWS 帳戶 在資料湖的根位置。如需詳細資訊,請參閱 Registering an Amazon S3 location (註冊 Amazon S3 位置)。

  2. 資料位置權限授與用於爬行者程式執行的IAM角色,以便爬行者程式可以從 Lake Formation 中的目的地讀取資料。如需詳細資訊,請參閱 Granting data location permissions (same account) (授與資料位置許可 (相同帳戶))。

  3. 將爬蟲程式角色存取許可 (Create) 授與指定作為輸出資料庫的資料庫。如需詳細資訊,請參閱 Granting database permissions using the Lake Formation console and the named resource method (使用 Lake Formation 主控台和具名資源方法授與資料庫許可)。

  4. 在主IAM控台 (https://console.aws.amazon.com/iam/) 中,建立爬行者程式的IAM角色。將 lakeformation:GetDataAccess 政策新增至該角色。

  5. 在 AWS Glue 主控台 (https://console.aws.amazon.com/glue/) 中,設定爬行者程式時,選取「使用 Lake Formation 登入資料來編目 Amazon S3 資料來源」選項。

    注意

    對於帳戶內檢索,此 accountId 欄位是選擇性的。

AWS CLI
aws glue --profile demo create-crawler --debug --cli-input-json '{ "Name": "prod-test-crawler", "Role": "arn:aws:iam::111122223333:role/service-role/AWSGlueServiceRole-prod-test-run-role", "DatabaseName": "prod-run-db", "Description": "", "Targets": { "S3Targets":[ { "Path": "s3://crawl-testbucket" } ] }, "SchemaChangePolicy": { "UpdateBehavior": "LOG", "DeleteBehavior": "LOG" }, "RecrawlPolicy": { "RecrawlBehavior": "CRAWL_EVERYTHING" }, "LineageConfiguration": { "CrawlerLineageSettings": "DISABLE" }, "LakeFormationConfiguration": { "UseLakeFormationCredentials": true, "AccountId": "111122223333" }, "Configuration": { "Version": 1.0, "CrawlerOutput": { "Partitions": { "AddOrUpdateBehavior": "InheritFromTable" }, "Tables": {"AddOrUpdateBehavior": "MergeNewColumns" } }, "Grouping": { "TableGroupingPolicy": "CombineCompatibleSchemas" } }, "CrawlerSecurityConfiguration": "", "Tags": { "KeyName": "" } }'