delete_db_instance
async
¶
delete_db_instance(
*,
config_overrides: Optional[AsyncRDSClientConfig] = None,
db_instance_identifier: Optional[String] = None,
skip_final_snapshot: Optional[Boolean] = None,
final_db_snapshot_identifier: Optional[String] = None,
delete_automated_backups: Optional[BooleanOptional] = None,
) -> DeleteDBInstanceResult
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.
To delete a DB instance in this case, first use the 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.
For RDS Custom DB instances, deleting the DB instance permanently deletes the EC2 instance and the associated EBS volumes. Make sure that you don't terminate or delete these resources before you delete the DB instance. Otherwise, deleting the DB instance and creation of the final snapshot might fail.
Parameters:
-
db_instance_identifier(Optional[String], default:None) –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.
-
-
skip_final_snapshot(Optional[Boolean], default:None) –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.
If you don't enable this parameter, you must specify the
FinalDBSnapshotIdentifierparameter.When a DB instance is in a failure state and has a status of
failed,incompatible-restore, orincompatible-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.
-
final_db_snapshot_identifier(Optional[String], default:None) –The
DBSnapshotIdentifierof the newDBSnapshotcreated when theSkipFinalSnapshotparameter is disabled.If you enable this parameter and also enable SkipFinalShapshot, the command results in an error.
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.
-
-
delete_automated_backups(Optional[BooleanOptional], default:None) –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.
Raises:
-
DBInstanceAutomatedBackupQuotaExceededFault–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.
-
DBInstanceNotFoundFault–DBInstanceIdentifierdoesn't refer to an existing DB instance. -
DBSnapshotAlreadyExistsFault–DBSnapshotIdentifieris already used by an existing snapshot. -
InvalidDBClusterStateFault–The requested operation can't be performed while the cluster is in this state.
-
InvalidDBInstanceStateFault–The DB instance isn't in a valid state.
-
KMSKeyNotAccessibleFault–An error occurred accessing an Amazon Web Services KMS key.
-
SnapshotQuotaExceededFault–The request would result in the user exceeding the allowed number of DB snapshots.
-
UnknownServiceError–The service returned an error code this client does not model.
Examples:
To delete a DB instance The following example deletes the specified DB instance after creating a final DB snapshot named test-instance-final-snap.
>>> await client.delete_db_instance(db_instance_identifier='test-instance', skip_final_snapshot=False, final_db_snapshot_identifier='test-instance-final-snap')
Source code in docs_src/capo_rds/_services/async_rds.py
4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 | |