設定 Amazon Redshift 資料共用的許可 - AWS Lake Formation

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

設定 Amazon Redshift 資料共用的許可

本主題說明接受資料共用邀請、建立聯合資料庫和授予許可時需要遵循的步驟。您可以使用 Lake Formation 主控台或 AWS Command Line Interface (AWS CLI)。本主題中的範例顯示相同帳戶中的生產者叢集、資料目錄和資料取用者。

若要進一步了解 Lake Formation 跨帳戶功能,請參閱 Lake Formation 中的跨帳戶資料共用

設定資料共用的許可
  1. 檢閱資料共用邀請並接受它。

    Console
    1. 在 以資料湖管理員身分登入 Lake Formation 主控台https://console.aws.amazon.com/lakeformation/。導覽至資料共用頁面。

    2. 檢閱您獲授權存取的資料共用。狀態欄指出您目前的資料共用參與狀態。擱置狀態表示您已新增至資料共用,但您尚未接受它或已拒絕邀請。

    3. 若要回應資料共用邀請,請選取資料共用名稱,然後選擇檢閱邀請 。在接受或拒絕資料共用 中,檢閱邀請詳細資訊。選擇接受以接受邀請或拒絕以拒絕邀請。如果您拒絕邀請,則無法存取資料共用。

    AWS CLI

    下列範例示範如何檢視、接受和註冊邀請。將 AWS 帳戶 ID 取代為有效的 AWS 帳戶 ID。將 取代data-share-arn為參考資料共用的實際 Amazon Resource Name (ARN)。

    1. 檢視擱置的邀請。

      aws redshift describe-data-shares \ --data-share-arn 'arn:aws:redshift:us-east-1:111122223333:datashare:abcd1234-1234-ab12-cd34-1a2b3c4d5e6f/federatedds' \
    2. 接受資料共用。

      aws redshift associate-data-share-consumer \ --data-share-arn 'arn:aws:redshift:us-east-1:111122223333:datashare:abcd1234-1234-ab12-cd34-1a2b3c4d5e6f/federatedds' \ --consumer-arn 'arn:aws:glue:us-east-1:111122223333:catalog
    3. 在 Lake Formation 帳戶中註冊資料共用。使用 RegisterResourceAPI操作在 Lake Formation 中註冊資料共用。 DataShareArn是 的輸入參數ResourceArn

      注意

      這是必要步驟。

      aws lakeformation register-resource \ --resource-arn 'arn:aws:redshift:us-east-1:111122223333:datashare:abcd1234-1234-ab12-cd34-1a2b3c4d5e6f/federatedds'
  2. 建立資料庫。

    接受資料共用邀請後,您需要建立指向與資料共用相關聯的 Amazon Redshift 資料庫的資料庫。您必須是資料湖管理員才能建立資料庫。

    Console
    1. 邀請窗格中選取資料共用,然後選擇設定資料庫詳細資訊

    2. 設定資料庫詳細資訊 中,輸入資料共用的唯一名稱和識別碼。您可以在中繼資料階層 (dbName.schema.table) 中使用此識別符在內部映射資料共用。

    3. 選擇下一步,將許可授予共用資料庫和資料表上的其他使用者。

    AWS CLI

    使用下列範例程式碼建立資料庫,該資料庫指向使用 與 Lake Formation 共用的 Amazon Redshift 資料庫 AWS CLI。

    aws glue create-database --cli-input-json \ '{ "CatalogId": "111122223333", "DatabaseInput": { "Name": "tahoedb", "FederatedDatabase": { "Identifier": "arn:aws:redshift:us-east-1:111122223333:datashare:abcd1234-1234-ab12-cd34-1a2b3c4d5e6f/federatedds", "ConnectionName": "aws:redshift" } } }'
  3. 授予許可。

    建立資料庫之後,您可以將許可授予帳戶中的使用者,或外部 AWS 帳戶 和組織。您將無法在對應至 Amazon Redshift 資料共用的聯合資料庫上授予寫入資料許可 (插入、刪除) 和中繼資料許可 (變更、捨棄、建立)。如需授予許可的詳細資訊,請參閱 管理 Lake Formation 許可

    注意

    身為資料湖管理員,您只能檢視聯合資料庫中的資料表。若要執行任何其他動作,您需要對這些資料表授予自己更多許可。

    Console
    1. 授予許可畫面上,選取要授予許可的使用者。

    2. 選擇 Grant (授予)。

    AWS CLI

    使用下列範例來授予使用 的資料庫和資料表許可 AWS CLI:

    aws lakeformation grant-permissions --input-cli-json file://input.json { "Principal": { "DataLakePrincipalIdentifier": "arn:aws:iam::111122223333:user/non-admin" }, "Resource": { "Database": { "CatalogId": "111122223333", "Name": "tahoedb" } }, "Permissions": [ "DESCRIBE" ], "PermissionsWithGrantOption": [ ] }
    aws lakeformation grant-permissions --input-cli-json file://input.json { "Principal": { "DataLakePrincipalIdentifier": "arn:aws:iam::111122223333:user/non-admin" }, "Resource": { "Table": { "CatalogId": "111122223333", "DatabaseName": "tahoedb", "Name": "public.customer" } }, "Permissions": [ "SELECT" ], "PermissionsWithGrantOption": [ "SELECT" ] }