

# Amazon DocumentDB instance lifecycle
<a name="db-instance-life-cycle"></a>

The lifecycle of an Amazon DocumentDB instance includes creating, modifying, maintaining and upgrading, performing backups and restores, rebooting, and deleting the instance. This section provides information about how to complete these processes. 

**Topics**
+ [Adding an instance](db-instance-add.md)
+ [Describing instances](db-instance-view-details.md)
+ [Modifying an instance](db-instance-modify.md)
+ [Rebooting an instance](db-instance-reboot.md)
+ [Deleting an instance](db-instance-delete.md)

You can create a new Amazon DocumentDB instance using the AWS Management Console or the AWS CLI. To add an instance to a cluster, the cluster must be in an *available* state. You cannot add an instance to a cluster that is stopped. If the cluster is stopped, first start the cluster, wait for the cluster to become *available*, and then add an instance. For more information, see [Stopping and starting an Amazon DocumentDB cluster](db-cluster-stop-start.md). 

**Note**  
If you create an Amazon DocumentDB cluster using the console, an instance is automatically created for you at the same time. If you want to create additional instances, use one of the following procedures.

# Adding an Amazon DocumentDB instance to a cluster
<a name="db-instance-add"></a>

------
#### [ Using the AWS Management Console ]

Use the following procedure to create an instance for your cluster using the Amazon DocumentDB console.

1. Sign in to the AWS Management Console, and open the Amazon DocumentDB console at [https://console.aws.amazon.com/docdb](https://console.aws.amazon.com/docdb).

1. In the navigation pane, choose **Clusters**.
**Tip**  
If you don't see the navigation pane on the left side of your screen, choose the menu icon (![\[Hamburger menu icon with three horizontal lines.\]](http://docs.aws.amazon.com/documentdb/latest/developerguide/images/docdb-menu-icon.png)) in the upper-left corner of the page.

1. To choose the cluster that you want to add an instance to, select the button to the left of the cluster's name.

1. Choose **Actions**, and then choose **Add instances**.

1. In the **Add instance to: <cluster-name>** page, repeat the following steps for each instance that you want to add to the cluster. You can have up to 15.

   1. **Instance identifier**— You can either enter a unique identifier for this instance or allow Amazon DocumentDB to provide the instance identifier based on the cluster identifier.

      Instance naming constraints:
      + Length is [1—63] letters, numbers, or hyphens.
      + First character must be a letter.
      + Cannot end with a hyphen or contain two consecutive hyphens.
      + Must be unique for all instances across Amazon RDS, Neptune, and Amazon DocumentDB per AWS account, per Region.

   1. **Instance class** — From the drop-down list, choose the instance type you want for this instance.

   1. **Promotion tier** — From the drop-down list, choose the promotion tier for your instance or choose *No preference* to allow Amazon DocumentDB to set the promotion tier for your instance. Lower numbers mean higher priority. For more information, see [Controlling the failover target](failover.md#failover-target_control).

   1. To add more instances, choose **Add additional instances** and repeat steps a, b, and c.

1. Finish the operation.
   + To add the instances to your cluster, choose **Create**.
   + To cancel the operation, choose **Cancel**.

It takes several minutes to create an instance. You can use the console or AWS CLI to view the instance's status. For more information, see [Monitoring an instance's status](monitoring_docdb-instance_status.md). 

------
#### [ Using the AWS CLI ]

Use the `create-db-instance` AWS CLI operation with the following parameters to create the primary instance for your cluster.
+ **--db-instance-class** — Required. The compute and memory capacity of the instance, for example, `db.m4.large`. Not all instance classes are available in all AWS Regions.
+ **--db-instance-identifier** — Required. A string that identifies the instance.

  Instance Naming Constraints:
  + Length is [1—63] letters, numbers, or hyphens.
  + First character must be a letter.
  + Cannot end with a hyphen or contain two consecutive hyphens.
  + Must be unique for all instances across Amazon RDS, Neptune, and Amazon DocumentDB per AWS account, per Region.
+ **--engine** — Required. Must be `docdb`.
+ **--availability-zone** — Optional. The Availability Zone that you want this instance to be created in. Use this parameter to locate your instances in different Availability Zones to increase fault tolerance. For more information, see [Amazon DocumentDB High availability and replication](replication.md). 
+ **--promotion-tier** — Optional. The failover priority tier for this instance. Must be between 0 and 15 with lower numbers being higher priority. For more information, see [Controlling the failover target](failover.md#failover-target_control). 

1. **First, determine what Availability Zones you can create your instance in. **

   If you want to specify the Availability Zone before you create your instance, run the following command to determine which Availability Zones are available for your Amazon DocumentDB cluster.

   For Linux, macOS, or Unix:

   ```
   aws docdb describe-db-clusters \
          --query 'DBClusters[*].[DBClusterIdentifier,AvailabilityZones[*]]'
   ```

   For Windows:

   ```
   aws docdb describe-db-clusters ^
          --query 'DBClusters[*].[DBClusterIdentifier,AvailabilityZones[*]]'
   ```

   Output from this operation looks something like the following.

   ```
   [
       [
           "sample-cluster",
           [
               "us-east-1c",
               "us-east-1b",
               "us-east-1a"
           ]
       ]
   ]
   ```

1. **Second, determine what instance classes you can create in your Region. **

   To determine which instance classes are available to you in your Region, run the following command. From the output, choose an instance class for the instance you want to add to your Amazon DocumentDB cluster. 

   For Linux, macOS, or Unix:

   ```
   aws docdb describe-orderable-db-instance-options \
           --engine docdb \
           --query 'OrderableDBInstanceOptions[*].DBInstanceClass'
   ```

   For Windows:

   ```
   aws docdb describe-orderable-db-instance-options ^
           --engine docdb ^
           --query 'OrderableDBInstanceOptions[*].DBInstanceClass'
   ```

   Output from this operation looks something like the following.

   ```
   [
       "db.r5.16xlarge",
       "db.r5.2xlarge",
       "db.r5.4xlarge",
       "db.r5.8xlarge",
       "db.r5.large",
       "db.r5.xlarge"
   ]
   ```

1. **Finally, add an instance to your Amazon DocumentDB cluster.**

   To add an instance to your Amazon DocumentDB cluster, run the following command..

   For Linux, macOS, or Unix:

   ```
   aws docdb create-db-instance \
          --db-cluster-identifier sample-cluster \
          --db-instance-identifier sample-instance-2 \
          --availability-zone us-east-1b \
          --promotion-tier 2 \
          --db-instance-class db.r5.xlarge \
          --engine docdb
   ```

   For Windows:

   ```
   aws docdb create-db-instance ^
          --db-cluster-identifier sample-cluster ^
          --db-instance-identifier sample-instance-2 ^
          --availability-zone us-east-1b ^
          --promotion-tier 2 ^
          --db-instance-class db.r5.xlarge ^
          --engine docdb
   ```

   Output from this operation looks something like the following.

   ```
   {
       "DBInstance": {
           "DBInstanceIdentifier": "sample-instance-2",
           "DBInstanceClass": "db.r5.xlarge",
           "Engine": "docdb",
           "DBInstanceStatus": "creating",
           "PreferredBackupWindow": "02:00-02:30",
           "BackupRetentionPeriod": 1,
           "VpcSecurityGroups": [
               {
                   "VpcSecurityGroupId": "sg-abcd0123",
                   "Status": "active"
               }
           ],
           "AvailabilityZone": "us-east-1b",
           "DBSubnetGroup": {
               "DBSubnetGroupName": "default",
               "DBSubnetGroupDescription": "default",
               "VpcId": "vpc-6242c31a",
               "SubnetGroupStatus": "Complete",
               "Subnets": [
                   {
                       "SubnetIdentifier": "subnet-abcd0123",
                       "SubnetAvailabilityZone": {
                           "Name": "us-west-2a"
                       },
                       "SubnetStatus": "Active"
                   },
                   {
                       "SubnetIdentifier": "subnet-wxyz0123",
                       "SubnetAvailabilityZone": {
                           "Name": "us-west-2b"
                       },
                       "SubnetStatus": "Active"
                   }
               ]
           },
           "PreferredMaintenanceWindow": "sun:11:35-sun:12:05",
           "PendingModifiedValues": {},
           "EngineVersion": "3.6.0",
           "AutoMinorVersionUpgrade": true,
           "PubliclyAccessible": false,
           "DBClusterIdentifier": "sample-cluster",
           "StorageEncrypted": true,
           "KmsKeyId": "arn:aws:kms:us-east-1:<accountID>:key/sample-key",
           "DbiResourceId": "db-ABCDEFGHIJKLMNOPQRSTUVWXYZ",
           "CACertificateIdentifier": "rds-ca-2019",
           "PromotionTier": 2,
           "DBInstanceArn": "arn:aws:rds:us-east-1:<accountID>:db:sample-instance-2"
       }
   }
   ```

It takes several minutes to create the instance. You can use the console or AWS CLI to view the instance's status. For more information, see [Monitoring an Amazon DocumentDB instance's status](monitoring_docdb-instance_status.md). 

------

# Describing Amazon DocumentDB instances
<a name="db-instance-view-details"></a>

You can use either the Amazon DocumentDB Management Console or the AWS CLI to see details such as connection endpoints, security groups VPCs, certificate authority, and parameter groups pertaining to your Amazon DocumentDB instances.

------
#### [ Using the AWS Management Console ]

To view the details of your instances using the AWS Management Console, follow the steps below.

1. Sign in to the AWS Management Console, and open the Amazon DocumentDB console at [https://console.aws.amazon.com/docdb](https://console.aws.amazon.com/docdb).

1. In the navigation pane, choose **Clusters **.
**Tip**  
If you don't see the navigation pane on the left side of your screen, choose the menu icon (![\[Hamburger menu icon with three horizontal lines.\]](http://docs.aws.amazon.com/documentdb/latest/developerguide/images/docdb-menu-icon.png)) in the upper-left corner of the page.

1. In the Clusters navigation box, you’ll see the column **Cluster Identifier**. Your instances are listed under clusters, similar to the screenshot below.  
![\[Clusters table showing list of clusters under Cluster identifier column, with instances nested inside clusters.\]](http://docs.aws.amazon.com/documentdb/latest/developerguide/images/choose-clusters.png)

1. In the list of instances, choose the name of the instance that you want to see its details. The information about the instance is organized into the following groupings:
   + **Summary**—General information about the instance, including the engine version, class, status, and any pending maintenance.
   + **Connectivity & Security** —The **Connect** section lists the connection endpoints to connect to this instance with the mongo shell or with an application. The **Security Groups** section lists the security groups associated with this instance and their VPC ID and descriptions.
   + **Configuration**—The **Details** section lists the configurations and status of the instance, including the instance's Amazon Resource Name (ARN), endpoint, role, class, and certificate authority. It also lists the instance's security and network settings, and backup information. The **Cluster details** section lists the details of the cluster that this instance belongs to. The **Cluster instances** section lists all the instances that belong to your cluster with each instance's role and cluster parameter group status.
**Note**  
You can modify the cluster associated with your instance by selecting **Modify** next to the **Cluster details** header. For more information, see [Modifying an Amazon DocumentDB cluster](db-cluster-modify.md). 
   + **Monitoring**—The CloudWatch Logs metrics for this instance. For more information, see [Monitoring Amazon DocumentDB with CloudWatch](cloud_watch.md). 
   + **Events & tags** —The **Recent events** section lists the recent events for this instance. Amazon DocumentDB keeps a record of events that relate to your clusters, instances, snapshots, security groups, and cluster parameter groups. This information includes the date, time, and message associated with each event. The **Tags** section lists the tags attached to this cluster. For more information, see [Tagging Amazon DocumentDB resources](tagging.md).

------
#### [ Using the AWS CLI ]

To view the details of your Amazon DocumentDB instances using the AWS CLI, use the `describe-db-clusters` command as shown in the examples below. For more information, see [https://docs.aws.amazon.com/documentdb/latest/developerguide/API_DescribeDBInstances.html](https://docs.aws.amazon.com/documentdb/latest/developerguide/API_DescribeDBInstances.html) in the *Amazon DocumentDB Resource Management API Reference*. 

**Note**  
For certain management features such as cluster and instance lifecycle management, Amazon DocumentDB leverages operational technology that is shared with Amazon RDS. The `filterName=engine,Values=docdb` filter parameter returns only Amazon DocumentDB clusters.

1. **List all Amazon DocumentDB instances.**

   The following AWS CLI code lists the details for all Amazon DocumentDB instances in a region.

   For Linux, macOS, or Unix:

   ```
   aws docdb describe-db-instances \
       --filter Name=engine,Values=docdb
   ```

   For Windows:

   ```
   aws docdb describe-db-instances \
       --filter Name=engine,Values=docdb
   ```

1. **List all details for a specified Amazon DocumentDB instance**

   The following code lists the details for `sample-cluster-instance`. Including the `--db-instance-identifier` parameter with the name of an instance restricts the output to information on that particular instance.

   For Linux, macOS, or Unix:

   ```
   aws docdb describe-db-instances \
       --db-instance-identifier sample-cluster-instance
   ```

   For Windows:

   ```
   aws docdb describe-db-instances \
       --db-instance-identifier sample-cluster-instance
   ```

   Output from this operation looks like the following.

   ```
   {
       "DBInstances": [
           {
               "DbiResourceId": "db-BJKKB54PIDV5QFKGVRX5T3S6GM",
               "DBInstanceArn": "arn:aws:rds:us-east-1:012345678901:db:sample-cluster-instance-00",
               "VpcSecurityGroups": [
                   {
                       "VpcSecurityGroupId": "sg-77186e0d",
                       "Status": "active"
                   }
               ],
               "DBInstanceClass": "db.r5.large",
               "DBInstanceStatus": "creating",
               "AutoMinorVersionUpgrade": true,
               "PreferredMaintenanceWindow": "fri:09:32-fri:10:02",
               "BackupRetentionPeriod": 1,
               "StorageEncrypted": true,
               "DBClusterIdentifier": "sample-cluster",
               "EngineVersion": "3.6.0",
               "AvailabilityZone": "us-east-1a",
               "Engine": "docdb",
               "PromotionTier": 2,
               "DBInstanceIdentifier": "sample-cluster-instance",
               "PreferredBackupWindow": "00:00-00:30",
               "PubliclyAccessible": false,
               "DBSubnetGroup": {
                   "DBSubnetGroupName": "default",
                   "Subnets": [
                       {
                           "SubnetIdentifier": "subnet-4e26d263",
                           "SubnetAvailabilityZone": {
                               "Name": "us-east-1a"
                           },
                           "SubnetStatus": "Active"
                       },
                       {
                           "SubnetIdentifier": "subnet-afc329f4",
                           "SubnetAvailabilityZone": {
                               "Name": "us-east-1c"
                           },
                           "SubnetStatus": "Active"
                       },
                       {
                           "SubnetIdentifier": "subnet-b3806e8f",
                           "SubnetAvailabilityZone": {
                               "Name": "us-east-1e"
                           },
                           "SubnetStatus": "Active"
                       },
                       {
                           "SubnetIdentifier": "subnet-53ab3636",
                           "SubnetAvailabilityZone": {
                               "Name": "us-east-1d"
                           },
                           "SubnetStatus": "Active"
                       },
                       {
                           "SubnetIdentifier": "subnet-991cb8d0",
                           "SubnetAvailabilityZone": {
                               "Name": "us-east-1b"
                           },
                           "SubnetStatus": "Active"
                       },
                       {
                           "SubnetIdentifier": "subnet-29ab1025",
                           "SubnetAvailabilityZone": {
                               "Name": "us-east-1f"
                           },
                           "SubnetStatus": "Active"
                       }
                   ],
                   "VpcId": "vpc-91280df6",
                   "DBSubnetGroupDescription": "default",
                   "SubnetGroupStatus": "Complete"
               },
               "PendingModifiedValues": {},
               "KmsKeyId": "arn:aws:kms:us-east-1:012345678901:key/0961325d-a50b-44d4-b6a0-a177d5ff730b"
           }
       ]
   }
   ```

------

# Modifying an Amazon DocumentDB instance
<a name="db-instance-modify"></a>

You can modify your Amazon DocumentDB instance using either the AWS Management Console or the AWS CLI. To modify an instance, the instance must be in the *available* state. You cannot modify an instance that is stopped. If the cluster is stopped, first start the cluster, wait for the instance to become *available*, and then make the desired modifications. For more information, see [Stopping and starting an Amazon DocumentDB cluster](db-cluster-stop-start.md). 

------
#### [ Using the AWS Management Console ]

To modify a specific Amazon DocumentDB instance using the console, complete the following steps.

1. Sign in to the AWS Management Console, and open the Amazon DocumentDB console at [https://console.aws.amazon.com/docdb](https://console.aws.amazon.com/docdb).

1. In the navigation pane, choose **Clusters **.
**Tip**  
If you don't see the navigation pane on the left side of your screen, choose the menu icon (![\[Hamburger menu icon with three horizontal lines.\]](http://docs.aws.amazon.com/documentdb/latest/developerguide/images/docdb-menu-icon.png)) in the upper-left corner of the page.

1. In the Clusters navigation box, you’ll see the column **Cluster Identifier**. Your instances are listed under clusters, similar to the screenshot below.  
![\[Clusters table showing list of clusters under Cluster identifier column, with instances nested inside clusters.\]](http://docs.aws.amazon.com/documentdb/latest/developerguide/images/choose-clusters.png)

1. Check the box to the left of the instance you wish to modify.

1. Choose **Actions**, and then choose **Modify**.

1. In the **Modify instance: <instance-name>** pane, make the changes that you want. You can make the following changes:
   + **Instance specifications** — The instance identifier and class. Instance identifier naming constraints:
     + **Instance identifier** — Enter a name that is unique for all instances owned by your AWS account in the current region. The instance identifier must contain [1—63] alphanumeric characters or hyphens, have a letter as the first character, and cannot end with a hyphen or contain two consecutive hyphens.
     + **Instance class** — From the drop-down menu, select an instance class for your Amazon DocumentDB instance. For more information, see [Managing instance classes](db-instance-classes.md).
   + **Certificate authority** — Server certificate for this instance. For more information, see [Updating your Amazon DocumentDB TLS certificates](ca_cert_rotation.md). 
   + **Failover** — During failover, the instance with the highest promotion tier will be promoted to primary. For more information, see [Amazon DocumentDB Failover](failover.md). 
   + **Maintenance** — The maintenance window in which pending modifications or patches are applied to instances in the cluster.

1. When you have finished, choose **Continue** to see a summary of your changes.

1. After verifying your changes, you can apply them immediately or during the next maintenance window under **Scheduling of modifications**. Choose **Modify instance** to save your changes. Alternatively, you can choose **Cancel** to discard your changes.

It takes a few minutes for your changes to be applied. You can use the instance only when its status is *available*. You can monitor the instance's status using the console or AWS CLI. For more information, see [Monitoring an Amazon DocumentDB instance's status](monitoring_docdb-instance_status.md). 

------
#### [ Using the AWS CLI ]

To modify a specific Amazon DocumentDB instance using the AWS CLI, use the `modify-db-instance` with the following parameters. For more information, see [ ModifyDBInstance](https://docs.aws.amazon.com/documentdb/latest/developerguide/API_ModifyDBInstance.html). The following code modifies the instance class to `db.r5.large` for the instance `sample-instance`.

**Parameters**
+ **--db-instance-identifier** — Required. The identifier for the instance to be modified.
+ **--db-instance-class** — Optional. The new compute and memory capacity of the instance; for example, `db.r5.large`. Not all instance classes are available in all AWS Regions. If you modify the instance class, an outage occurs during the change. The change is applied during the next maintenance window, unless `ApplyImmediately` is specified as true for this request.
+ **--apply-immediately** or **--no-apply-immediately** — Optional. Specifies whether this modification should be applied immediately or wait until the next maintenance window. If this parameter is omitted, the modification is performed during the next maintenance window.

**Example**  
For Linux, macOS, or Unix:  

```
aws docdb modify-db-instance \
       --db-instance-identifier sample-instance \
       --db-instance-class db.r5.large \
       --apply-immediately
```
For Windows:  

```
aws docdb modify-db-instance ^
       --db-instance-identifier sample-instance ^
       --db-instance-class db.r5.large ^
       --apply-immediately
```
Output from this operation looks something like the following.  

```
{
    "DBInstances": [
        {
            "DBInstanceIdentifier": "sample-instance-1",
            "DBInstanceClass": "db.r5.large",
            "Engine": "docdb",
            "DBInstanceStatus": "modifying",
            "Endpoint": {                     
                "Address": "sample-instance-1.node.us-east-1.docdb.amazonaws.com",
                "Port": 27017,   
                "HostedZoneId": "ABCDEFGHIJKLM"
            },
            "InstanceCreateTime": "2020-01-10T22:18:55.921Z",
            "PreferredBackupWindow": "02:00-02:30",
            "BackupRetentionPeriod": 1,
            "VpcSecurityGroups": [
                {                             
                    "VpcSecurityGroupId": "sg-abcd0123",
                    "Status": "active"
                }
            ],
            "AvailabilityZone": "us-east-1a",
            "DBSubnetGroup": {
                "DBSubnetGroupName": "default",
                "DBSubnetGroupDescription": "default",
                "VpcId": "vpc-abcd0123",
                "SubnetGroupStatus": "Complete",
                "Subnets": [
                    {
                        "SubnetIdentifier": "subnet-abcd0123",
                        "SubnetAvailabilityZone": {
                            "Name": "us-east-1a"
                        },
                        "SubnetStatus": "Active"
                    },
                    {
                        "SubnetIdentifier": "subnet-abcd0123",
                        "SubnetAvailabilityZone": {
                            "Name": "us-east-1b"
                        },
                        "SubnetStatus": "Active"
                    }
                ]
            },
            "PreferredMaintenanceWindow": "sun:10:57-sun:11:27",
            "PendingModifiedValues": {
                "DBInstanceClass": "db.r5.large"
            },
            "EngineVersion": "3.6.0",
            "AutoMinorVersionUpgrade": true,
            "PubliclyAccessible": false,
            "DBClusterIdentifier": "sample-cluster",
            "StorageEncrypted": true,
            "KmsKeyId": "arn:aws:kms:us-east-1:123456789012:key/wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",
            "DbiResourceId": "db-ABCDEFGHIJKLMNOPQRSTUVWXYZ",
            "CACertificateIdentifier": "rds-ca-2019",
            "PromotionTier": 1,                     
            "DBInstanceArn": "arn:aws:rds:us-east-1:123456789012:db:sample-instance-1",
            "EnabledCloudwatchLogsExports": [
                "profiler"
            ]
        }
    ]
}
```

It takes a few minutes for your modifications to be applied. You can use the instance only when its status is *available*. You can monitor the instance's status using the AWS Management Console or AWS CLI. For more information, see [Monitoring an Amazon DocumentDB instance's status](monitoring_docdb-instance_status.md). 

------

# Rebooting an Amazon DocumentDB instance
<a name="db-instance-reboot"></a>

Occasionally, you might need to reboot your Amazon DocumentDB instance, usually for maintenance reasons. If you make certain changes, such as changing the cluster parameter group that is associated with a cluster, you must reboot the instances in the cluster for the changes to take effect. You can reboot a specified instance using the AWS Management Console or the AWS CLI.

Rebooting an instance restarts the database engine service. Rebooting results in a momentary outage, during which the instance status is set to `rebooting`. An Amazon DocumentDB event is created when the reboot is completed.

Rebooting an instance doesn't result in a failover. To failover an Amazon DocumentDB cluster, use the AWS Management Console or the AWS CLI operation `failover-db-cluster`. For more information, see [Amazon DocumentDB Failover](failover.md). 

You can't reboot your instance if it isn't in the *available* state. Your database can be unavailable for several reasons, such as a previously requested modification, or a maintenance-window action. For more information on instance states, see [Monitoring an Amazon DocumentDB instance's status](monitoring_docdb-instance_status.md). 

------
#### [ Using the AWS Management Console ]

The following procedure reboots an instance that you specify using the console.

1. Sign in to the AWS Management Console, and open the Amazon DocumentDB console at [https://console.aws.amazon.com/docdb](https://console.aws.amazon.com/docdb).

1. In the navigation pane, choose **Clusters **.
**Tip**  
If you don't see the navigation pane on the left side of your screen, choose the menu icon (![\[Hamburger menu icon with three horizontal lines.\]](http://docs.aws.amazon.com/documentdb/latest/developerguide/images/docdb-menu-icon.png)) in the upper-left corner of the page.

1. In the Clusters navigation box, you’ll see the column **Cluster Identifier**. Your instances are listed under clusters, similar to the screenshot below.  
![\[Clusters table showing list of clusters under Cluster identifier column, with instances nested inside clusters.\]](http://docs.aws.amazon.com/documentdb/latest/developerguide/images/choose-clusters.png)

1. Check the box to the left of the instance you wish to reboot.

1. Choose **Actions**, choose **Reboot**, and then choose **Reboot** to confirm your reboot.

It takes a few minutes for your instance to reboot. You can use the instance only when its status is *available*. You can monitor the instance's status using the console or the AWS CLI. For more information, see [Monitoring an Amazon DocumentDB instance's status](monitoring_docdb-instance_status.md). 

------
#### [ Using the AWS CLI ]

To reboot an Amazon DocumentDB instance, use the `reboot-db-instance` operation with the `--db-instance-identifier` parameter. This parameter specifies the identifier for the instance to be rebooted.

The following code reboots the instance `sample-instance`.

**Example**  
For Linux, macOS, or Unix:  

```
aws docdb reboot-db-instance \
       --db-instance-identifier sample-instance
```
For Windows:  

```
aws docdb reboot-db-instance ^
       --db-instance-identifier sample-instance
```
Output from this operation looks something like the following.  

```
{
    "DBInstance": {
        "DBInstanceIdentifier": "sample-instance",
        "DBInstanceClass": "db.r5.large",
        "Engine": "docdb",
        "DBInstanceStatus": "rebooting",
        "Endpoint": {
            "Address": "sample-instance.node.us-east-1.docdb.amazonaws.com",
            "Port": 27017,   
            "HostedZoneId": "ABCDEFGHIJKLM"
        },
        "InstanceCreateTime": "2020-03-27T08:05:56.314Z",
        "PreferredBackupWindow": "02:00-02:30",
        "BackupRetentionPeriod": 1,
        "VpcSecurityGroups": [
            {
                "VpcSecurityGroupId": "sg-abcd0123",
                "Status": "active"
            }
        ],
        "AvailabilityZone": "us-east-1c",
        "DBSubnetGroup": {
            "DBSubnetGroupName": "default",
            "DBSubnetGroupDescription": "default",
            "VpcId": "vpc-abcd0123",
            "SubnetGroupStatus": "Complete",
            "Subnets": [
                {
                    "SubnetIdentifier": "subnet-abcd0123",
                    "SubnetAvailabilityZone": {
                        "Name": "us-east-1a"
                    },
                    "SubnetStatus": "Active"
                },
                {
                    "SubnetIdentifier": "subnet-wxyz0123",
                    "SubnetAvailabilityZone": {
                        "Name": "us-east-1b"
                    },
                    "SubnetStatus": "Active"
                }
            ]
        },
        "PreferredMaintenanceWindow": "sun:06:53-sun:07:23",
        "PendingModifiedValues": {},
        "EngineVersion": "3.6.0",
        "AutoMinorVersionUpgrade": true,
        "PubliclyAccessible": false,
        "DBClusterIdentifier": "sample-cluster",
        "StorageEncrypted": true,
        "KmsKeyId": "arn:aws:kms:us-east-1:<accountID>:key/sample-key",
        "DbiResourceId": "db-ABCDEFGHIJKLMNOPQRSTUVWXYZ",
        "CACertificateIdentifier": "rds-ca-2019",
        "PromotionTier": 1,
        "DBInstanceArn": "arn:aws:rds:us-east-1:<accountID>:db:sample-instance",
        "EnabledCloudwatchLogsExports": [
            "profiler"
        ]
    }
}
```

It takes a few minutes for your instance to reboot. You can use the instance only when its status is *available*. You can monitor the instance's status using the console or AWS CLI. For more information, see [Monitoring an Amazon DocumentDB instance's status](monitoring_docdb-instance_status.md). 

------

# Deleting an Amazon DocumentDB instance
<a name="db-instance-delete"></a>

You can delete your Amazon DocumentDB instance using either the AWS Management Console or the AWS CLI. To delete an instance, the instance must be in the *available* state. You cannot delete an instance that is stopped. If the Amazon DocumentDB cluster that contains your instance is stopped, first start the cluster, wait for the instance to become *available*, and then delete the instance. For more information, see [Stopping and starting an Amazon DocumentDB cluster](db-cluster-stop-start.md). 

**Note**  
Amazon DocumentDB stores all of your data in the cluster volume. The data persists in that cluster volume, even if you remove all the instances from your cluster. If you need to access the data again, you can add an instance to the cluster at any time and pick up where you left off.

------
#### [ Using the AWS Management Console ]

The following procedure deletes a specified Amazon DocumentDB instance using the console.

1. Sign in to the AWS Management Console, and open the Amazon DocumentDB console at [https://console.aws.amazon.com/docdb](https://console.aws.amazon.com/docdb).

1. In the navigation pane, choose **Clusters **.
**Tip**  
If you don't see the navigation pane on the left side of your screen, choose the menu icon (![\[Hamburger menu icon with three horizontal lines.\]](http://docs.aws.amazon.com/documentdb/latest/developerguide/images/docdb-menu-icon.png)) in the upper-left corner of the page.

1. In the Clusters navigation box, you’ll see the column **Cluster Identifier**. Your instances are listed under clusters, similar to the screenshot below.  
![\[Clusters table showing list of clusters under Cluster identifier column, with instances nested inside clusters.\]](http://docs.aws.amazon.com/documentdb/latest/developerguide/images/choose-clusters.png)

1. Check the box to the left of the instance you wish to delete.

1. Select **Actions**, and then choose **Delete**.

   1. If you are deleting the last instance in your cluster:
      + **Create final cluster snapshot?** — Choose **Yes** if you want to create a final snapshot before the cluster is deleted. Otherwise, choose **No**.
      + **Final snapshot name** — If you choose to create a final snapshot, enter the cluster snapshot identifier of the new cluster snapshot created.
      + **Delete <instance-name> instance?** — Enter the phrase **delete entire cluster** into the field to confirm the deletion.

   1. If you are not deleting the last instance in your cluster:
      + **Delete <instance-name> instance?** — Enter the phrase **delete me** into the field to confirm the deletion. 

1. Select **Delete** to delete the instance. 

It takes several minutes for an instance to be deleted. To monitor the status of an instance, see [Monitoring an Amazon DocumentDB instance's status](monitoring_docdb-instance_status.md). 

------
#### [ Using the AWS CLI ]

The following procedure deletes an Amazon DocumentDB instance using the AWS CLI.

1. **First, determine how many instances are in your Amazon DocumentDB cluster:** 

   To determine how many instances are in your cluster, run the `describe-db-clusters` command, as follows.

   ```
   aws docdb describe-db-clusters \
       --db-cluster-identifier sample-cluster \
       --query 'DBClusters[*].[DBClusterIdentifier,DBClusterMembers[*].DBInstanceIdentifier]'
   ```

   Output from this operation looks something like the following.

   ```
   [
       [
           "sample-cluster",
           [
               "sample-instance-1",
               "sample-instance-2"
           ]
       ]
   ]
   ```

1. **If there are more than one instances in your Amazon DocumentDB cluster:**

   To delete a specified Amazon DocumentDB instance, use the `delete-db-instance` command with the `--db-instance-identifier` parameter, as shown below. It takes several minutes for an instance to be deleted. To monitor the status of an instance, see [Monitoring an Amazon DocumentDB instance's status](monitoring_docdb-instance_status.md). 

   ```
   aws docdb delete-db-instance \
          --db-instance-identifier sample-instance-2
   ```

   Output from this operation looks something like the following.

   ```
   {
       "DBInstance": {
           "DBInstanceIdentifier": "sample-instance-2",
           "DBInstanceClass": "db.r5.large",
           "Engine": "docdb",
           "DBInstanceStatus": "deleting",
           "Endpoint": {
               "Address": "sample-instance-2.node.us-east-1.docdb.amazonaws.com",
               "Port": 27017,
               "HostedZoneId": "ABCDEFGHIJKLM"
           },
           "InstanceCreateTime": "2020-03-27T08:05:56.314Z",
           "PreferredBackupWindow": "02:00-02:30",
           "BackupRetentionPeriod": 1,
           "VpcSecurityGroups": [
               {
                   "VpcSecurityGroupId": "sg-abcd0123",
                   "Status": "active"
               }
           ],
           "AvailabilityZone": "us-east-1c",
           "DBSubnetGroup": {
               "DBSubnetGroupName": "default",
               "DBSubnetGroupDescription": "default",
               "VpcId": "vpc-6242c31a",
               "SubnetGroupStatus": "Complete",
               "Subnets": [
                   {
                       "SubnetIdentifier": "subnet-abcd0123",
                       "SubnetAvailabilityZone": {
                           "Name": "us-east-1a"
                       },
                       "SubnetStatus": "Active"
                   },
                   {
                       "SubnetIdentifier": "subnet-wxyz0123",
                       "SubnetAvailabilityZone": {
                           "Name": "us-east-1b"
                       },
                       "SubnetStatus": "Active"
                   }
               ]
           },
           "PreferredMaintenanceWindow": "sun:06:53-sun:07:23",
           "PendingModifiedValues": {},
           "EngineVersion": "3.6.0",
           "AutoMinorVersionUpgrade": true,
           "PubliclyAccessible": false,
           "DBClusterIdentifier": "sample-cluster",
           "StorageEncrypted": true,
           "KmsKeyId": "arn:aws:kms:us-east-1:<accountID>:key/sample-key",
           "DbiResourceId": "db-ABCDEFGHIJKLMNOPQRSTUVWXYZ",
           "CACertificateIdentifier": "rds-ca-2019",
           "PromotionTier": 1,
           "DBInstanceArn": "arn:aws:rds:us-east-1:<accountID>:db:sample-instance-2",
           "EnabledCloudwatchLogsExports": [
               "profiler"
           ]
       }
   }
   ```

1. **If the instance your want to delete is the last instance in your Amazon DocumentDB cluster: **

   If you delete the last instance in an Amazon DocumentDB cluster, you also delete that cluster and the automatic snapshots and continuous backups associated with that cluster.

   To delete the last instance in your cluster, you can delete the cluster and optionally create a final snapshot. For more information, see [Deleting an Amazon DocumentDB cluster](db-cluster-delete.md). 

------

## Deletion protection
<a name="db-instance-delete-deletion-protection"></a>

Deleting the last instance of an Amazon DocumentDB cluster will also delete the cluster, as well as the automatic snapshots and continuous backups associated with that cluster. Amazon DocumentDB enforces deletion protection for a cluster whether you perform the delete operation using the AWS Management Console or the AWS CLI. If deletion protection is enabled, you can't delete a cluster.

To delete a cluster that has deletion protection enabled, you must first modify the cluster and disable deletion protection. For more information, see [Deleting an Amazon DocumentDB cluster](db-cluster-delete.md). 