Services or capabilities described in AWS documentation might vary by Region. To see the differences applicable to the AWS European Sovereign Cloud Region, see the AWS European Sovereign Cloud User Guide.Configure your Auto Scaling group to launch instances with Capacity Reservations
To configure your Auto Scaling group to launch instances with Amazon EC2 Capacity Reservations, choose
the procedure that matches your approach:
Use a Capacity Reservation specification
Use one of the following methods to configure a Capacity Reservation specification when
you create a new Auto Scaling group.
- Console
-
- AWS CLI
-
Add the --capacity-reservation-specification
parameter to the create-auto-scaling-group command. The parameter
accepts a preference and an optional target. For details, see
Capacity Reservation preference and
Capacity Reservation target.
The following example creates an Auto Scaling group with a preference
of capacity-reservations-only and a specific Capacity Reservation
as the target.
aws autoscaling create-auto-scaling-group \
--auto-scaling-group-name my-asg \
--launch-template LaunchTemplateName=my-launch-template \
--min-size 1 --max-size 10 --desired-capacity 5 \
--vpc-zone-identifier "subnet-abc1234a,subnet-abc1234b" \
--capacity-reservation-specification '{
"CapacityReservationPreference": "capacity-reservations-only",
"CapacityReservationTarget": {
"CapacityReservationIds": ["cr-1234567890abcdef1"]
}
}'
Update an existing Auto Scaling group
To change the Capacity Reservation specification on an existing Auto Scaling group, use one of
the following methods.
- Console
-
To change the Capacity Reservation specification on an existing group (console)
-
Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/, and choose Auto Scaling
Groups from the navigation
pane.
-
From the navigation bar at the top, choose the
AWS Region where your Auto Scaling group is
located.
-
Select the check box next to your Auto Scaling group. A
split pane opens at the bottom of the page.
-
On the Details tab, under
Capacity Reservation preference, choose
Edit.
-
Choose a Capacity Reservation preference and, optionally, a Capacity Reservation
target.
-
Choose Update.
- AWS CLI
-
Add the
--capacity-reservation-specification
parameter to the update-auto-scaling-group command.
The following example updates an Auto Scaling group to use a Capacity Reservation Resource Group
as the target with a preference of
capacity-reservations-first.
aws autoscaling update-auto-scaling-group \
--auto-scaling-group-name my-asg \
--capacity-reservation-specification '{
"CapacityReservationPreference": "capacity-reservations-first",
"CapacityReservationTarget": {
"CapacityReservationResourceGroupArns": ["arn:aws:resource-groups:us-east-1:123456789012:group/my-cr-group"]
}
}'