Modify an EC2 Fleet
You can modify the total target capacity, Spot capacity, and On-Demand capacity of an EC2 Fleet. You can also modify whether running instances should be terminated if the new total target capacity is reduced below the current size of the fleet.
Considerations
Consider the following when modifying an EC2 Fleet:
-
Fleet type – You can only modify an EC2 Fleet of type
maintain
. You can't modify an EC2 Fleet of typerequest
orinstant
. -
Fleet parameters – You can modify the following parameters of an EC2 Fleet:
-
target-capacity-specification
– Increase or decrease the target capacity for:-
TotalTargetCapacity
-
OnDemandTargetCapacity
-
SpotTargetCapacity
-
-
excess-capacity-termination-policy
– Whether running instances should be terminated if the total target capacity of the EC2 Fleet is decreased below the current size of the fleet. Valid values are:-
no-termination
-
termination
-
-
-
Fleet behavior when increasing total target capacity – When you increase the total target capacity, the EC2 Fleet launches the additional instances according to the instance purchasing option specified for
DefaultTargetCapacityType
, which is either On-Demand Instances or Spot Instances, and according to the specified allocation strategy. -
Fleet behavior when decreasing Spot target capacity – When you decrease the Spot target capacity, the EC2 Fleet deletes any open requests that exceed the new target capacity. You can request that the fleet terminate Spot Instances until the size of the fleet reaches the new target capacity. If the allocation strategy is
lowest-price
, the fleet terminates the instances with the highest price per unit. If the allocation strategy isdiversified
, the fleet terminates instances across the pools. Alternatively, you can request that EC2 Fleet keep the fleet at its current size, but not replace any Spot Instances that are interrupted or any instances that you terminate manually.When an EC2 Fleet terminates a Spot Instance because the target capacity was decreased, the instance receives a Spot Instance interruption notice.
-
Fleet state – You can modify an EC2 Fleet that is in the
submitted
oractive
state. When you modify a fleet, it enters themodifying
state.
Commands for modifying an EC2 Fleet
You can use the modify-fleet AWS CLI command to modify an EC2 Fleet.
To modify the total target capacity of an EC2 Fleet
Use the modify-fleet command to update the target capacity of the specified EC2 Fleet.
aws ec2 modify-fleet \ --fleet-id
fleet-73fbd2ce-aa30-494c-8788-1cee4EXAMPLE
\ --target-capacity-specification TotalTargetCapacity=20
To specify that excess running instances mustn't be deleted when decreasing the total target capacity of an EC2 Fleet
If you are decreasing the target capacity but want to keep the fleet at its current size, you can modify the previous command as follows.
aws ec2 modify-fleet \ --fleet-id
fleet-73fbd2ce-aa30-494c-8788-1cee4EXAMPLE
\ --target-capacity-specification TotalTargetCapacity=10
\ --excess-capacity-termination-policy no-termination