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
5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 | |