Launch instances into an existing
Capacity Reservation
You can only launch an instance into a Capacity Reservation that:
-
Has matching attributes (instance type, platform, Availability Zone, and
tenancy)
-
Has sufficient available capacity
-
Is in the active
state
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.
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.
- Console
-
To launch instances into an existing Capacity Reservation using the console
-
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.
-
Expand Advanced details and do the following:
-
For Placement group, select the cluster placement
group in which to launch the instance.
-
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.
-
Specify Capacity Reservation – 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.
-
Specify Capacity Reservation resource 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.
-
Specify Capacity Reservation only – Launches the instances
into a Capacity Reservation. If a Capacity Reservation ID isn't specified, the instances launch into an open Capacity Reservation. If capacity isn't available,
the instances fail to launch.
-
Specify Capacity Reservation resource group only – Launches the instances into a Capacity Reservation in a Capacity Reservation resource group.
If a Capacity Reservation resource group ARN isn't specified, the instances launch into an open Capacity Reservation.
If capacity isn't available, the instances fail to launch.
-
In the Summary panel, review your instance configuration,
and then choose Launch instance. For more information, see
Launch an EC2 instance using the launch
instance wizard in the console.
- AWS CLI
-
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
}
The following example launches a t2.micro
instance into a Capacity Reservation only. Because a Capacity Reservation ID isn't specified, the instance will launch in 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=capacity-reservations-only
The following example launches a t2.micro
instance into a specific Capacity Reservation only. If capacity isn't available in the specified Capacity Reservation, the instance will fail to launch.
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=capacity-reservations-only
CapacityReservationTarget={CapacityReservationId=cr-a1234567
}