By using Amazon DocumentDB cloning, you can create a new cluster that uses the same Amazon DocumentDB cluster volume and has the same data as the original. The process is designed to be fast and cost-effective. The new cluster with its associated data volume is known as a clone. Creating a clone is faster and more space-efficient than physically copying the data using other techniques, such as restoring a snapshot.
Amazon DocumentDB supports creating an Amazon DocumentDB provisioned clone from a provisioned Amazon DocumentDB cluster. When you create a clone using a different deployment configuration than the source, the clone is created using the latest version of the source's Amazon DocumentDB engine.
When you create clones from your Amazon DocumentDB clusters, the clones are created in your AWS account—the same account that owns the source Amazon DocumentDB cluster.
Topics
Overview of Amazon DocumentDB cloning
Amazon DocumentDB uses a copy-on-write protocol to create a clone. This mechanism uses minimal additional space to create an initial clone. When the clone is first created, Amazon DocumentDB keeps a single copy of the data that is used by the source DB cluster and the new (cloned) Amazon DocumentDB cluster. Additional storage is allocated only when changes are made to data (on the Amazon DocumentDB storage volume) by the source Amazon DocumentDB cluster or the Amazon DocumentDB cluster clone. To learn more about the copy-on-write protocol, see How Amazon DocumentDB cloning works.
Amazon DocumentDB cloning is especially useful for quickly setting up test environments using your production data, without risking data corruption. You can use clones for many types of applications, such as the following:
-
Experiment with potential changes (schema changes and parameter group changes, for example) to assess all impacts.
-
Run workload-intensive operations, such as exporting data or running analytical queries on the clone.
-
Create a copy of your production DB cluster for development, testing, or other purposes.
You can create more than one clone from the same Amazon DocumentDB cluster. You can also create multiple clones from another clone.
After creating an Amazon DocumentDB clone, you can configure the Amazon DocumentDB instances differently from the source Amazon DocumentDB cluster. For example, you might not need a clone for development purposes to meet the same high availability requirements as the source production Amazon DocumentDB cluster. In this case, you can configure the clone with a single Amazon DocumentDB instance rather than the multiple DB instances used by the Amazon DocumentDB cluster.
When you finish using the clone for your testing, development, or other purposes, you can delete it.
Limitations of Amazon DocumentDB cloning
Amazon DocumentDB; cloning currently has the following limitations:
-
You can create as many clones as you want, up to the maximum number of DB clusters allowed in the AWS Region. However, after you create 15 clones, the next clone is a full copy. The cloning operation acts like a point-in-time recovery.
-
You can't create a clone in a different AWS Region from the source Amazon DocumentDB cluster.
-
You can't create a clone from an Amazon DocumentDB cluster that has no DB instances. You can only clone Amazon DocumentDB clusters that have at least one DB instance.
-
You can create a clone in a different virtual private cloud (VPC) than that of the Amazon DocumentDB cluster. If you do, the subnets of the VPCs must map to the same Availability Zones.
How Amazon DocumentDB cloning works
Amazon DocumentDB cloning works at the storage layer of an Amazon DocumentDB cluster. It uses a copy-on-write protocol that's both fast and space-efficient in terms of the underlying durable media supporting the Amazon DocumentDB storage volume. You can learn more about Amazon DocumentDB cluster volumes in Managing Amazon DocumentDB clusters.
Understanding the copy-on-write protocol
An Amazon DocumentDB cluster stores data in pages in the underlying Amazon DocumentDB storage volume.
For example, in the following diagram you can find an Amazon DocumentDB cluster (A) that has four data pages, 1, 2, 3, and 4. Imagine that a clone, B, is created from the Amazon DocumentDB cluster. When the clone is created, no data is copied. Rather, the clone points to the same set of pages as the source Amazon DocumentDB cluster.

When the clone is created, no additional storage is usually needed. The copy-on-write protocol uses the same segment on the physical storage media as the source segment. Additional storage is required only if the capacity of the source segment isn't sufficient for the entire clone segment. If that's the case, the source segment is copied to another physical device.
In the following diagrams, you can find an example of the copy-on-write protocol in action using the same cluster A and its clone, B, as shown preceding. Let's say that you make a change to your Amazon DocumentDB cluster (A) that results in a change to data held on page 1. Instead of writing to the original page 1, Amazon DocumentDB creates a new page 1[A]. The Amazon DocumentDB cluster volume for cluster (A) now points to page 1[A], 2, 3, and 4, while the clone (B) still references the original pages.

On the clone, a change is made to page 4 on the storage volume. Instead of writing to the original page 4, Amazon DocumentDB creates a new page, 4[B]. The clone now points to pages 1, 2, 3, and to page 4[B], while the cluster (A) continues pointing to 1[A], 2, 3, and 4.

As more changes occur over time in both the source Amazon DocumentDB cluster volume and the clone, more storage is needed to capture and store the changes.
Deleting a source cluster volume
When you delete a source cluster volume that has one or more clones associated with it, the clones aren't affected. The clones continue to point to the pages that were previously owned by the source cluster volume.
Creating an Amazon DocumentDB clone
You can create a clone in the same AWS account as the source Amazon DocumentDB cluster. To do so, you can use the AWS Management Console or the AWS CLI and the procedures following.
By using Amazon DocumentDB cloning, you can create a provisioned Amazon DocumentDB cluster clone from a provisioned Amazon DocumentDB cluster.
The following procedure describes how to clone an Amazon DocumentDB cluster using the AWS Management Console.
Creating a clone using the AWS Management Console results in an Amazon DocumentDB cluster with one Amazon DocumentDB instance.
These instructions apply for DB clusters owned by the same AWS account that is creating the clone. The DB cluster must be owned by the same AWS account as cross-account cloning is not supported in Amazon DocumentDB.
To create a clone of a DB cluster owned by your AWS account using the AWS Management Console
Sign in to the AWS Management Console, and open the Amazon DocumentDB console at https://console.aws.amazon.com/docdb
. In the navigation pane, choose Clusters.
Choose your Amazon DocumentDB cluster from the list, and for Actions, choose Create clone.
The Create clone page opens, where you can configure a Cluster identifier and an Instance class, and other options for the Amazon DocumentDB cluster clone.
In the Settings section, do the following:
For Cluster identifier, enter the name that you want to give to your cloned Amazon DocumentDB cluster.
For Instance configuration, select an appropriate Instance class for your cloned Amazon DocumentDB cluster.
-
For Network settings, choose a Subnet group for your use case and the associated VPC security groups.
-
For Encryption-at-rest, if the source cluster (the cluster that is being cloned) has encryption enabled, the cloned cluster must also have encryption enabled. If this scenario is true, then the Enable encryption options are grayed out (disabled) but with the Enable encryption choice selected. Conversely, if the source cluster does not have encryption enabled, the Enable encryption options are available and you can choose to enable or disable encryption.
-
Complete the new cluster clone configuration by selecting the type of logs to export (optional), entering a specific port used to connect to the cluster, and enabling protection from accidentally deleting the cluster (enabled by default).
Finish entering all settings for your Amazon DocumentDB cluster clone. To learn more about Amazon DocumentDB cluster and instance settings, see Managing Amazon DocumentDB clusters.
-
Choose Create clone to launch the Amazon DocumentDB clone of your chosen Amazon DocumentDB cluster.
When the clone is created, it's listed with your other Amazon DocumentDB clusters in the console Databases section and displays its current state. Your clone is ready to use when its state is Available.