Deleting a DB Instance - Amazon Relational Database Service

Deleting a DB Instance

To delete a DB instance, you must do the following:

  • Provide the name of the instance

  • Enable or disable the option to take a final DB snapshot of the instance

  • Enable or disable the option to retain automated backups

If the DB instance that you want to delete has a read replica, you should either promote the read replica or delete it. For more information, see Promoting a Read Replica to Be a Standalone DB Instance.

Deletion Protection

You can only delete instances that don't have deletion protection enabled. When you create or modify a DB instance, you have the option to enable deletion protection so that users can't delete the DB instance. Deletion protection is disabled by default for you when you use AWS CLI and API commands. Deletion protection is enabled for you when you use the AWS Management Console to create a production DB instance. However, Amazon RDS enforces deletion protection when you use the console, the CLI, or the API to delete a DB instance. To delete a DB instance that has deletion protection enabled, first modify the instance and disable deletion protection. Enabling or disabling deletion protection doesn't cause an outage.

Creating a Final Snapshot and Retaining Automated Backups

When you delete a DB instance, you can choose whether to create a final snapshot of the DB instance. You can also choose to retain automated backups after the DB instance is deleted, up to the retention period set on your DB instance. To be able to restore the DB instance later, create a final snapshot, retain automated backups, or both.

When you delete a DB instance, you have the following choices:

  • Create a final DB snapshot.

    To be able to restore your deleted DB instance later, create a final DB snapshot.

    To delete a DB instance quickly, you can skip creating a final DB snapshot.

    Important

    If you skip the final DB snapshot, to restore your DB instance you will need to do one of the following:

    • Use an earlier manual snapshot of the DB instance to restore the DB instance to that DB snapshot's point in time.

    • Retain automated backups. You can use those to restore your DB instance during your retention period, but not after your retention period has ended.

    You can't create a final DB snapshot of your DB instance if it has the status creating, failed, incompatible-restore, or incompatible-network. For more information about DB instance statuses, see DB Instance Status.

  • Retain automated backups.

    You can choose to retain automated backups when you delete a DB instance. Your automated backups are retained for the retention period that is set on the DB instance at the time that you delete it. This set retention period occurs whether or not you choose to create a final DB snapshot.

    To delete a retained automated backup, follow the instructions in Deleting Retained Automated Backups.

    If you don't choose to retain automated backups, your automated backups are deleted and can't be recovered when you delete a DB instance. You typically don't need to retain automated backups if you create a final DB snapshot.

Note

Regardless of your choice, earlier manual DB snapshots aren't deleted.

Deleting a DB Instance by Using the Console, CLI, and API

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

To delete a DB instance

  1. Sign in to the AWS Management Console and open the Amazon RDS console at https://console.aws.amazon.com/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. To create a final DB snapshot for the DB instance, enable Create final snapshot?.

  5. If you enabled Create final snapshot? in the previous step, for Final snapshot name enter the name of your final DB snapshot.

  6. To retain automated backups, choose Retain automated backups.

  7. Enter delete me in the box.

  8. Choose Delete.

To delete a DB instance by using the AWS CLI, call the delete-db-instance command with the following options:

  • --db-instance-identifier

  • --final-db-snapshot-identifier or --skip-final-snapshot

Example With a final snapshot and no retained automated backups

For Linux, macOS, or Unix:

aws rds delete-db-instance \ --db-instance-identifier mydbinstance \ --final-db-snapshot-identifier mydbinstancefinalsnapshot \ --delete-automated-backups

For Windows:

aws rds delete-db-instance ^ --db-instance-identifier mydbinstance ^ --final-db-snapshot-identifier mydbinstancefinalsnapshot ^ --delete-automated-backups

Example With retained automated backups and no final snapshot

For Linux, macOS, or Unix:

aws rds delete-db-instance \ --db-instance-identifier mydbinstance \ --skip-final-snapshot \ --no-delete-automated-backups

For Windows:

aws rds delete-db-instance ^ --db-instance-identifier mydbinstance ^ --skip-final-snapshot ^ --no-delete-automated-backups

To delete a DB instance by using the Amazon RDS API, call the DeleteDBInstance operation with the following parameters:

  • DBInstanceIdentifier

  • FinalDBSnapshotIdentifier or SkipFinalSnapshot

Example With a final snapshot and no retained automated backups

https://rds.amazonaws.com/ ?Action=DeleteDBInstance &DBInstanceIdentifier=mydbinstance &FinalDBSnapshotIdentifier=mydbinstancefinalsnapshot &DeleteAutomatedBackups=true &SignatureMethod=HmacSHA256 &SignatureVersion=4 &Version=2014-10-31 &X-Amz-Algorithm=AWS4-HMAC-SHA256 &X-Amz-Credential=AKIADQKE4SARGYLE/20140305/us-west-1/rds/aws4_request &X-Amz-Date=20140305T185838Z &X-Amz-SignedHeaders=content-type;host;user-agent;x-amz-content-sha256;x-amz-date &X-Amz-Signature=b441901545441d3c7a48f63b5b1522c5b2b37c137500c93c45e209d4b3a064a3

Example With retained automated backups and no final snapshot

https://rds.amazonaws.com/ ?Action=DeleteDBInstance &DBInstanceIdentifier=mydbinstance &SkipFinalSnapshot=true &DeleteAutomatedBackups=false &SignatureMethod=HmacSHA256 &SignatureVersion=4 &Version=2014-10-31 &X-Amz-Algorithm=AWS4-HMAC-SHA256 &X-Amz-Credential=AKIADQKE4SARGYLE/20140305/us-west-1/rds/aws4_request &X-Amz-Date=20140305T185838Z &X-Amz-SignedHeaders=content-type;host;user-agent;x-amz-content-sha256;x-amz-date &X-Amz-Signature=b441901545441d3c7a48f63b5b1522c5b2b37c137500c93c45e209d4b3a064a3