terminate_instance_in_auto_scaling_group
async
¶
terminate_instance_in_auto_scaling_group(
*,
config_overrides: Optional[AsyncAutoScalingClientConfig] = 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.
>>> await 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.
>>> await 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/async_auto_scaling.py
5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 | |