terminate_instance_in_auto_scaling_group
¶
terminate_instance_in_auto_scaling_group(
*,
config_overrides: Optional[AutoScalingClientConfig] = None,
instance_id: Optional[XmlStringMaxLen19] = None,
instance_ids: Optional[TerminationInstanceIds] = None,
auto_scaling_group_name: Optional[XmlStringMaxLen255] = None,
should_decrement_desired_capacity: Optional[ShouldDecrementDesiredCapacity] = None,
) -> ActivityType
Terminates the specified instance and optionally adjusts the desired group size. This operation cannot be called on instances in a warm pool.
This call simply makes a termination request. The instances are not terminated immediately. When an instance is terminated, the instance status changes to terminated. You can't connect to or start an instance after you've terminated it.
If you do not specify the option to decrement the desired capacity, Amazon EC2 Auto Scaling launches instances to replace the ones that are terminated.
To terminate multiple instances in a single call, use the InstanceIds and AutoScalingGroupName parameters instead of InstanceId. When terminating multiple instances, the response populates Activities instead of Activity.
By default, Amazon EC2 Auto Scaling balances instances across all Availability Zones. If you decrement the desired capacity, your Auto Scaling group can become unbalanced between Availability Zones. Amazon EC2 Auto Scaling tries to rebalance the group, and rebalancing might terminate instances in other zones. For more information, see Manual scaling in the Amazon EC2 Auto Scaling User Guide.
Parameters:
-
instance_id(Optional[XmlStringMaxLen19], default:None) –The ID of the instance.
-
instance_ids(Optional[TerminationInstanceIds], default:None) –The IDs of the instances. You can specify up to 100 instances.
This parameter requires that you also specify
AutoScalingGroupName. -
auto_scaling_group_name(Optional[XmlStringMaxLen255], default:None) –The name of the Auto Scaling group. Required when using
InstanceIds. -
should_decrement_desired_capacity(Optional[ShouldDecrementDesiredCapacity], default:None) –Indicates whether terminating the instance also decrements the size of the Auto Scaling group.
Raises:
-
ResourceContentionFault–You already have a pending update to an Amazon EC2 Auto Scaling resource (for example, an Auto Scaling group, instance, or load balancer).
-
ScalingActivityInProgressFault–The operation can't be performed because there are scaling activities in progress.
-
UnknownServiceError–The service returned an error code this client does not model.
Examples:
To terminate an instance in an Auto Scaling group This example terminates the specified instance from the specified Auto Scaling group without updating the size of the group. Auto Scaling launches a replacement instance after the specified instance terminates.
>>> client.terminate_instance_in_auto_scaling_group(instance_id='i-93633f9b', should_decrement_desired_capacity=False)
To terminate multiple instances in an Auto Scaling group
This example terminates multiple instances from the specified Auto Scaling group without updating the size of the group. Auto Scaling launches replacement instances after the specified instances terminate.
>>> client.terminate_instance_in_auto_scaling_group(instance_ids=['i-93633f9b', 'i-ab4d5e6f7'], auto_scaling_group_name='my-asg', should_decrement_desired_capacity=False)
Source code in docs_src/capo_auto_scaling/_services/auto_scaling.py
5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 | |