Skip to content

stop_db_instance async

stop_db_instance(
    *,
    config_overrides: Optional[AsyncRDSClientConfig] = None,
    db_instance_identifier: Optional[String] = None,
    db_snapshot_identifier: Optional[String] = None,
    detach_from_db_capacity_reservation: Optional[BooleanOptional] = 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.

  • detach_from_db_capacity_reservation (Optional[BooleanOptional], default: None ) –

    Specifies whether the DB instance stops using its DB capacity reservation when the DB instance stops. When you specify true, the DB instance belongs to no reservation after it stops, and a later start launches it outside the reservation.

    By default, a stopped DB instance keeps its DB capacity reservation, and a later start returns the DB instance to the same reservation.

    Every stop releases the unit of reserved capacity that the DB instance holds, for either value of this parameter. Another DB instance can then use that capacity. This parameter controls the reservation that the DB instance belongs to, and it does not control the release of the capacity.

    If the DB instance uses no DB capacity reservation, this parameter has no effect.

    Amazon RDS holds no capacity for a stopped DB instance. When the reservation has no available capacity in the Availability Zone of the DB instance, a later start waits for capacity in that Availability Zone. When the DB instance belongs to no reservation, a later start can fail because the Amazon Web Services Region has insufficient capacity for the DB instance class.

Raises:

Examples:

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

>>> await client.stop_db_instance(db_instance_identifier='test-instance')
Source code in docs_src/capo_rds/_services/async_rds.py
async def stop_db_instance(
    self,
    *,
    config_overrides: Optional[AsyncRDSClientConfig] = None,
    db_instance_identifier: Optional["capo_rds.types.string.String"] = None,
    db_snapshot_identifier: Optional["capo_rds.types.string.String"] = None,
    detach_from_db_capacity_reservation: Optional[
        "capo_rds.types.boolean_optional.BooleanOptional"
    ] = 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>
        detach_from_db_capacity_reservation: <p>Specifies whether the DB instance stops using its DB capacity reservation when the DB instance stops. When you specify <code>true</code>, the DB instance belongs to no reservation after it stops, and a later start launches it outside the reservation.</p> <p>By default, a stopped DB instance keeps its DB capacity reservation, and a later start returns the DB instance to the same reservation.</p> <p>Every stop releases the unit of reserved capacity that the DB instance holds, for either value of this parameter. Another DB instance can then use that capacity. This parameter controls the reservation that the DB instance belongs to, and it does not control the release of the capacity.</p> <p>If the DB instance uses no DB capacity reservation, this parameter has no effect.</p> <important> <p>Amazon RDS holds no capacity for a stopped DB instance. When the reservation has no available capacity in the Availability Zone of the DB instance, a later start waits for capacity in that Availability Zone. When the DB instance belongs to no reservation, a later start can fail because the Amazon Web Services Region has insufficient capacity for the DB instance class.</p> </important>

    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_capacity_reservation_state_fault.InvalidDBCapacityReservationStateFault: <p>The DB capacity reservation isn't in a valid state.</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.

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

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

        (
            output,
            http_response,
        ) = await capo_rds._operations.amazon_rd_sv19.stop_db_instance.async_stop_db_instance(
            req.options, req.input
        )
        return AsyncOperationResponse(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
    if detach_from_db_capacity_reservation is not None:
        input_["detach_from_db_capacity_reservation"] = (
            detach_from_db_capacity_reservation
        )

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output