Use CancelCapacityReservation with a CLI - Amazon Elastic Compute Cloud
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Use CancelCapacityReservation with a CLI

The following code examples show how to use CancelCapacityReservation.

CLI
Amazon 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

For a complete list of Amazon SDK developer guides and code examples, see Create Amazon EC2 resources using an Amazon SDK. This topic also includes information about getting started and details about previous SDK versions.