deleteDBInstance method
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. However, manual DB snapshots of the DB instance aren't deleted.
If you request a final DB snapshot, the status of the Amazon RDS DB
instance is deleting until the DB snapshot is created. This
operation can't be canceled or reverted after it begins. To monitor the
status of this operation, use DescribeDBInstance.
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 you skip
creation of the final snapshot with the SkipFinalSnapshot
parameter.
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.
PromoteReadReplicaDBCluster operation to promote the DB
cluster so that it's no longer a read replica. After the promotion
completes, use the DeleteDBInstance operation to delete the
final instance in the DB cluster.
May throw DBInstanceAutomatedBackupQuotaExceededFault.
May throw DBInstanceNotFoundFault.
May throw DBSnapshotAlreadyExistsFault.
May throw InvalidDBClusterStateFault.
May throw InvalidDBInstanceStateFault.
May throw KMSKeyNotAccessibleFault.
May throw SnapshotQuotaExceededFault.
Parameter 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.
Parameter deleteAutomatedBackups :
Specifies whether to remove automated backups immediately after the DB
instance is deleted. This parameter isn't case-sensitive. The default is
to remove automated backups immediately after the DB instance is deleted.
Parameter finalDBSnapshotIdentifier :
The DBSnapshotIdentifier of the new DBSnapshot
created when the SkipFinalSnapshot parameter is disabled.
This setting doesn't apply to RDS Custom.
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.
Parameter skipFinalSnapshot :
Specifies whether to skip the creation of a final DB snapshot before
deleting the instance. If you enable this parameter, RDS doesn't create a
DB snapshot. If you don't enable this parameter, RDS creates a DB snapshot
before the DB instance is deleted. By default, skip isn't enabled, and the
DB snapshot is created.
When a DB instance is in a failure state and has a status of
failed, incompatible-restore, or
incompatible-network, RDS can delete the instance only if you
enable this parameter.
If you delete a read replica or an RDS Custom instance, you must enable this setting.
This setting is required for RDS Custom.
Implementation
Future<DeleteDBInstanceResult> deleteDBInstance({
required String dBInstanceIdentifier,
bool? deleteAutomatedBackups,
String? finalDBSnapshotIdentifier,
bool? skipFinalSnapshot,
}) async {
final $request = <String, String>{
'DBInstanceIdentifier': dBInstanceIdentifier,
if (deleteAutomatedBackups != null)
'DeleteAutomatedBackups': deleteAutomatedBackups.toString(),
if (finalDBSnapshotIdentifier != null)
'FinalDBSnapshotIdentifier': finalDBSnapshotIdentifier,
if (skipFinalSnapshot != null)
'SkipFinalSnapshot': skipFinalSnapshot.toString(),
};
final $result = await _protocol.send(
$request,
action: 'DeleteDBInstance',
version: '2014-10-31',
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
resultWrapper: 'DeleteDBInstanceResult',
);
return DeleteDBInstanceResult.fromXml($result);
}