Skip to content

EC2  >  Operations  >  cancel_capacity_reservation

cancel_capacity_reservation

Operation

cancel_capacity_reservation async

cancel_capacity_reservation(request: CancelCapacityReservationInput | CancelCapacityReservationInputDict, /, *, plugins: list[Plugin] | None = None) -> CancelCapacityReservationOutput
cancel_capacity_reservation(*, plugins: list[Plugin] | None = None, **kwargs: Unpack[CancelCapacityReservationInputDict]) -> CancelCapacityReservationOutput

Cancels the specified Capacity Reservation, releases the reserved capacity, and changes the Capacity Reservation's state to cancelled.

You can cancel a Capacity Reservation that is in the following states:

  • assessing

  • scheduled --- requires a cancellation quote. Use CreateCapacityReservationCancellationQuote to generate a quote, then pass the quote ID with ApplyCancellationCharges set to commitment-wind-down. The cancellation charge depends on how close the reservation is to its start date.

  • active and there is no commitment duration or the commitment duration has elapsed.

  • active during the commitment duration --- requires a cancellation quote. Use CreateCapacityReservationCancellationQuote to generate a quote, then pass the quote ID with ApplyCancellationCharges set to commitment-wind-down. The Capacity Reservation transitions to cancelling while charges are applied.

  • delayed --- the commitment duration is waived, so no cancellation charge applies.

Note

You can't modify or cancel a Capacity Block. For more information, see Capacity Blocks for ML.

Instances running in the reserved capacity continue running until you stop them. Stopped instances that target the Capacity Reservation can no longer launch. Modify these instances to either target a different Capacity Reservation, launch On-Demand Instance capacity, or run in any open Capacity Reservation that has matching attributes and sufficient capacity.

Parameters:

Name Type Description Default
plugins list[Plugin] | None

A list of callables that modify the configuration dynamically. Changes made by these plugins only apply for the duration of the operation execution and will not affect any other operation invocations.

None

Returns:

Type Description
CancelCapacityReservationOutput

An instance of CancelCapacityReservationOutput.

Input

Pass the input fields as keyword arguments, or pass a model or dictionary as the first positional argument. Pass plugins separately as a keyword argument.

Model

CancelCapacityReservationInput dataclass

Bases: _SerdeShape

Dataclass for CancelCapacityReservationInput structure.

Attributes
apply_cancellation_charges class-attribute instance-attribute
apply_cancellation_charges: str | None = ...

Specifies the cancellation charge type to apply when cancelling a future-dated Capacity Reservation during its commitment duration. Possible values include commitment-wind-down, which continues billing for the remaining commitment duration without delivering capacity.

capacity_reservation_id class-attribute instance-attribute
capacity_reservation_id: str | None = ...

The ID of the Capacity Reservation to be cancelled.

dry_run class-attribute instance-attribute
dry_run: bool | None = ...

Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

quote_id class-attribute instance-attribute
quote_id: str | None = ...

The ID of the cancellation quote to use for the cancellation. You can generate a cancellation quote by using the CreateCapacityReservationCancellationQuote action. The cancellation quote must be in an active state.

Dictionaries

CancelCapacityReservationInputDict

Bases: TypedDict

Dictionary form of CancelCapacityReservationInput.

Attributes
apply_cancellation_charges instance-attribute
apply_cancellation_charges: str | None

Specifies the cancellation charge type to apply when cancelling a future-dated Capacity Reservation during its commitment duration. Possible values include commitment-wind-down, which continues billing for the remaining commitment duration without delivering capacity.

capacity_reservation_id instance-attribute
capacity_reservation_id: Required[str]

The ID of the Capacity Reservation to be cancelled.

dry_run instance-attribute
dry_run: bool | None

Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

quote_id instance-attribute
quote_id: str | None

The ID of the cancellation quote to use for the cancellation. You can generate a cancellation quote by using the CreateCapacityReservationCancellationQuote action. The cancellation quote must be in an active state.

Output

CancelCapacityReservationOutput dataclass

Bases: _SerdeShape

Dataclass for CancelCapacityReservationOutput structure.

Attributes

response_metadata class-attribute instance-attribute
response_metadata: ResponseMetadata = ...

Metadata about the response that produced this output. Use this to recover the request identifiers a service's support team needs in order to investigate a call. Members of the metadata are individually optional.

return_ class-attribute instance-attribute
return_: bool | None = ...

Returns true if the request succeeds; otherwise, it returns an error.