Creates or updates a warm pool for the specified Auto Scaling group. A warm pool is a pool of pre-initialized EC2 instances that sits alongside the Auto Scaling group. Whenever your application needs to scale out, the Auto Scaling group can draw on the warm pool to meet its new desired capacity.
This operation must be called from the Region in which the Auto Scaling group was created.
You can view the instances in the warm pool using the DescribeWarmPool API call. If you are no longer using a warm pool, you can delete it by calling the DeleteWarmPool API.
For more information, see Warm pools for Amazon EC2 Auto Scaling in the Amazon EC2 Auto Scaling User Guide.
Parameters:
-
auto_scaling_group_name
(Optional[XmlStringMaxLen255], default:
None
)
–
The name of the Auto Scaling group.
-
max_group_prepared_capacity
(Optional[MaxGroupPreparedCapacity], default:
None
)
–
Specifies the maximum number of instances that are allowed to be in the warm pool or in any state except Terminated for the Auto Scaling group. This is an optional property. Specify it only if you do not want the warm pool size to be determined by the difference between the group's maximum capacity and its desired capacity.
If a value for MaxGroupPreparedCapacity is not specified, Amazon EC2 Auto Scaling launches and maintains the difference between the group's maximum capacity and its desired capacity. If you specify a value for MaxGroupPreparedCapacity, Amazon EC2 Auto Scaling uses the difference between the MaxGroupPreparedCapacity and the desired capacity instead.
The size of the warm pool is dynamic. Only when MaxGroupPreparedCapacity and MinSize are set to the same value does the warm pool have an absolute size.
If the desired capacity of the Auto Scaling group is higher than the MaxGroupPreparedCapacity, the capacity of the warm pool is 0, unless you specify a value for MinSize. To remove a value that you previously set, include the property but specify -1 for the value.
-
min_size
(Optional[WarmPoolMinSize], default:
None
)
–
Specifies the minimum number of instances to maintain in the warm pool. This helps you to ensure that there is always a certain number of warmed instances available to handle traffic spikes. Defaults to 0 if not specified.
-
pool_state
(Optional[WarmPoolState], default:
None
)
–
Sets the instance state to transition to after the lifecycle actions are complete. Default is Stopped.
-
instance_reuse_policy
(Optional[InstanceReusePolicy], default:
None
)
–
Indicates whether instances in the Auto Scaling group can be returned to the warm pool on scale in. The default is to terminate instances in the Auto Scaling group when the group scales in.
Raises:
-
InstanceRefreshInProgressFault
–
The request failed because an active instance refresh already exists for the specified Auto Scaling group.
-
LimitExceededFault
–
You have already reached a limit for your Amazon EC2 Auto Scaling resources (for example, Auto Scaling groups, launch configurations, or lifecycle hooks). For more information, see DescribeAccountLimits in the Amazon EC2 Auto Scaling API Reference.
-
ResourceContentionFault
–
You already have a pending update to an Amazon EC2 Auto Scaling resource (for example, an Auto Scaling group, instance, or load balancer).
-
UnknownServiceError
–
The service returned an error code this client does not model.
Examples:
To create a warm pool for an Auto Scaling group
This example creates a warm pool for the specified Auto Scaling group.
>>> await client.put_warm_pool(auto_scaling_group_name='my-auto-scaling-group', min_size=30, pool_state='Hibernated', instance_reuse_policy={'ReuseOnScaleIn': True})
Source code in docs_src/capo_auto_scaling/_services/async_auto_scaling.py
| async def put_warm_pool(
self,
*,
config_overrides: Optional[AsyncAutoScalingClientConfig] = None,
auto_scaling_group_name: Optional[
"capo_auto_scaling.types.xml_string_max_len255.XmlStringMaxLen255"
] = None,
max_group_prepared_capacity: Optional[
"capo_auto_scaling.types.max_group_prepared_capacity.MaxGroupPreparedCapacity"
] = None,
min_size: Optional[
"capo_auto_scaling.types.warm_pool_min_size.WarmPoolMinSize"
] = None,
pool_state: Optional[
"capo_auto_scaling.types.warm_pool_state.WarmPoolState"
] = None,
instance_reuse_policy: Optional[
"capo_auto_scaling.types.instance_reuse_policy.InstanceReusePolicy"
] = None,
) -> "capo_auto_scaling.types.put_warm_pool_answer.PutWarmPoolAnswer":
"""<p>Creates or updates a warm pool for the specified Auto Scaling group. A warm pool is a pool of pre-initialized EC2 instances that sits alongside the Auto Scaling group. Whenever your application needs to scale out, the Auto Scaling group can draw on the warm pool to meet its new desired capacity.</p> <p>This operation must be called from the Region in which the Auto Scaling group was created.</p> <p>You can view the instances in the warm pool using the <a href="https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_DescribeWarmPool.html">DescribeWarmPool</a> API call. If you are no longer using a warm pool, you can delete it by calling the <a href="https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_DeleteWarmPool.html">DeleteWarmPool</a> API.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/autoscaling/ec2/userguide/ec2-auto-scaling-warm-pools.html">Warm pools for Amazon EC2 Auto Scaling</a> in the <i>Amazon EC2 Auto Scaling User Guide</i>.</p>
Args:
auto_scaling_group_name: <p>The name of the Auto Scaling group.</p>
max_group_prepared_capacity: <p>Specifies the maximum number of instances that are allowed to be in the warm pool or in any state except <code>Terminated</code> for the Auto Scaling group. This is an optional property. Specify it only if you do not want the warm pool size to be determined by the difference between the group's maximum capacity and its desired capacity. </p> <important> <p>If a value for <code>MaxGroupPreparedCapacity</code> is not specified, Amazon EC2 Auto Scaling launches and maintains the difference between the group's maximum capacity and its desired capacity. If you specify a value for <code>MaxGroupPreparedCapacity</code>, Amazon EC2 Auto Scaling uses the difference between the <code>MaxGroupPreparedCapacity</code> and the desired capacity instead. </p> <p>The size of the warm pool is dynamic. Only when <code>MaxGroupPreparedCapacity</code> and <code>MinSize</code> are set to the same value does the warm pool have an absolute size.</p> </important> <p>If the desired capacity of the Auto Scaling group is higher than the <code>MaxGroupPreparedCapacity</code>, the capacity of the warm pool is 0, unless you specify a value for <code>MinSize</code>. To remove a value that you previously set, include the property but specify -1 for the value. </p>
min_size: <p>Specifies the minimum number of instances to maintain in the warm pool. This helps you to ensure that there is always a certain number of warmed instances available to handle traffic spikes. Defaults to 0 if not specified.</p>
pool_state: <p>Sets the instance state to transition to after the lifecycle actions are complete. Default is <code>Stopped</code>.</p>
instance_reuse_policy: <p>Indicates whether instances in the Auto Scaling group can be returned to the warm pool on scale in. The default is to terminate instances in the Auto Scaling group when the group scales in.</p>
Raises:
capo_auto_scaling.errors.instance_refresh_in_progress_fault.InstanceRefreshInProgressFault: <p>The request failed because an active instance refresh already exists for the specified Auto Scaling group.</p>
capo_auto_scaling.errors.limit_exceeded_fault.LimitExceededFault: <p>You have already reached a limit for your Amazon EC2 Auto Scaling resources (for example, Auto Scaling groups, launch configurations, or lifecycle hooks). For more information, see <a href="https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_DescribeAccountLimits.html">DescribeAccountLimits</a> in the <i>Amazon EC2 Auto Scaling API Reference</i>.</p>
capo_auto_scaling.errors.resource_contention_fault.ResourceContentionFault: <p>You already have a pending update to an Amazon EC2 Auto Scaling resource (for example, an Auto Scaling group, instance, or load balancer).</p>
capo_auto_scaling.errors.UnknownServiceError: The service returned an error code this client does not model.
Examples:
To create a warm pool for an Auto Scaling group
This example creates a warm pool for the specified Auto Scaling group.
>>> await client.put_warm_pool(auto_scaling_group_name='my-auto-scaling-group', min_size=30, pool_state='Hibernated', instance_reuse_policy={'ReuseOnScaleIn': True})
"""
async def _handler(
req: "AsyncOperationRequest[capo_auto_scaling.types.put_warm_pool_type.PutWarmPoolType]",
) -> AsyncOperationResponse[
"capo_auto_scaling.types.put_warm_pool_answer.PutWarmPoolAnswer"
]:
import capo_auto_scaling._operations.auto_scaling_2011_01_01.put_warm_pool
(
output,
http_response,
) = await capo_auto_scaling._operations.auto_scaling_2011_01_01.put_warm_pool.async_put_warm_pool(
req.options, req.input
)
return AsyncOperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("PutWarmPool")
)
input_: capo_auto_scaling.types.put_warm_pool_type.PutWarmPoolType = {}
if auto_scaling_group_name is not None:
input_["auto_scaling_group_name"] = auto_scaling_group_name
if max_group_prepared_capacity is not None:
input_["max_group_prepared_capacity"] = max_group_prepared_capacity
if min_size is not None:
input_["min_size"] = min_size
if pool_state is not None:
input_["pool_state"] = pool_state
if instance_reuse_policy is not None:
input_["instance_reuse_policy"] = instance_reuse_policy
response = await aexecute_pipeline(
AsyncOperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
await response.response.aclose()
return response.output
|