AWS announces preview of AWS Interconnect - multicloud
AWS announces AWS Interconnect – multicloud (preview), providing simple, resilient, high-speed private connections to other cloud service providers. AWS Interconnect - multicloud is easy to configure and provides high-speed, resilient connectivity with dedicated bandwidth, enabling customers to interconnect AWS networking services such as AWS Transit Gateway, AWS Cloud WAN, and Amazon VPC to other cloud service providers with ease.
如何建立 Amazon Redshift Spectrum 對 AWS Glue 和 Amazon S3 的跨帳戶存取權?
我想要使用 Amazon Redshift Spectrum 在不同的 AWS 帳戶中存取 AWS Glue 和 Amazon Simple Storage Service (Amazon S3)。
解決方法
建立信任 Amazon Redshift 的 IAM 角色
若要使用 Amazon Redshift Spectrum 存取跨帳戶 AWS 資源,您必須建立信任 Amazon Redshift 的 AWS Identity and Access Management (IAM) 角色。然後,將角色附加到 Amazon Redshift 叢集。
請完成下列步驟:
- 開啟 IAM console (IAM 主控台)。
- 在導覽窗格中,選擇 Roles (角色)。
- 選擇 Create role (建立角色)。
- 在 Select type of trusted entity (選取受信任實體的類型) 中,選擇 AWS service (AWS 服務)。
- 選擇 Redshift。
- 在 Select your use case (選取使用案例) 中,選擇 Redshift - Customizable (Redshift - 可自訂)。
- 選擇 Next: Permissions (下一步:權限),Next: Tags (下一步:標籤),然後選擇 Next: Review (下一步:檢閱)。
**注意:**您不需要新增政策或標籤。 - 輸入 Role name (角色名稱),然後選擇 Create role (建立角色)。在以下範例中,角色是 redshift_role1。
- 將 redshift_role1 與 Amazon Redshift 叢集建立關聯。此關聯可讓您的叢集承擔新建立的角色,以存取 Amazon S3、Amazon Athena 和 AWS Glue。
建立可存取 AWS Glue 和 Amazon S3 的新 IAM 角色
在另一個帳戶中,建立可存取 AWS Glue 和 Amazon S3 的新 IAM 角色。Amazon Redshift 透過信任關係承擔存取 AWS Glue 和 S3 資源的角色。
請完成下列步驟:
-
開啟 IAM console (IAM 主控台)。
-
選擇 Policies (政策),然後選擇 Create policy (建立政策)。
-
選擇 ** JSON ** 索引標籤,然後輸入類似下列範例的 IAM 政策:
{ "Version": "2012-10-17", "Statement": [ { "Sid": "VisualEditor0", "Effect": "Allow", "Action": [ "glue:BatchCreatePartition", "glue:UpdateDatabase", "glue:CreateTable", "glue:DeleteDatabase", "glue:GetTables", "glue:GetPartitions", "glue:BatchDeletePartition", "glue:UpdateTable", "glue:BatchGetPartition", "glue:DeleteTable", "glue:GetDatabases", "glue:GetTable", "glue:GetDatabase", "glue:GetPartition", "glue:CreateDatabase", "glue:BatchDeleteTable", "glue:CreatePartition", "glue:DeletePartition", "glue:UpdatePartition" ], "Resource": "*" }, { "Sid": "VisualEditor1", "Effect": "Allow", "Action": [ "s3:GetObject", "s3:ListBucketMultipartUploads", "s3:ListBucket", "s3:GetBucketLocation", "s3:ListMultipartUploadParts" ], "Resource": [ "arn:aws:s3:::your_bucket", "arn:aws:s3:::your_bucket/*" ] }, { "Sid": "VisualEditor2", "Effect": "Allow", "Action": [ "kms:Decrypt" ], "Resource": [ "<KMS_KEY_ARN>" ] } ] }**注意:**將 your_bucket 替換為您要使用 Amazon Redshift Spectrum 存取之 S3 儲存貯體的名稱。將 KMS_KEY_ARN 替換為加密 S3 儲存貯體 KMS 金鑰的 ARN。如果 S3 儲存貯體中的檔案已加密,則授予 Amazon Redshift 適當的權限。
-
選擇 Review policy (檢閱政策)。
-
輸入政策名稱,然後選擇 Create policy (建立政策)。
-
在導覽窗格中,選擇 Roles (角色),然後選擇 Create role (建立角色)。
-
在 Select type of trusted entity (選取受信任實體的類型) 中,選擇 Another AWS account (其他 AWS 帳戶)。
-
在 Account ID (帳戶 ID) 中,輸入使用 Amazon Redshift 之帳戶的 ID。如需詳細資訊,請參閱使用您 AWS 帳戶 ID 的別名。
-
選擇 Next: Permissions (下一步:權限)。
-
在政策清單中,選取您建立之政策的名稱。
-
選擇 Next: Tags (下一步:標籤),然後選擇 Next: Review (下一步:檢閱)。
**注意:**您不需要新增標籤。 -
輸入 Role name (角色名稱),然後選擇 Create role (建立角色)。在以下範例中,角色是 glue_s3_role2。
-
在導覽窗格中,選擇 Roles (角色)。
-
選取您建立之角色的名稱,然後選擇 Trust Relationships (信任關係) 索引標籤。
-
選擇 Edit trust relationship (編輯信任關係)。
-
刪除現有政策,然後將其替換為類似於以下範例的政策:
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::redshift_account1:role/redshift_role1" }, "Action": "sts:AssumeRole" } ] }
**注意:**將 redshift_account1 替換為使用 Amazon Redshift 之帳戶的 ID。將 redshift_role1 替換為您建立的第一個角色的名稱。
- 選擇 Update trust policy (更新信任政策)。
更新 Amazon Redshift IAM 角色的權限
更新您建立的第一個 IAM 角色的權限。請完成下列步驟:
-
開啟 IAM console (IAM 主控台)。
-
從導覽窗格中選擇 Roles (角色),然後選擇您先前建立的第一個角色的名稱 (redshift_role1)。
-
在「權限」下,選擇 Add inline policy (新增內嵌政策)。
-
選擇 JSON 索引標籤。刪除現有政策,然後輸入類似下列範例的 IAM 政策:
{ "Version": "2012-10-17", "Statement": [ { "Sid": "Stmt1487639602000", "Effect": "Allow", "Action": [ "sts:AssumeRole" ], "Resource": "arn:aws:iam::glue_s3_account2:role/glue_s3_role2" } ] }**注意:**將 glue_s3_account2 替換為使用 AWS Glue 和 Amazon S3 之帳戶的 ID。將 glue_s3_role2 替換為您建立的第二個角色的名稱。
-
選擇 Review policy (檢閱政策)。
-
輸入政策名稱,然後選擇 Create policy (建立政策)。
-
建立一個使用您在兩個帳戶中建立之角色的外部結構描述。請參閱下列範例:
create external schema spectrum_schema from data catalog database 'your_db' iam_role 'arn:aws:iam::redshift_account1:role/redshift_role1,arn:aws:iam::glue_s3_account2:role/glue_s3_role2'**注意:**將以下值替換為如下所示:
your_db:AWS Glue 中資料庫的名稱。
redshift_account1:Amazon Redshift 帳戶的 ID。
redshift_role1:您在 Amazon Redshift 帳戶中建立之角色的名稱。
glue_s3_account2:AWS Glue 和 Amazon S3 帳戶的 ID。
glue_s3_role2:您在 AWS Glue 和 Amazon S3 帳戶中建立之角色的名稱。在「建立外部結構描述 DDL」陳述式中,依下列順序列出 IAM 角色 ARN:redshift_cluster_role、destination_account_role。角色之間不要有空格。
現在,您可以使用 redshift_account1 中 Amazon Redshift 叢集的 Amazon Redshift Spectrum 來查詢 glue_s3_account2 中的 AWS Glue 資料表。所有資源必須位於相同的 AWS 區域。您不需要重新建立外部資料表,因為 Amazon Redshift Spectrum 可以存取您現有的 AWS Glue 資料表。
下列查詢會傳回在外部結構描述中所建立 AWS Glue 表中的資料列數:
select count(*) from spectrum_schema.glue_table;
**注意:**將 spectrum_schema 和 glue_table 替換為您結構苗促和 AWS Glue 資料表的名稱。
相關資訊
- 語言
- 中文 (繁體)

相關內容
- 已提問 2 年前
AWS 官方已更新 1 年前