本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
共用 Amazon DocumentDB 叢集快照
使用 Amazon DocumentDB,您可以透過下列方式共用手動叢集快照:
若要共用自動化叢集快照,請複製自動化快照來建立手動叢集快照,然後共用該複本。此程序也適用於 AWS Backup 產生的資源。
您最多可以與其他 20 個 共用手動快照 AWS 帳戶。您也可以將未加密的手動快照以公有形式共用,讓所有 帳戶都可使用此快照。將快照以公有形式共用時,請確保不要在任何公有快照中包含您的私人資訊。
與其他 共用手動快照, AWS 帳戶並使用 AWS CLI 或 Amazon DocumentDB API 從共用快照還原叢集時,您必須指定共用快照的 Amazon Resource Name (ARN) 做為快照識別符。
共用加密快照
共用加密快照有下列限制:
請按照以下步驟共用加密的快照。
-
與您想要能夠存取快照的任何帳戶共用用來加密快照的 AWS Key Management Service (AWS KMS) 加密金鑰。
您可以將其他 AWS 帳戶新增至金鑰政策,以與其他帳戶共用 AWS KMS 加密 AWS KMS 金鑰。如需更新金鑰政策的詳細資訊,請參閱《 AWS Key Management Service 開發人員指南》中的在 AWS KMS 中使用金鑰政策。有關建立金鑰政策的範例,請參閱本主題稍後的建立 IAM 政策以允許複製加密快照。
-
使用 與其他帳戶共用加密快照 AWS CLI,如下所示。
允許存取 AWS KMS 加密金鑰
若要 AWS 帳戶 讓另一個 複製從您的帳戶共用的加密快照,您與之共用快照的帳戶必須能夠存取加密快照的 AWS KMS 金鑰。若要允許另一個帳戶存取 AWS KMS 金鑰,請使用您在金鑰政策中以委託人身分共用的帳戶 AWS KMS ARN 來更新金鑰的 AWS KMS 金鑰政策。然後允許 kms:CreateGrant
動作。
將 AWS KMS 加密金鑰的存取權授予帳戶後,若要複製加密快照,如果該帳戶還沒有加密快照,則必須建立 AWS Identity and Access Management (IAM) 使用者。此外,該帳戶也必須將 IAM 政策連接至該 IAM 使用者,以允許使用者使用您的 AWS KMS 金鑰複製加密快照。帳戶必須是 IAM 使用者,且由於 AWS KMS 安全限制,不能是根 AWS 帳戶 身分。
在下列金鑰政策範例中,使用者 123451234512 是 AWS KMS 加密金鑰的擁有者。使用者 123456789012 是共用金鑰的帳戶。此更新的金鑰政策可讓帳戶存取 AWS KMS 金鑰。它透過將使用者 123456789012 根 AWS 帳戶 身分的 ARN 作為政策的主體,以及允許 kms:CreateGrant
動作來執行此操作。
- JSON
-
-
{
"Id": "key-policy-1",
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Allow use of the key",
"Effect": "Allow",
"Principal": {"AWS": [
"arn:aws:iam::123451234512:user/KeyUser",
"arn:aws:iam::123456789012:root"
]},
"Action": [
"kms:CreateGrant",
"kms:Encrypt",
"kms:Decrypt",
"kms:ReEncrypt*",
"kms:GenerateDataKey*",
"kms:DescribeKey"
],
"Resource": "*"},
{
"Sid": "Allow attachment of persistent resources",
"Effect": "Allow",
"Principal": {"AWS": [
"arn:aws:iam::123451234512:user/KeyUser",
"arn:aws:iam::123456789012:root"
]},
"Action": [
"kms:CreateGrant",
"kms:ListGrants",
"kms:RevokeGrant"
],
"Resource": "*",
"Condition": {"Bool": {"kms:GrantIsForAWSResource": true}}
}
]
}
建立 IAM 政策以允許複製加密快照
當外部 AWS 帳戶 可以存取您的 AWS KMS 金鑰時,該帳戶的擁有者可以建立政策,以允許為帳戶建立的 IAM 使用者複製使用該 AWS KMS 金鑰加密的加密快照。
下列範例顯示可連接至 IAM 使用者 AWS 帳戶 123456789012 的政策。此政策可讓 IAM 使用者從已在 c989c1dd-a3f2-4a5d-8d96-e793d082ab26
us-west-2 區域中使用 AWS KMS 金鑰加密的帳戶 123451234512 複製共用快照。
- JSON
-
-
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowUseOfTheKey",
"Effect": "Allow",
"Action": [
"kms:Encrypt",
"kms:Decrypt",
"kms:ReEncrypt*",
"kms:GenerateDataKey*",
"kms:DescribeKey",
"kms:CreateGrant",
"kms:RetireGrant"
],
"Resource": ["arn:aws:kms:us-west-2:123451234512:key/c989c1dd-a3f2-4a5d-8d96-e793d082ab26"]
},
{
"Sid": "AllowAttachmentOfPersistentResources",
"Effect": "Allow",
"Action": [
"kms:CreateGrant",
"kms:ListGrants",
"kms:RevokeGrant"
],
"Resource": ["arn:aws:kms:us-west-2:123451234512:key/c989c1dd-a3f2-4a5d-8d96-e793d082ab26"],
"Condition": {
"Bool": {
"kms:GrantIsForAWSResource": true
}
}
}
]
}
如需更新金鑰政策的詳細資訊,請參閱《 AWS Key Management Service 開發人員指南》中的在 中使用金鑰政策 AWS KMS。
共用快照
您可以使用 或 共用 Amazon DocumentDB 手動叢集快照 ( AWS Management Console 或自動化快照的副本) AWS CLI:
- Using the AWS Management Console
-
若要使用 共用快照 AWS Management Console,請完成下列步驟:
登入 AWS Management Console,並在 https://console.aws.amazon.com/docdb:// 開啟 Amazon DocumentDB 主控台。
在導覽窗格中,選擇 Snapshots (快照)。
選取您要共享的手動快照。
在動作下拉式功能表中,選擇共用。
為資料庫快照可見性選擇下列其中一個選項:
針對AWS 帳戶 ID,輸入您要允許 從手動快照還原叢集之帳戶 AWS 的帳戶識別符,然後選擇新增。重複 以包含額外的 AWS 帳戶識別符,最多 20 個 AWS 帳戶。
如果您在將 AWS 帳戶識別符新增至允許的帳戶清單時發生錯誤,您可以選擇不正確 AWS 帳戶識別符右側的刪除,將其從清單中刪除。
為要允許還原手動快照的所有 AWS 帳戶新增識別符後,請選擇儲存以儲存變更。
- Using the AWS CLI
-
若要使用 共用快照 AWS CLI,請使用 Amazon DocumentDB modify-db-snapshot-attribute
操作。使用 --values-to-add
參數來新增 AWS 帳戶 有權還原手動快照IDs 清單。
下列範例允許兩個 AWS 帳戶 識別符 123451234512 和 123456789012 還原名為 的快照manual-snapshot1
。這還會移除 all
屬性值,以將快照標記為私有。
若為 Linux、macOS 或 Unix:
aws docdb modify-db-cluster-snapshot-attribute \
--db-cluster-snapshot-identifier sample-cluster-snapshot \
--attribute-name restore \
--values-to-add '["123451234512","123456789012"]'
針對 Windows:
aws docdb modify-db-cluster-snapshot-attribute ^
--db-cluster-snapshot-identifier sample-cluster-snapshot ^
--attribute-name restore ^
--values-to-add '["123451234512","123456789012"]'
此操作的輸出將會如下所示。
{
"DBClusterSnapshotAttributesResult": {
"DBClusterSnapshotIdentifier": "sample-cluster-snapshot",
"DBClusterSnapshotAttributes": [
{
"AttributeName": "restore",
"AttributeValues": [
"123451234512",
"123456789012"
]
}
]
}
}
若要從清單中移除 AWS 帳戶 識別符,請使用 --values-to-remove
參數。下列範例可防止 AWS 帳戶 ID 123456789012 還原快照。
若為 Linux、macOS 或 Unix:
aws docdb modify-db-cluster-snapshot-attribute \
--db-cluster-snapshot-identifier sample-cluster-snapshot \
--attribute-name restore \
--values-to-remove '["123456789012"]'
針對 Windows:
aws docdb modify-db-cluster-snapshot-attribute ^
--db-cluster-snapshot-identifier sample-cluster-snapshot ^
--attribute-name restore ^
--values-to-remove '["123456789012"]'
此操作的輸出將會如下所示。
{
"DBClusterSnapshotAttributesResult": {
"DBClusterSnapshotIdentifier": "sample-cluster-snapshot",
"DBClusterSnapshotAttributes": [
{
"AttributeName": "restore",
"AttributeValues": [
"123451234512"
]
}
]
}
}