Use CancelCapacityReservation with an AWS SDK or CLI - Amazon Elastic Compute Cloud

Use CancelCapacityReservation with an AWS SDK or 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

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