Skip to content

delete_db_instance

delete_db_instance(
    *,
    config_overrides: Optional[NeptuneClientConfig] = None,
    db_instance_identifier: Optional[String] = None,
    skip_final_snapshot: Optional[Boolean] = None,
    final_db_snapshot_identifier: Optional[String] = None,
) -> DeleteDBInstanceResult

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 Neptune 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.

You can't delete a DB instance if it is the only instance in the DB cluster, or if it has deletion protection enabled.

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 ) –

    Determines whether a final DB snapshot is created before the DB instance is deleted. If true is specified, no DBSnapshot is created. If false is specified, a DB snapshot is created before the DB instance is deleted.

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

    Specify true when deleting a Read Replica.

    The FinalDBSnapshotIdentifier parameter must be specified if SkipFinalSnapshot is false.

    Default: false

  • final_db_snapshot_identifier (Optional[String], default: None ) –

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

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

    Constraints:

    • Must be 1 to 255 letters or numbers.

    • First character must be a letter

    • Cannot end with a hyphen or contain two consecutive hyphens

    • Cannot be specified when deleting a Read Replica.

Raises:

Source code in docs_src/capo_neptune/_services/neptune.py
def delete_db_instance(
    self,
    *,
    config_overrides: Optional[NeptuneClientConfig] = None,
    db_instance_identifier: Optional["capo_neptune.types.string.String"] = None,
    skip_final_snapshot: Optional["capo_neptune.types.boolean.Boolean"] = None,
    final_db_snapshot_identifier: Optional[
        "capo_neptune.types.string.String"
    ] = None,
) -> "capo_neptune.types.delete_db_instance_result.DeleteDBInstanceResult":
    """<p>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 <code>DeleteDBInstance</code> are not deleted.</p> <p> If you request a final DB snapshot the status of the Amazon Neptune DB instance is <code>deleting</code> until the DB snapshot is created. The API action <code>DescribeDBInstance</code> is used to monitor the status of this operation. The action can't be canceled or reverted once submitted.</p> <p>Note that when a DB instance is in a failure state and has a status of <code>failed</code>, <code>incompatible-restore</code>, or <code>incompatible-network</code>, you can only delete it when the <code>SkipFinalSnapshot</code> parameter is set to <code>true</code>.</p> <p>You can't delete a DB instance if it is the only instance in the DB cluster, or if it has deletion protection enabled.</p>

    Args:
        db_instance_identifier: <p>The DB instance identifier for the DB instance to be deleted. This parameter isn't case-sensitive.</p> <p>Constraints:</p> <ul> <li> <p>Must match the name of an existing DB instance.</p> </li> </ul>
        skip_final_snapshot: <p> Determines whether a final DB snapshot is created before the DB instance is deleted. If <code>true</code> is specified, no DBSnapshot is created. If <code>false</code> is specified, a DB snapshot is created before the DB instance is deleted.</p> <p>Note that when a DB instance is in a failure state and has a status of 'failed', 'incompatible-restore', or 'incompatible-network', it can only be deleted when the SkipFinalSnapshot parameter is set to "true".</p> <p>Specify <code>true</code> when deleting a Read Replica.</p> <note> <p>The FinalDBSnapshotIdentifier parameter must be specified if SkipFinalSnapshot is <code>false</code>.</p> </note> <p>Default: <code>false</code> </p>
        final_db_snapshot_identifier: <p> The DBSnapshotIdentifier of the new DBSnapshot created when SkipFinalSnapshot is set to <code>false</code>.</p> <note> <p>Specifying this parameter and also setting the SkipFinalSnapshot parameter to true results in an error.</p> </note> <p>Constraints:</p> <ul> <li> <p>Must be 1 to 255 letters or numbers.</p> </li> <li> <p>First character must be a letter</p> </li> <li> <p>Cannot end with a hyphen or contain two consecutive hyphens</p> </li> <li> <p>Cannot be specified when deleting a Read Replica.</p> </li> </ul>

    Raises:
        capo_neptune.errors.db_instance_not_found_fault.DBInstanceNotFoundFault: <p> <i>DBInstanceIdentifier</i> does not refer to an existing DB instance.</p>
        capo_neptune.errors.db_snapshot_already_exists_fault.DBSnapshotAlreadyExistsFault: <p> <i>DBSnapshotIdentifier</i> is already used by an existing snapshot.</p>
        capo_neptune.errors.invalid_db_cluster_state_fault.InvalidDBClusterStateFault: <p>The DB cluster is not in a valid state.</p>
        capo_neptune.errors.invalid_db_instance_state_fault.InvalidDBInstanceStateFault: <p>The specified DB instance is not in the <i>available</i> state.</p>
        capo_neptune.errors.snapshot_quota_exceeded_fault.SnapshotQuotaExceededFault: <p>Request would result in user exceeding the allowed number of DB snapshots.</p>
        capo_neptune.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_neptune.types.delete_db_instance_message.DeleteDBInstanceMessage]",
    ) -> OperationResponse[
        "capo_neptune.types.delete_db_instance_result.DeleteDBInstanceResult"
    ]:
        import capo_neptune._operations.amazon_rd_sv19.delete_db_instance

        output, http_response = (
            capo_neptune._operations.amazon_rd_sv19.delete_db_instance.delete_db_instance(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("DeleteDBInstance")
    )
    input_: capo_neptune.types.delete_db_instance_message.DeleteDBInstanceMessage = {}
    if db_instance_identifier is not None:
        input_["db_instance_identifier"] = db_instance_identifier
    if skip_final_snapshot is not None:
        input_["skip_final_snapshot"] = skip_final_snapshot
    if final_db_snapshot_identifier is not None:
        input_["final_db_snapshot_identifier"] = final_db_snapshot_identifier

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output