Amazon Relational Database Service
API Reference (API Version 2014-10-31)

DeleteDBInstance

The DeleteDBInstance action deletes a previously provisioned DB instance. When you delete a DB instance, all automated backups for that instance are deleted and can't be recovered. Manual DB snapshots of the DB instance to be deleted by DeleteDBInstance are not deleted.

If you request a final DB snapshot the status of the Amazon RDS DB instance is deleting until the DB snapshot is created. The API action DescribeDBInstance is used to monitor the status of this operation. The action can't be canceled or reverted once submitted.

Note that when a DB instance is in a failure state and has a status of failed, incompatible-restore, or incompatible-network, you can only delete it when the SkipFinalSnapshot parameter is set to true.

If the specified DB instance is part of an Amazon Aurora DB cluster, you can't delete the DB instance if both of the following conditions are true:

  • The DB cluster is a Read Replica of another Amazon Aurora DB cluster.

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

To delete a DB instance in this case, first call the PromoteReadReplicaDBCluster API action to promote the DB cluster so it's no longer a Read Replica. After the promotion completes, then call the DeleteDBInstance API action to delete the final instance in the DB cluster.

Request Parameters

For information about the parameters that are common to all actions, see Common Parameters.

DBInstanceIdentifier

The DB instance identifier for the DB instance to be deleted. This parameter isn't case-sensitive.

Constraints:

  • Must match the name of an existing DB instance.

Type: String

Required: Yes

DeleteAutomatedBackups

A value that indicates whether to remove automated backups immediately after the DB instance is deleted. This parameter isn't case-sensitive. This parameter defaults to true.

Type: Boolean

Required: No

FinalDBSnapshotIdentifier

The DBSnapshotIdentifier of the new DB snapshot created when SkipFinalSnapshot is set to false.

Note

Specifying this parameter and also setting the SkipFinalShapshot parameter to true results in an error.

Constraints:

  • Must be 1 to 255 letters or numbers.

  • First character must be a letter.

  • Can't end with a hyphen or contain two consecutive hyphens.

  • Can't be specified when deleting a Read Replica.

Type: String

Required: No

SkipFinalSnapshot

A value that indicates whether a final DB snapshot is created before the DB instance is deleted. If true is specified, no DB snapshot is created. If false is specified, a DB snapshot is created before the DB instance is deleted.

When a DB instance is in a failure state and has a status of failed, incompatible-restore, or incompatible-network, you can only delete it when the SkipFinalSnapshot parameter is set to true.

Specify true when deleting a Read Replica.

Note

The FinalDBSnapshotIdentifier parameter must be specified if SkipFinalSnapshot is false.

Default: false

Type: Boolean

Required: No

Response Elements

The following element is returned by the service.

DBInstance

Contains the details of an Amazon RDS DB instance.

This data type is used as a response element in the DescribeDBInstances action.

Type: DBInstance object

Errors

For information about the errors that are common to all actions, see Common Errors.

DBInstanceAutomatedBackupQuotaExceeded

The quota for retained automated backups was exceeded. This prevents you from retaining any additional automated backups. The retained automated backups quota is the same as your DB Instance quota.

HTTP Status Code: 400

DBInstanceNotFound

DBInstanceIdentifier doesn't refer to an existing DB instance.

HTTP Status Code: 404

DBSnapshotAlreadyExists

DBSnapshotIdentifier is already used by an existing snapshot.

HTTP Status Code: 400

InvalidDBClusterStateFault

The requested operation can't be performed while the cluster is in this state.

HTTP Status Code: 400

InvalidDBInstanceState

The DB instance isn't in a valid state.

HTTP Status Code: 400

SnapshotQuotaExceeded

The request would result in the user exceeding the allowed number of DB snapshots.

HTTP Status Code: 400

Example

Sample Request

https://rds.us-east-1.amazonaws.com/ ?Action=DeleteDBInstance &DBInstanceIdentifier=mydatabase &SignatureMethod=HmacSHA256 &SignatureVersion=4 &SkipFinalSnapshot=true &Version=2014-09-01 &X-Amz-Algorithm=AWS4-HMAC-SHA256 &X-Amz-Credential=AKIADQKE4SARGYLE/20131109/us-east-1/rds/aws4_request &X-Amz-Date=20131109T001924Z &X-Amz-SignedHeaders=content-type;host;user-agent;x-amz-content-sha256;x-amz-date &X-Amz-Signature=70e774e243c0fbb7ffe84029637005bf543e9e321cdf432c0b272be5687d32d8

Sample Response

<DeleteDBInstanceResponse xmlns="http://rds.amazonaws.com/doc/2014-09-01/"> <DeleteDBInstanceResult> <DBInstance> <BackupRetentionPeriod>7</BackupRetentionPeriod> <DBInstanceStatus>deleting</DBInstanceStatus> <MultiAZ>false</MultiAZ> <VpcSecurityGroups/> <DBInstanceIdentifier>mydatabase</DBInstanceIdentifier> <PreferredBackupWindow>08:14-08:44</PreferredBackupWindow> <PreferredMaintenanceWindow>fri:04:50-fri:05:20</PreferredMaintenanceWindow> <AvailabilityZone>us-east-1a</AvailabilityZone> <ReadReplicaDBInstanceIdentifiers/> <LatestRestorableTime>2013-11-09T00:15:00Z</LatestRestorableTime> <Engine>mysql</Engine> <PendingModifiedValues/> <LicenseModel>general-public-license</LicenseModel> <EngineVersion>5.6.13</EngineVersion> <Endpoint> <Port>3306</Port> <Address>mydatabase.cf037hpkuvjt.us-east-1.rds.amazonaws.com</Address> </Endpoint> <DBParameterGroups> <DBParameterGroup> <ParameterApplyStatus>in-sync</ParameterApplyStatus> <DBParameterGroupName>default.mysql5.6</DBParameterGroupName> </DBParameterGroup> </DBParameterGroups> <OptionGroupMemberships> <OptionGroupMembership> <OptionGroupName>default:mysql-5-6</OptionGroupName> <Status>in-sync</Status> </OptionGroupMembership> </OptionGroupMemberships> <PubliclyAccessible>true</PubliclyAccessible> <DBSecurityGroups> <DBSecurityGroup> <Status>active</Status> <DBSecurityGroupName>default</DBSecurityGroupName> </DBSecurityGroup> </DBSecurityGroups> <DBName>mysqldb</DBName> <AutoMinorVersionUpgrade>true</AutoMinorVersionUpgrade> <InstanceCreateTime>2011-04-28T23:33:54.909Z</InstanceCreateTime> <AllocatedStorage>100</AllocatedStorage> <MasterUsername>myawsuser</MasterUsername> <DBInstanceClass>db.m1.medium</DBInstanceClass> </DBInstance> </DeleteDBInstanceResult> <ResponseMetadata> <RequestId>7369556f-b70d-11c3-faca-6ba18376ea1b</RequestId> </ResponseMetadata> </DeleteDBInstanceResponse>

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: