Deleting Aurora DB clusters and DB instances - Amazon Aurora
Services or capabilities described in AWS documentation might vary by Region. To see the differences applicable to the AWS European Sovereign Cloud Region, see the AWS European Sovereign Cloud User Guide.

Deleting Aurora DB clusters and DB instances

You can delete an Aurora DB cluster when you no longer need it. Deleting the cluster removes the cluster volume containing all your data. Before deleting the cluster, you can save a snapshot of your data. You can restore the snapshot later to create a new cluster containing the same data.

For Aurora PostgreSQL and Aurora MySQL, you can delete a DB cluster and all of its DB instances in a single step. You can also delete the DB instances individually and then delete the DB cluster.

You can also delete DB instances from a cluster while preserving the cluster itself and the data that it contains. Deleting DB instances can help you reduce your charges if the cluster isn't busy, or you don't need the computation capacity of multiple DB instances.

Deleting an Aurora DB cluster

You can delete an Aurora DB cluster in one of the following ways:

  • Delete the DB cluster and all of its DB instances in a single step (Aurora PostgreSQL and Aurora MySQL). Amazon RDS deletes every DB instance in the cluster and then deletes the cluster. For more information, see Deleting an Aurora DB cluster and its DB instances in a single step.

  • Delete the DB instances individually, and then delete the DB cluster. Use this method if you want to control the order in which DB instances are removed, or if your cluster doesn't meet the requirements for a single-step delete.

Both methods protect you from accidentally losing data. You can't delete a DB cluster that has deletion protection turned on, and you can create a final snapshot and retain automated backups.

Use the following general procedure to delete the DB instances individually and then delete the cluster itself.

  1. Delete any reader instances in the cluster. Use the procedure in Deleting a DB instance from an Aurora DB cluster.

    If the cluster has any reader instances, deleting one of the instances only reduces the computation capacity of the cluster. Deleting the reader instances first ensures that the cluster remains available throughout the procedure and doesn't perform unnecessary failover operations.

  2. Delete the writer instance from the cluster. Again, use the procedure in Deleting a DB instance from an Aurora DB cluster.

    When you delete the DB instances, the cluster and its associated cluster volume remain even after you delete all the DB instances.

  3. Delete the DB cluster.

    • AWS Management Console – Choose the cluster, then choose Delete from the Actions menu. You can choose the following options to preserve the data from the cluster in case you need it later:

      If the cluster still contains DB instances, the console lists the DB instances that will be deleted along with the cluster.

      • Create a final snapshot of the cluster volume. The default setting is to create a final snapshot.

      • Retain automated backups. The default setting is not to retain automated backups.

      Aurora also requires you to confirm that you intend to delete the cluster by entering the DB cluster name.

    • CLI and API – Call the delete-db-cluster CLI command or DeleteDBCluster API operation. You can choose the following options to preserve the data from the cluster in case you need it later:

      • Create a final snapshot of the cluster volume.

      • Retain automated backups.

Deleting an Aurora DB cluster and its DB instances in a single step

For Aurora PostgreSQL and Aurora MySQL DB clusters, you can delete a DB cluster and all of its DB instances with a single request. Amazon RDS deletes every DB instance in the DB cluster, and then deletes the DB cluster. You don't need to delete each reader and writer DB instance first. This option is available for all Aurora PostgreSQL and Aurora MySQL engine versions, in all commercial AWS Regions. It supports provisioned, Aurora Serverless v2, Aurora I/O-Optimized, and clusters created with express configuration.

When you delete a DB cluster this way, you can still create a final snapshot of the cluster volume and choose whether to retain automated backups. Aurora creates one final snapshot of the DB cluster. It doesn't create a separate snapshot for each DB instance.

Important

Deleting a DB cluster and its DB instances removes all DB instances and the cluster volume containing all your data. To preserve your data, create a final snapshot.

Prerequisites

  • IAM permissions. In addition to rds:DeleteDBCluster on the DB cluster, you must have permission for rds:DeleteDBInstance on every DB instance in the DB cluster. If you don't have permission to delete any one of the DB instances, the request fails and nothing is deleted.

  • Deletion protection. Deletion protection must be turned off for the DB cluster. For more information, see Deletion protection for Aurora clusters.

The following example IAM policy allows deleting a DB cluster and its DB instances.

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "rds:DeleteDBCluster", "Resource": "arn:aws:rds:us-east-1:123456789012:cluster:sample-cluster" }, { "Effect": "Allow", "Action": "rds:DeleteDBInstance", "Resource": "arn:aws:rds:us-east-1:123456789012:db:sample-cluster-instance-*" } ] }

Limitations

You can't delete a DB cluster and its DB instances in a single step in the following cases:

  • The DB cluster is a member of an Aurora global database. Remove the DB cluster from the global database first. For more information, see Removing a cluster from an Amazon Aurora global database.

  • The DB cluster is an Aurora PostgreSQL Limitless Database DB cluster.

  • The DB cluster is in the stopped, stopping, or starting state.

  • The DB cluster is an Aurora MySQL read replica of another Aurora DB cluster.

  • Any DB instance in the DB cluster is already in the deleting state.

  • Any DB instance in the DB cluster is switching over, or is the blue DB instance of an active blue/green deployment.

  • Any DB instance in the DB cluster has an active zero-ETL integration.

  • Any DB instance in the DB cluster is the source of an Aurora read replica DB cluster, has a read replica that is being created, or has a cross-Region read replica that is being restored.

Amazon RDS checks all of these conditions, and your permissions, before it deletes anything. If any condition applies, or if any DB instance can't be deleted, the request fails and Amazon RDS doesn't delete the DB cluster or any of its DB instances. Resolve the condition and try again, or delete the DB instances individually.

If the DB cluster doesn't contain any DB instances, Amazon RDS deletes the DB cluster the same way as when you don't use this option.

What happens during the deletion

After you confirm, the DB cluster and all of its DB instances change to the deleting state, and the request returns. Amazon RDS deletes the DB instances in parallel, and the writer DB instance doesn't fail over during the deletion.

Related resources, such as RDS Proxy targets, custom endpoints, and associated IAM roles, are handled the same way as when you delete the DB instances individually and then delete the DB cluster.

Amazon RDS emits the usual DB instance deleted event for each DB instance, the same as when you delete the DB instances individually.

To delete a DB cluster and its DB instances
  1. Sign in to the AWS Management Console and open the Amazon RDS console at https://eusc-de-east-1.console.amazonaws-eusc.eu/rds/.

  2. In the navigation pane, choose Databases, and then choose the DB cluster that you want to delete.

  3. For Actions, choose Delete.

  4. Review the list of DB instances that will be deleted along with the DB cluster.

  5. To create a final DB snapshot for the DB cluster, choose Create final snapshot?. This is the default setting.

  6. If you chose to create a final snapshot, enter the Final snapshot name. Aurora creates one snapshot of the DB cluster, not a snapshot for each DB instance.

  7. To retain automated backups, choose Retain automated backups. This is not the default setting.

  8. Enter the name of the DB cluster in the box to confirm the deletion.

  9. Choose Delete.

To delete a DB cluster and all of its DB instances by using the AWS CLI, call the delete-db-cluster command and specify the --db-cluster-identifier and --delete-db-instances options.

Example

For Linux, macOS, or Unix:

aws rds delete-db-cluster \ --db-cluster-identifier mydbcluster \ --delete-db-instances \ --final-db-snapshot-identifier mydbcluster-final-snapshot

For Windows:

aws rds delete-db-cluster ^ --db-cluster-identifier mydbcluster ^ --delete-db-instances ^ --final-db-snapshot-identifier mydbcluster-final-snapshot

To delete a DB cluster and all of its DB instances by using the Amazon RDS API, call the DeleteDBCluster operation, specify the DBClusterIdentifier parameter, and set DeleteDBInstances to true.

Deleting an empty Aurora cluster

You can delete an empty DB cluster using the AWS Management Console, AWS CLI, or Amazon RDS API.

Tip

You can keep a cluster with no DB instances to preserve your data without incurring CPU charges for the cluster. You can quickly start using the cluster again by creating one or more new DB instances for the cluster. However, you can only add new DB instances by using the AWS CLI or the RDS API. You can't add new DB instances by using the Amazon RDS console. You can perform Aurora-specific administrative operations on the cluster while it doesn't have any associated DB instances. You just can't access the data or perform any operations that require connecting to a DB instance.

To delete a DB cluster
  1. Sign in to the AWS Management Console and open the Amazon RDS console at https://eusc-de-east-1.console.amazonaws-eusc.eu/rds/.

  2. In the navigation pane, choose Databases, and then choose the DB cluster that you want to delete.

  3. For Actions, choose Delete.

  4. To create a final DB snapshot for the DB cluster, choose Create final snapshot?. This is the default setting.

  5. If you chose to create a final snapshot, enter the Final snapshot name.

  6. To retain automated backups, choose Retain automated backups. This is not the default setting.

  7. Enter the name of the DB cluster in the box.

  8. Choose Delete.

To delete an empty Aurora DB cluster by using the AWS CLI, call the delete-db-cluster command.

Suppose that the empty cluster deleteme-zero-instances was only used for development and testing and doesn't contain any important data. In that case, you don't need to preserve a snapshot of the cluster volume when you delete the cluster. The following example demonstrates that a cluster doesn't contain any DB instances, and then deletes the empty cluster without creating a final snapshot or retaining automated backups.

$ aws rds describe-db-clusters --db-cluster-identifier deleteme-zero-instances --output text \ --query '*[].["Cluster:",DBClusterIdentifier,DBClusterMembers[*].["Instance:",DBInstanceIdentifier,IsClusterWriter]] Cluster: deleteme-zero-instances $ aws rds delete-db-cluster --db-cluster-identifier deleteme-zero-instances \ --skip-final-snapshot \ --delete-automated-backups { "DBClusterIdentifier": "deleteme-zero-instances", "Status": "available", "Engine": "aurora-mysql" }

To delete an empty Aurora DB cluster by using the Amazon RDS API, call the DeleteDBCluster operation.

Deleting an Aurora cluster with a single DB instance

You can delete the last DB instance, even if the DB cluster has deletion protection enabled. In this case, the DB cluster itself still exists and your data is preserved. You can access the data again by attaching a new DB instance to the cluster.

Tip

To delete the cluster and its writer DB instance in one call, specify --delete-db-instances. For more information, see Deleting an Aurora DB cluster and its DB instances in a single step.

The following example shows how the delete-db-cluster command doesn't work when the cluster still has any associated DB instances and you don't specify the --delete-db-instances option. This cluster has a single writer DB instance. When we examine the DB instances in the cluster, we check the IsClusterWriter attribute of each one. The cluster could have zero or one writer DB instance. A value of true signifies a writer DB instance. A value of false signifies a reader DB instance. The cluster could have zero, one, or many reader DB instances. In this case, we delete the writer DB instance using the delete-db-instance command. As soon as the DB instance goes into deleting state, we can delete the cluster also. For this example also, suppose that the cluster doesn't contain any data worth preserving. Therefore, we don't create a snapshot of the cluster volume or retain automated backups.

$ aws rds delete-db-cluster --db-cluster-identifier deleteme-writer-only --skip-final-snapshot An error occurred (InvalidDBClusterStateFault) when calling the DeleteDBCluster operation: Cluster cannot be deleted, it still contains DB instances in non-deleting state. $ aws rds describe-db-clusters --db-cluster-identifier deleteme-writer-only \ --query '*[].[DBClusterIdentifier,Status,DBClusterMembers[*].[DBInstanceIdentifier,IsClusterWriter]]' [ [ "deleteme-writer-only", "available", [ [ "instance-2130", true ] ] ] ] $ aws rds delete-db-instance --db-instance-identifier instance-2130 { "DBInstanceIdentifier": "instance-2130", "DBInstanceStatus": "deleting", "Engine": "aurora-mysql" } $ aws rds delete-db-cluster --db-cluster-identifier deleteme-writer-only \ --skip-final-snapshot \ --delete-automated-backups { "DBClusterIdentifier": "deleteme-writer-only", "Status": "available", "Engine": "aurora-mysql" }

Deleting an Aurora cluster with multiple DB instances

If your cluster contains multiple DB instances, typically there is a single writer instance and one or more reader instances. The reader instances help with high availability, by being on standby to take over if the writer instance encounters a problem. You can also use reader instances to scale the cluster up to handle a read-intensive workload without adding overhead to the writer instance.

To delete a cluster with multiple DB instances in a single step, use the --delete-db-instances option. For more information, see Deleting an Aurora DB cluster and its DB instances in a single step.

To delete the DB instances individually, delete the reader instances first and then the writer instance. Deleting the writer instance leaves the cluster and its data in place. You delete the cluster through a separate action.

This CLI example shows how to delete a cluster containing both a writer DB instance and a single reader DB instance. The describe-db-clusters output shows that instance-7384 is the writer instance and instance-1039 is the reader instance. The example deletes the reader instance first, because deleting the writer instance while a reader instance still existed would cause a failover operation. It doesn't make sense to promote the reader instance to a writer if you plan to delete that instance also. Again, suppose that these db.t2.small instances are only used for development and testing, and so the delete operation skips the final snapshot and doesn't retain automated backups.

$ aws rds delete-db-cluster --db-cluster-identifier deleteme-writer-and-reader --skip-final-snapshot An error occurred (InvalidDBClusterStateFault) when calling the DeleteDBCluster operation: Cluster cannot be deleted, it still contains DB instances in non-deleting state. $ aws rds describe-db-clusters --db-cluster-identifier deleteme-writer-and-reader --output text \ --query '*[].["Cluster:",DBClusterIdentifier,DBClusterMembers[*].["Instance:",DBInstanceIdentifier,IsClusterWriter]] Cluster: deleteme-writer-and-reader Instance: instance-1039 False Instance: instance-7384 True $ aws rds delete-db-instance --db-instance-identifier instance-1039 { "DBInstanceIdentifier": "instance-1039", "DBInstanceStatus": "deleting", "Engine": "aurora-mysql" } $ aws rds delete-db-instance --db-instance-identifier instance-7384 { "DBInstanceIdentifier": "instance-7384", "DBInstanceStatus": "deleting", "Engine": "aurora-mysql" } $ aws rds delete-db-cluster --db-cluster-identifier deleteme-writer-and-reader \ --skip-final-snapshot \ --delete-automated-backups { "DBClusterIdentifier": "deleteme-writer-and-reader", "Status": "available", "Engine": "aurora-mysql" }

The following example shows how to delete a DB cluster containing a writer DB instance and multiple reader DB instances. It uses concise output from the describe-db-clusters command to get a report of the writer and reader instances. Again, we delete all reader DB instances before deleting the writer DB instance. It doesn't matter what order we delete the reader DB instances in.

Suppose that this cluster with several DB instances does contain data worth preserving. Thus, the delete-db-cluster command in this example includes the --no-skip-final-snapshot and --final-db-snapshot-identifier parameters to specify the details of the snapshot to create. It also includes the --no-delete-automated-backups parameter to retain automated backups.

$ aws rds describe-db-clusters --db-cluster-identifier deleteme-multiple-readers --output text \ --query '*[].["Cluster:",DBClusterIdentifier,DBClusterMembers[*].["Instance:",DBInstanceIdentifier,IsClusterWriter]] Cluster: deleteme-multiple-readers Instance: instance-1010 False Instance: instance-5410 False Instance: instance-9948 False Instance: instance-8451 True $ aws rds delete-db-instance --db-instance-identifier instance-1010 { "DBInstanceIdentifier": "instance-1010", "DBInstanceStatus": "deleting", "Engine": "aurora-mysql" } $ aws rds delete-db-instance --db-instance-identifier instance-5410 { "DBInstanceIdentifier": "instance-5410", "DBInstanceStatus": "deleting", "Engine": "aurora-mysql" } $ aws rds delete-db-instance --db-instance-identifier instance-9948 { "DBInstanceIdentifier": "instance-9948", "DBInstanceStatus": "deleting", "Engine": "aurora-mysql" } $ aws rds delete-db-instance --db-instance-identifier instance-8451 { "DBInstanceIdentifier": "instance-8451", "DBInstanceStatus": "deleting", "Engine": "aurora-mysql" } $ aws rds delete-db-cluster --db-cluster-identifier deleteme-multiple-readers \ --no-delete-automated-backups \ --no-skip-final-snapshot \ --final-db-snapshot-identifier deleteme-multiple-readers-final-snapshot { "DBClusterIdentifier": "deleteme-multiple-readers", "Status": "available", "Engine": "aurora-mysql" }

The following example shows how to confirm that Aurora created the requested snapshot. You can request details for the specific snapshot by specifying its identifier deleteme-multiple-readers-final-snapshot. You can also get a report of all snapshots for the cluster that was deleted by specifying the cluster identifier deleteme-multiple-readers. Both of those commands return information about the same snapshot.

$ aws rds describe-db-cluster-snapshots \ --db-cluster-snapshot-identifier deleteme-multiple-readers-final-snapshot { "DBClusterSnapshots": [ { "AvailabilityZones": [], "DBClusterSnapshotIdentifier": "deleteme-multiple-readers-final-snapshot", "DBClusterIdentifier": "deleteme-multiple-readers", "SnapshotCreateTime": "11T01:40:07.354000+00:00", "Engine": "aurora-mysql", ... $ aws rds describe-db-cluster-snapshots --db-cluster-identifier deleteme-multiple-readers { "DBClusterSnapshots": [ { "AvailabilityZones": [], "DBClusterSnapshotIdentifier": "deleteme-multiple-readers-final-snapshot", "DBClusterIdentifier": "deleteme-multiple-readers", "SnapshotCreateTime": "11T01:40:07.354000+00:00", "Engine": "aurora-mysql", ...

Deletion protection for Aurora clusters

You can't delete clusters that have deletion protection enabled. You can delete DB instances within the cluster, but not the cluster itself. That way, the cluster volume containing all your data is safe from accidental deletion. Aurora enforces deletion protection for a DB cluster whether you try to delete the cluster using the console, the AWS CLI, or the RDS API.

If you delete a cluster and its DB instances in a single step, deletion protection must be turned off for the DB cluster. If deletion protection is turned on, the request fails and Amazon RDS doesn't delete the DB cluster or any of its DB instances.

Deletion protection is enabled by default when you create a production DB cluster using the AWS Management Console. However, deletion protection is disabled by default if you create a cluster using the AWS CLI or API. Enabling or disabling deletion protection doesn't cause an outage. To be able to delete the cluster, modify the cluster and disable deletion protection. For more information about turning deletion protection on and off, see Modifying the DB cluster by using the console, CLI, and API.

Tip

Even if all the DB instances are deleted, you can access the data by creating a new DB instance in the cluster.

Deleting a stopped Aurora cluster

You can't delete a cluster if it's in the stopped state. In this case, start the cluster before deleting it. For more information, see Starting an Aurora DB cluster.

This also applies when you delete a cluster and its DB instances in a single step. You can't use this option while the cluster is in the stopped, stopping, or starting state. Start the cluster, wait until its status is available, and then delete it.

Deleting Aurora MySQL clusters that are read replicas

For Aurora MySQL, you can't delete a DB instance in a DB cluster if both of the following conditions are true:

  • The DB cluster is a read replica of another Aurora DB cluster.

  • The DB instance is the only instance in the DB cluster.

To delete a DB instance in this case, first promote the DB cluster so that it's no longer a read replica. After the promotion completes, you can delete the final DB instance in the DB cluster. For more information, see Replicating Amazon Aurora MySQL DB clusters across AWS Regions.

You can't delete a DB cluster and its DB instances in a single step if any DB instance in the cluster is the source of an Aurora read replica DB cluster, has a read replica that is being created, or has a cross-Region read replica that is being restored. Delete or promote the read replicas first, or wait for the read replica creation or restore to finish.

You also can't delete a DB cluster and its DB instances in a single step if the DB cluster is itself an Aurora MySQL read replica of another Aurora DB cluster.

The final snapshot when deleting a cluster

Throughout this section, the examples show how you can choose whether to take a final snapshot when you delete an Aurora cluster, including when you delete the cluster and its DB instances in a single step. If you choose to take a final snapshot but the name you specify matches an existing snapshot, the operation stops with an error and no DB instances are deleted. In this case, examine the snapshot details to confirm if it represents your current detail or if it is an older snapshot. If the existing snapshot doesn't have the latest data that you want to preserve, rename the snapshot and try again, or specify a different name for the final snapshot parameter.

Deleting a DB instance from an Aurora DB cluster

You can delete a DB instance from an Aurora DB cluster as part of the process of deleting the entire cluster. To delete the cluster and all of its DB instances together, see Deleting an Aurora DB cluster and its DB instances in a single step. You can also delete one or more reader instances from a cluster while leaving the cluster running. You might do so to reduce compute capacity and associated charges if your cluster isn't busy.

To delete a DB instance, you specify the name of the instance.

You can delete a DB instance using the AWS Management Console, the AWS CLI, or the RDS API.

Note

When an Aurora Replica is deleted, its instance endpoint is removed immediately, and the Aurora Replica is removed from the reader endpoint. If there are statements running on the Aurora Replica that is being deleted, there is a three-minute grace period. Existing statements can finish during the grace period. When the grace period ends, the Aurora Replica is shut down and deleted.

For Aurora DB clusters, deleting a DB instance doesn't necessarily delete the entire cluster. You can delete a DB instance in an Aurora cluster to reduce compute capacity and associated charges when the cluster isn't busy. For information about the special circumstances for Aurora clusters that have one DB instance or zero DB instances, see Deleting an Aurora cluster with a single DB instance and Deleting an empty Aurora cluster.

Note

You can't delete a DB cluster when deletion protection is enabled for it. For more information, see Deletion protection for Aurora clusters.

You can disable deletion protection by modifying the DB cluster. For more information, see Modifying an Amazon Aurora DB cluster.

To delete a DB instance in a DB cluster
  1. Sign in to the AWS Management Console and open the Amazon RDS console at https://eusc-de-east-1.console.amazonaws-eusc.eu/rds/.

  2. In the navigation pane, choose Databases, and then choose the DB instance that you want to delete.

  3. For Actions, choose Delete.

  4. Enter delete me in the box.

  5. Choose Delete.

To delete a DB instance by using the AWS CLI, call the delete-db-instance command and specify the --db-instance-identifier value.

Example

For Linux, macOS, or Unix:

aws rds delete-db-instance \ --db-instance-identifier mydbinstance

For Windows:

aws rds delete-db-instance ^ --db-instance-identifier mydbinstance

To delete a DB instance by using the Amazon RDS API, call the DeleteDBInstance operation and specify the DBInstanceIdentifier parameter.

Note

When the status for a DB instance is deleting, its CA certificate value doesn't appear in the RDS console or in output for AWS CLI commands or RDS API operations. For more information about CA certificates, see Using SSL/TLS to encrypt a connection to a DB cluster.