Launch instances into an existing Capacity Reservation - Amazon Elastic Compute Cloud

Launch instances into an existing Capacity Reservation

When you launch an instance, you can specify whether to launch the instance into any open Capacity Reservation, into a specific Capacity Reservation, or into a group of Capacity Reservations. You can only launch an instance into a Capacity Reservation that has matching attributes (instance type, platform, Availability Zone, and tenancy) and sufficient capacity. Alternatively, you can configure the instance to avoid running in a Capacity Reservation, even if you have an open Capacity Reservation that has matching attributes and available capacity.

Launching an instance into a Capacity Reservation reduces its available capacity by the number of instances launched. For example, if you launch three instances, the available capacity of the Capacity Reservation is reduced by three.

To launch instances into an existing Capacity Reservation using the console
  1. Follow the procedure to launch an instance, but don't launch the instance until you've completed the following steps to specify the settings for the placement group and Capacity Reservation.

  2. Expand Advanced details and do the following:

    1. For Placement group, select the cluster placement group in which to launch the instance.

    2. For Capacity Reservation, choose one of the following options depending on the configuration of the Capacity Reservation:

      • None – Prevents the instances from launching into a Capacity Reservation. The instances run in On-Demand capacity.

      • Open – Launches the instances into any Capacity Reservation that has matching attributes and sufficient capacity for the number of instances you selected. If there is no matching Capacity Reservation with sufficient capacity, the instance uses On-Demand capacity.

      • Target by ID – Launches the instances into the selected Capacity Reservation. If the selected Capacity Reservation does not have sufficient capacity for the number of instances you selected, the instance launch fails.

      • Target by group – Launches the instances into any Capacity Reservation with matching attributes and available capacity in the selected Capacity Reservation group. If the selected group does not have a Capacity Reservation with matching attributes and available capacity, the instances launch into On-Demand capacity.

  3. In the Summary panel, review your instance configuration, and then choose Launch instance. For more information, see Launch an instance using the new launch instance wizard.

To launch an instance into an existing Capacity Reservation using the AWS CLI

Use the run-instances command and specify the --capacity-reservation-specification parameter.

The following example launches a t2.micro instance into any open Capacity Reservation that has matching attributes and available capacity:

aws ec2 run-instances --image-id ami-abc12345 --count 1 --instance-type t2.micro --key-name MyKeyPair --subnet-id subnet-1234567890abcdef1 --capacity-reservation-specification CapacityReservationPreference=open

The following example launches a t2.micro instance into a targeted Capacity Reservation:

aws ec2 run-instances --image-id ami-abc12345 --count 1 --instance-type t2.micro --key-name MyKeyPair --subnet-id subnet-1234567890abcdef1 --capacity-reservation-specification CapacityReservationTarget={CapacityReservationId=cr-a1234567}

The following example launches a t2.micro instance into a Capacity Reservation group:

aws ec2 run-instances --image-id ami-abc12345 --count 1 --instance-type t2.micro --key-name MyKeyPair --subnet-id subnet-1234567890abcdef1 --capacity-reservation-specification CapacityReservationTarget={CapacityReservationResourceGroupArn=arn:aws:resource-groups:us-west-1:123456789012:group/my-cr-group}