本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
設定 Amazon Redshift 資料共用的許可
本主題說明接受資料共用邀請、建立聯合資料庫和授予許可時需要遵循的步驟。您可以使用 Lake Formation 主控台或 AWS Command Line Interface (AWS CLI)。本主題中的範例顯示相同帳戶中的生產者叢集、資料目錄和資料取用者。
若要進一步了解 Lake Formation 跨帳戶功能,請參閱 Lake Formation 中的跨帳戶資料共用。
設定資料共用的許可
檢閱資料共用邀請並接受它。
- Console
-
- AWS CLI
-
下列範例示範如何檢視、接受和註冊邀請。將 AWS 帳戶 ID 取代為有效的 AWS 帳戶 ID。將 取代data-share-arn
為參考資料共用的實際 Amazon Resource Name (ARN)。
-
檢視擱置的邀請。
aws redshift describe-data-shares \
--data-share-arn 'arn:aws:redshift:us-east-1:111122223333:datashare:abcd1234-1234-ab12-cd34-1a2b3c4d5e6f/federatedds' \
-
接受資料共用。
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
-
在 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'
-
建立資料庫。
接受資料共用邀請後,您需要建立指向與資料共用相關聯的 Amazon Redshift 資料庫的資料庫。您必須是資料湖管理員才能建立資料庫。
- Console
-
-
從邀請窗格中選取資料共用,然後選擇設定資料庫詳細資訊 。
-
在設定資料庫詳細資訊 中,輸入資料共用的唯一名稱和識別碼。您可以在中繼資料階層 (dbName.schema.table) 中使用此識別符在內部映射資料共用。
-
選擇下一步,將許可授予共用資料庫和資料表上的其他使用者。
- 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"
}
}
}'
-
授予許可。
建立資料庫之後,您可以將許可授予帳戶中的使用者,或外部 AWS 帳戶 和組織。您將無法在對應至 Amazon Redshift 資料共用的聯合資料庫上授予寫入資料許可 (插入、刪除) 和中繼資料許可 (變更、捨棄、建立)。如需授予許可的詳細資訊,請參閱 管理 Lake Formation 許可。
身為資料湖管理員,您只能檢視聯合資料庫中的資料表。若要執行任何其他動作,您需要對這些資料表授予自己更多許可。
- Console
-
-
在授予許可畫面上,選取要授予許可的使用者。
-
選擇 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"
]
}