

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

# 設定跨帳戶 Data Catalog 存取權
<a name="lf-athena-limitations-cross-account"></a>

若要存取另一個帳戶中的資料目錄，您可以使用 Athena 的跨帳戶 AWS Glue 功能或在 Lake Formation 中設定跨帳戶存取。

## 選項 A：在 Athena 中設定跨帳戶 Data Catalog 存取權
<a name="lf-athena-limitations-cross-account-glue"></a>

您可以使用 Athena 的跨帳戶 AWS Glue 目錄功能，在帳戶中註冊目錄。僅 Athena 引擎版本 2 及更新版本中提供此功能，且僅限於帳戶之間的相同區域使用。如需詳細資訊，請參閱[從另一個帳戶註冊 Data Catalog](data-sources-glue-cross-account.md)。

如果要共用的資料目錄在 中設定了資源政策 AWS Glue，則必須更新以允許存取 ， AWS Resource Access Manager 並授予許可給帳戶 B 使用帳戶 A 的資料目錄。

如需詳細資訊，請參閱[設定 AWS Glue 資料目錄的跨帳戶存取](security-iam-cross-account-glue-catalog-access.md)。

## 選項 B：在 Lake Formation 中設定跨帳戶存取權
<a name="lf-athena-limitations-cross-account-glue-lf-xacct"></a>

AWS Lake Formation 可讓您使用單一帳戶來管理中央 Data Catalog。您可以使用此功能來實作對資料目錄中繼資料和基礎資料的[跨帳戶存取](https://docs.aws.amazon.com/lake-formation/latest/dg/access-control-cross-account.html)。例如，擁有者帳戶可以授予另一個 (收件人) 帳戶對資料表的 `SELECT` 許可。

若要在 Athena 查詢編輯器中顯示共用的資料庫或資料表，您需在 Lake Formation 中對共用的資料庫或資料表[建立資源連結](https://docs.aws.amazon.com/lake-formation/latest/dg/resource-links-about.html)。當 Lake Formation 中的收件人帳戶查詢擁有者的資料表時，[CloudTrail](https://docs.aws.amazon.com/lake-formation/latest/dg/cross-account-logging.html) 會將資料存取事件新增至收件人帳戶和擁有者帳戶的記錄。

如需共用視圖，請謹記下列要點：
+ 在目標資源連結上執行，而不是來源資料表或視圖上執行查詢，然後將輸出共用到目標帳戶。
+ 僅共用視圖並不足夠。建立視圖所涉及的所有資料表必須是跨帳戶共用的一部分。
+ 在共用資源上建立的資源連結的名稱必須與擁有者帳戶中的資源名稱相符。如果名稱不相符，則會出現一則錯誤訊息，例如分析存放檢視 'awsdatacatalog.*my-lf-resource-link*.*my-lf-view*' 失敗：行 3:3：結構描述 *schema\$1name* 不存在。

如需有關在 Lake Formation 中跨帳戶存取的詳細資訊，請參閱《AWS Lake Formation 開發人員指南》**中的以下資源：

 [跨帳戶存取](https://docs.aws.amazon.com/lake-formation/latest/dg/access-control-cross-account.html) 

 [資源連結在 Lake Formation 中如何運作](https://docs.aws.amazon.com/lake-formation/latest/dg/resource-links-about.html) 

 [跨帳戶 CloudTrail 記錄](https://docs.aws.amazon.com/lake-formation/latest/dg/cross-account-logging.html) 