Use CancelCapacityReservation with a CLI - AWS SDK Code Examples

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

Use CancelCapacityReservation with a CLI

The following code examples show how to use CancelCapacityReservation.

CLI
AWS CLI

To cancel a capacity reservation

The following cancel-capacity-reservation example cancels the specified capacity reservation.

aws ec2 cancel-capacity-reservation \ --capacity-reservation-id cr-1234abcd56EXAMPLE

Output:

{ "Return": true }

For more information, see Canceling a Capacity Reservation in the Amazon Elastic Compute Cloud User Guide for Linux Instances.

PowerShell
Tools for PowerShell

Example 1: This example cancels the capacity reservation cr-0c1f2345db6f7cdba

Remove-EC2CapacityReservation -CapacityReservationId cr-0c1f2345db6f7cdba

Output:

Confirm Are you sure you want to perform this action? Performing the operation "Remove-EC2CapacityReservation (CancelCapacityReservation)" on target "cr-0c1f2345db6f7cdba". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): y True