Configure your Auto Scaling group to launch instances with Capacity Reservations - Amazon EC2 Auto Scaling
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
To configure a Capacity Reservation specification on a new group (console)
  1. Follow the steps in Create an Auto Scaling group using the Amazon EC2 launch wizard, up to step 2.

  2. On the Choose instance launch options page, under Additional capacity settings, choose a Capacity Reservation preference. Optionally, choose a Capacity Reservation target. For more information, see Capacity Reservation preference and Capacity Reservation target.

  3. Continue with the remaining steps of the wizard.

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)
  1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/, and choose Auto Scaling Groups from the navigation pane.

  2. From the navigation bar at the top, choose the AWS Region where your Auto Scaling group is located.

  3. Select the check box next to your Auto Scaling group. A split pane opens at the bottom of the page.

  4. On the Details tab, under Capacity Reservation preference, choose Edit.

  5. Choose a Capacity Reservation preference and, optionally, a Capacity Reservation target.

  6. 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"] } }'