設定沒有共用 VPC 的 Amazon Keyspaces 跨帳戶存取 - Amazon Keyspaces (適用於 Apache Cassandra)

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

設定沒有共用 VPC 的 Amazon Keyspaces 跨帳戶存取

如果 Amazon Keyspaces 資料表和私有 VPC 端點為不同帳戶所擁有,但未共用 VPC,則應用程式仍然可以使用 VPC 端點來連接跨帳戶。由於帳戶不會共用 VPC 端點,Account B因此 Account A、 和 Account C需要自己的 VPC 端點。對於 Cassandra 用戶端驅動程式,Amazon Keyspaces 會顯示為單一節點,而不是多節點叢集。連線時,用戶端驅動程式會到達 DNS 伺服器,傳回帳戶 VPC 中其中一個可用的端點。

您也可以使用公有端點或在每個帳戶中部署私有 VPC 端點,在不同的帳戶中存取 Amazon Keyspaces 資料表,而無需共用 VPC 端點。不使用共用 VPC 時,每個帳戶都需要自己的 VPC 端點。在此範例中,Account AAccount BAccount C需要自己的 VPC 端點才能存取 中的資料表Account A。在此組態中使用 VPC 端點時,Amazon Keyspaces 會顯示為 Cassandra 用戶端驅動程式的單一節點叢集,而非多節點叢集。連線時,用戶端驅動程式會到達 DNS 伺服器,傳回帳戶 VPC 中其中一個可用的端點。但用戶端驅動程式無法存取system.peers資料表來探索其他端點。由於可用的主機較少,驅動程式的連線較少。若要調整,請將驅動程式的連線集區設定增加 3 倍。

圖表顯示沒有共用 VPC 的相同組織在 AWS 區域 中擁有的三個不同帳戶。

Account A 是包含 Account BAccount C 需要存取之資源 (Amazon Keyspaces 資料表) 的帳戶,信任帳戶Account A也是 。 Account BAccount C是具有 中需要存取資源 (Amazon Keyspaces 資料表) 之主體的帳戶Account A,因此 Account BAccount C信任帳戶。信任帳戶透過共用 IAM 角色將許可授予信任的帳戶。下列程序概述 中所需的組態步驟Account A

的組態 Account A
  1. 在 中建立 Amazon Keyspaces 金鑰空間和資料表Account A

  2. 在 中建立Account A具有 Amazon Keyspaces 資料表完整存取權和 Amazon Keyspaces 系統資料表讀取存取權的 IAM 角色。

    { "Version":"2012-10-17", "Statement":[ { "Effect":"Allow", "Action":[ "cassandra:Select", "cassandra:Modify" ], "Resource":[ "arn:aws:cassandra:region:Account-A:/keyspace/mykeyspace/table/mytable", "arn:aws:cassandra:region:Account-A:/keyspace/system*" ] } ] }
  3. 在 中設定 IAM 角色的信任政策,Account AAccount B和 中的主體Account C可以擔任信任帳戶的角色。如以下範例所示。

    { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::AccountB:role/Cross-Account-Role-B", "AWS": "arn:aws:iam::AccountC:role/Cross-Account-Role-C" }, "Action": "sts:AssumeRole", "Condition": {} } ] }

    如需跨帳戶 IAM 政策的詳細資訊,請參閱《IAM 使用者指南》中的跨帳戶政策

  4. 在 中設定 VPC 端點,Account A並將許可連接到允許來自 Account B和 的角色Account A使用 VPC 端點Account C擔任 中角色的端點。這些許可對其連接的 VPC 端點有效。如需 VPC 端點政策的詳細資訊,請參閱 控制對 Amazon Keyspaces 介面 VPC 端點的存取

    { "Version": "2012-10-17", "Statement": [ { "Sid": "Allow-access-from-specific-IAM-roles", "Effect": "Allow", "Principal": "*", "Action": "cassandra:*", "Resource": "*", "Condition": { "ArnEquals": { "aws:PrincipalArn": "arn:aws:iam::AccountB:role/Cross-Account-Role-B", "aws:PrincipalArn": "arn:aws:iam::AccountC:role/Cross-Account-Role-C" } } } ] }
Account B 和 中的組態 Account C
  1. Account B和 中Account C,建立新的角色並連接下列政策,以允許委託人擔任在 中建立的共用角色Account A

    { "Version": "2012-10-17", "Statement": { "Effect": "Allow", "Action": "sts:AssumeRole", "Resource": "arn:aws:iam::Account-A:role/keyspaces_access" } }

    允許委託人擔任共用角色是使用 AWS Security Token Service (AWS STS) 的 AssumeRole API 實作。如需詳細資訊,請參閱《IAM 使用者指南》中的在您擁有 AWS 帳戶 的另一個 中為 IAM 使用者提供存取權

  2. Account B和 中Account C,您可以建立使用 SIGV4 身分驗證外掛程式的應用程式,允許應用程式擔任共用角色以連線到位於 中的 Amazon Keyspaces 資料表Account A。如需 SIGV4 身分驗證外掛程式的詳細資訊,請參閱 建立 Amazon Keyspaces 的程式設計存取憑證 。如需如何設定應用程式以在另一個 AWS 帳戶中擔任角色的詳細資訊,請參閱 AWS SDKs和工具參考指南中的身分驗證和存取