Skip to content

stop_db_instance

stop_db_instance(
    *,
    config_overrides: Optional[RDSClientConfig] = None,
    db_instance_identifier: Optional[String] = None,
    db_snapshot_identifier: Optional[String] = None,
) -> StopDBInstanceResult

Stops an Amazon RDS DB instance temporarily. When you stop a DB instance, Amazon RDS retains the DB instance's metadata, including its endpoint, DB parameter group, and option group membership. Amazon RDS also retains the transaction logs so you can do a point-in-time restore if necessary. The instance restarts automatically after 7 days.

For more information, see Stopping an Amazon RDS DB Instance Temporarily in the Amazon RDS User Guide.

This command doesn't apply to RDS Custom, Aurora MySQL, and Aurora PostgreSQL. For Aurora clusters, use StopDBCluster instead.

Parameters:

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

    The user-supplied instance identifier.

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

    The user-supplied instance identifier of the DB Snapshot created immediately before the DB instance is stopped.

Raises:

Examples:

To stop a DB instance The following example stops the specified DB instance.

>>> client.stop_db_instance(db_instance_identifier='test-instance')
Source code in docs_src/capo_rds/_services/rds.py
def stop_db_instance(
    self,
    *,
    config_overrides: Optional[RDSClientConfig] = None,
    db_instance_identifier: Optional["capo_rds.types.string.String"] = None,
    db_snapshot_identifier: Optional["capo_rds.types.string.String"] = None,
) -> "capo_rds.types.stop_db_instance_result.StopDBInstanceResult":
    """<p>Stops an Amazon RDS DB instance temporarily. When you stop a DB instance, Amazon RDS retains the DB instance's metadata, including its endpoint, DB parameter group, and option group membership. Amazon RDS also retains the transaction logs so you can do a point-in-time restore if necessary. The instance restarts automatically after 7 days.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_StopInstance.html"> Stopping an Amazon RDS DB Instance Temporarily</a> in the <i>Amazon RDS User Guide.</i> </p> <note> <p>This command doesn't apply to RDS Custom, Aurora MySQL, and Aurora PostgreSQL. For Aurora clusters, use <code>StopDBCluster</code> instead.</p> </note>

    Args:
        db_instance_identifier: <p>The user-supplied instance identifier.</p>
        db_snapshot_identifier: <p>The user-supplied instance identifier of the DB Snapshot created immediately before the DB instance is stopped.</p>

    Raises:
        capo_rds.errors.db_instance_not_found_fault.DBInstanceNotFoundFault: <p> <code>DBInstanceIdentifier</code> doesn't refer to an existing DB instance.</p>
        capo_rds.errors.db_snapshot_already_exists_fault.DBSnapshotAlreadyExistsFault: <p> <code>DBSnapshotIdentifier</code> is already used by an existing snapshot.</p>
        capo_rds.errors.invalid_db_cluster_state_fault.InvalidDBClusterStateFault: <p>The requested operation can't be performed while the cluster is in this state.</p>
        capo_rds.errors.invalid_db_instance_state_fault.InvalidDBInstanceStateFault: <p>The DB instance isn't in a valid state.</p>
        capo_rds.errors.snapshot_quota_exceeded_fault.SnapshotQuotaExceededFault: <p>The request would result in the user exceeding the allowed number of DB snapshots.</p>
        capo_rds.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To stop a DB instance
        The following example stops the specified DB instance.

        >>> client.stop_db_instance(db_instance_identifier='test-instance')
    """

    def _handler(
        req: "OperationRequest[capo_rds.types.stop_db_instance_message.StopDBInstanceMessage]",
    ) -> OperationResponse[
        "capo_rds.types.stop_db_instance_result.StopDBInstanceResult"
    ]:
        import capo_rds._operations.amazon_rd_sv19.stop_db_instance

        output, http_response = (
            capo_rds._operations.amazon_rd_sv19.stop_db_instance.stop_db_instance(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_output(
        output: "capo_rds.types.stop_db_instance_result.StopDBInstanceResult",
    ) -> dict[str, Any]:
        import capo_rds.types.stop_db_instance_result

        return capo_rds.types.stop_db_instance_result.redact_sensitive(output)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("StopDBInstance", redact_output=_redact_output),
    )
    input_: capo_rds.types.stop_db_instance_message.StopDBInstanceMessage = {}
    if db_instance_identifier is not None:
        input_["db_instance_identifier"] = db_instance_identifier
    if db_snapshot_identifier is not None:
        input_["db_snapshot_identifier"] = db_snapshot_identifier

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