Skip to content

update_auto_scaling_group async

update_auto_scaling_group(
    *,
    config_overrides: Optional[AsyncAutoScalingClientConfig] = None,
    auto_scaling_group_name: Optional[XmlStringMaxLen255] = None,
    launch_configuration_name: Optional[XmlStringMaxLen255] = None,
    launch_template: Optional[LaunchTemplateSpecification] = None,
    mixed_instances_policy: Optional[MixedInstancesPolicy] = None,
    min_size: Optional[AutoScalingGroupMinSize] = None,
    max_size: Optional[AutoScalingGroupMaxSize] = None,
    desired_capacity: Optional[AutoScalingGroupDesiredCapacity] = None,
    default_cooldown: Optional[Cooldown] = None,
    availability_zones: Optional[AvailabilityZones] = None,
    availability_zone_ids: Optional[AvailabilityZoneIds] = None,
    health_check_type: Optional[XmlStringMaxLen32] = None,
    health_check_grace_period: Optional[HealthCheckGracePeriod] = None,
    placement_group: Optional[UpdatePlacementGroupParam] = None,
    vpc_zone_identifier: Optional[XmlStringMaxLen5000] = None,
    termination_policies: Optional[TerminationPolicies] = None,
    new_instances_protected_from_scale_in: Optional[InstanceProtected] = None,
    service_linked_role_arn: Optional[ResourceName] = None,
    max_instance_lifetime: Optional[MaxInstanceLifetime] = None,
    capacity_rebalance: Optional[CapacityRebalanceEnabled] = None,
    context: Optional[Context] = None,
    desired_capacity_type: Optional[XmlStringMaxLen255] = None,
    default_instance_warmup: Optional[DefaultInstanceWarmup] = None,
    instance_maintenance_policy: Optional[InstanceMaintenancePolicy] = None,
    availability_zone_distribution: Optional[AvailabilityZoneDistribution] = None,
    availability_zone_impairment_policy: Optional[
        AvailabilityZoneImpairmentPolicy
    ] = None,
    skip_zonal_shift_validation: Optional[SkipZonalShiftValidation] = None,
    capacity_reservation_specification: Optional[
        CapacityReservationSpecification
    ] = None,
    instance_lifecycle_policy: Optional[InstanceLifecyclePolicy] = None,
    deletion_protection: Optional[DeletionProtection] = None,
) -> None

We strongly recommend that all Auto Scaling groups use launch templates to ensure full functionality for Amazon EC2 Auto Scaling and Amazon EC2.

Updates the configuration for the specified Auto Scaling group.

To update an Auto Scaling group, specify the name of the group and the property that you want to change. Any properties that you don't specify are not changed by this update request. The new settings take effect on any scaling activities after this call returns.

If you associate a new launch configuration or template with an Auto Scaling group, all new instances will get the updated configuration. Existing instances continue to run with the configuration that they were originally launched with. When you update a group to specify a mixed instances policy instead of a launch configuration or template, existing instances may be replaced to match the new purchasing options that you specified in the policy. For example, if the group currently has 100% On-Demand capacity and the policy specifies 50% Spot capacity, this means that half of your instances will be gradually terminated and relaunched as Spot Instances. When replacing instances, Amazon EC2 Auto Scaling launches new instances before terminating the old ones, so that updating your group does not compromise the performance or availability of your application.

Note the following about changing DesiredCapacity, MaxSize, or MinSize:

  • If a scale-in activity occurs as a result of a new DesiredCapacity value that is lower than the current size of the group, the Auto Scaling group uses its termination policy to determine which instances to terminate.

  • If you specify a new value for MinSize without specifying a value for DesiredCapacity, and the new MinSize is larger than the current size of the group, this sets the group's DesiredCapacity to the new MinSize value.

  • If you specify a new value for MaxSize without specifying a value for DesiredCapacity, and the new MaxSize is smaller than the current size of the group, this sets the group's DesiredCapacity to the new MaxSize value.

To see which properties have been set, call the DescribeAutoScalingGroups API. To view the scaling policies for an Auto Scaling group, call the DescribePolicies API. If the group has scaling policies, you can update them by calling the PutScalingPolicy API.

Parameters:

  • auto_scaling_group_name (Optional[XmlStringMaxLen255], default: None ) –

    The name of the Auto Scaling group.

  • launch_configuration_name (Optional[XmlStringMaxLen255], default: None ) –

    The name of the launch configuration. If you specify LaunchConfigurationName in your update request, you can't specify LaunchTemplate or MixedInstancesPolicy.

  • launch_template (Optional[LaunchTemplateSpecification], default: None ) –

    The launch template and version to use to specify the updates. If you specify LaunchTemplate in your update request, you can't specify LaunchConfigurationName or MixedInstancesPolicy.

  • mixed_instances_policy (Optional[MixedInstancesPolicy], default: None ) –

    The mixed instances policy. For more information, see Auto Scaling groups with multiple instance types and purchase options in the Amazon EC2 Auto Scaling User Guide.

    You can remove the Distribution Segments configuration by specifying OnDemandBaseCapacity or OnDemandPercentageAboveBaseCapacity. You can also remove it explicitly by specifying an empty list for DistributionSegments.

  • min_size (Optional[AutoScalingGroupMinSize], default: None ) –

    The minimum size of the Auto Scaling group.

  • max_size (Optional[AutoScalingGroupMaxSize], default: None ) –

    The maximum size of the Auto Scaling group.

    With a mixed instances policy that uses instance weighting, Amazon EC2 Auto Scaling may need to go above MaxSize to meet your capacity requirements. In this event, Amazon EC2 Auto Scaling will never go above MaxSize by more than your largest instance weight (weights that define how many units each instance contributes to the desired capacity of the group).

  • desired_capacity (Optional[AutoScalingGroupDesiredCapacity], default: None ) –

    The desired capacity is the initial capacity of the Auto Scaling group after this operation completes and the capacity it attempts to maintain. This number must be greater than or equal to the minimum size of the group and less than or equal to the maximum size of the group.

  • default_cooldown (Optional[Cooldown], default: None ) –

    Only needed if you use simple scaling policies.

    The amount of time, in seconds, between one scaling activity ending and another one starting due to simple scaling policies. For more information, see Scaling cooldowns for Amazon EC2 Auto Scaling in the Amazon EC2 Auto Scaling User Guide.

  • availability_zones (Optional[AvailabilityZones], default: None ) –

    One or more Availability Zones for the group.

  • availability_zone_ids (Optional[AvailabilityZoneIds], default: None ) –

    A list of Availability Zone IDs for the Auto Scaling group. You cannot specify both AvailabilityZones and AvailabilityZoneIds in the same request.

  • health_check_type (Optional[XmlStringMaxLen32], default: None ) –

    A comma-separated value string of one or more health check types.

    The valid values are EC2, EBS, ELB, and VPC_LATTICE. EC2 is the default health check and cannot be disabled. For more information, see Health checks for instances in an Auto Scaling group in the Amazon EC2 Auto Scaling User Guide.

    Only specify EC2 if you must clear a value that was previously set.

  • health_check_grace_period (Optional[HealthCheckGracePeriod], default: None ) –

    The amount of time, in seconds, that Amazon EC2 Auto Scaling waits before checking the health status of an EC2 instance that has come into service and marking it unhealthy due to a failed health check. This is useful if your instances do not immediately pass their health checks after they enter the InService state. For more information, see Set the health check grace period for an Auto Scaling group in the Amazon EC2 Auto Scaling User Guide.

  • placement_group (Optional[UpdatePlacementGroupParam], default: None ) –

    The name of an existing placement group into which to launch your instances. To remove the placement group setting, pass an empty string for placement-group. For more information about placement groups, see Placement groups in the Amazon EC2 User Guide.

    A cluster placement group is a logical grouping of instances within a single Availability Zone. You cannot specify multiple Availability Zones and a cluster placement group.

  • vpc_zone_identifier (Optional[XmlStringMaxLen5000], default: None ) –

    A comma-separated list of subnet IDs for a virtual private cloud (VPC). If you specify VPCZoneIdentifier with AvailabilityZones, the subnets that you specify must reside in those Availability Zones.

  • termination_policies (Optional[TerminationPolicies], default: None ) –

    A policy or a list of policies that are used to select the instances to terminate. The policies are executed in the order that you list them. For more information, see Configure termination policies for Amazon EC2 Auto Scaling in the Amazon EC2 Auto Scaling User Guide.

    Valid values: Default | AllocationStrategy | ClosestToNextInstanceHour | NewestInstance | OldestInstance | OldestLaunchConfiguration | OldestLaunchTemplate | arn:aws:lambda:region:account-id:function:my-function:my-alias

  • new_instances_protected_from_scale_in (Optional[InstanceProtected], default: None ) –

    Indicates whether newly launched instances are protected from termination by Amazon EC2 Auto Scaling when scaling in. For more information about preventing instances from terminating on scale in, see Use instance scale-in protection in the Amazon EC2 Auto Scaling User Guide.

  • service_linked_role_arn (Optional[ResourceName], default: None ) –

    The Amazon Resource Name (ARN) of the service-linked role that the Auto Scaling group uses to call other Amazon Web Services on your behalf. For more information, see Service-linked roles in the Amazon EC2 Auto Scaling User Guide.

  • max_instance_lifetime (Optional[MaxInstanceLifetime], default: None ) –

    The maximum amount of time, in seconds, that an instance can be in service. The default is null. If specified, the value must be either 0 or a number equal to or greater than 86,400 seconds (1 day). To clear a previously set value, specify a new value of 0. For more information, see Replacing Auto Scaling instances based on maximum instance lifetime in the Amazon EC2 Auto Scaling User Guide.

  • capacity_rebalance (Optional[CapacityRebalanceEnabled], default: None ) –

    Enables or disables Capacity Rebalancing. If Capacity Rebalancing is disabled, proactive replacement of at-risk Spot Instances does not occur. For more information, see Capacity Rebalancing in Auto Scaling to replace at-risk Spot Instances in the Amazon EC2 Auto Scaling User Guide.

    To suspend rebalancing across Availability Zones, use the SuspendProcesses API.

  • context (Optional[Context], default: None ) –

    Reserved.

  • desired_capacity_type (Optional[XmlStringMaxLen255], default: None ) –

    The unit of measurement for the value specified for desired capacity. Amazon EC2 Auto Scaling supports DesiredCapacityType for attribute-based instance type selection only. For more information, see Create a mixed instances group using attribute-based instance type selection in the Amazon EC2 Auto Scaling User Guide.

    By default, Amazon EC2 Auto Scaling specifies units, which translates into number of instances.

    Valid values: units | vcpu | memory-mib

  • default_instance_warmup (Optional[DefaultInstanceWarmup], default: None ) –

    The amount of time, in seconds, until a new instance is considered to have finished initializing and resource consumption to become stable after it enters the InService state.

    During an instance refresh, Amazon EC2 Auto Scaling waits for the warm-up period after it replaces an instance before it moves on to replacing the next instance. Amazon EC2 Auto Scaling also waits for the warm-up period before aggregating the metrics for new instances with existing instances in the Amazon CloudWatch metrics that are used for scaling, resulting in more reliable usage data. For more information, see Set the default instance warmup for an Auto Scaling group in the Amazon EC2 Auto Scaling User Guide.

    To manage various warm-up settings at the group level, we recommend that you set the default instance warmup, even if it is set to 0 seconds. To remove a value that you previously set, include the property but specify -1 for the value. However, we strongly recommend keeping the default instance warmup enabled by specifying a value of 0 or other nominal value.

  • instance_maintenance_policy (Optional[InstanceMaintenancePolicy], default: None ) –

    An instance maintenance policy. For more information, see Set instance maintenance policy in the Amazon EC2 Auto Scaling User Guide.

  • availability_zone_distribution (Optional[AvailabilityZoneDistribution], default: None ) –

    The instance capacity distribution across Availability Zones.

  • availability_zone_impairment_policy (Optional[AvailabilityZoneImpairmentPolicy], default: None ) –

    The policy for Availability Zone impairment.

  • skip_zonal_shift_validation (Optional[SkipZonalShiftValidation], default: None ) –

    If you enable zonal shift with cross-zone disabled load balancers, capacity could become imbalanced across Availability Zones. To skip the validation, specify true. For more information, see Auto Scaling group zonal shift in the Amazon EC2 Auto Scaling User Guide.

  • capacity_reservation_specification (Optional[CapacityReservationSpecification], default: None ) –

    The capacity reservation specification for the Auto Scaling group.

  • instance_lifecycle_policy (Optional[InstanceLifecyclePolicy], default: None ) –

    The instance lifecycle policy for the Auto Scaling group. This policy controls instance behavior when an instance transitions through its lifecycle states. Configure retention triggers to specify when instances should move to a Retained state instead of automatic termination.

    For more information, see Control instance retention with instance lifecycle policies in the Amazon EC2 Auto Scaling User Guide.

  • deletion_protection (Optional[DeletionProtection], default: None ) –

    The deletion protection setting for the Auto Scaling group. This setting helps safeguard your Auto Scaling group and its instances by controlling whether the DeleteAutoScalingGroup operation is allowed. When deletion protection is enabled, users cannot delete the Auto Scaling group according to the specified protection level until the setting is changed back to a less restrictive level.

    The valid values are none, prevent-force-deletion, and prevent-all-deletion.

    Default: none

    For more information, see Configure deletion protection for your Amazon EC2 Auto Scaling resources in the Amazon EC2 Auto Scaling User Guide.

Raises:

Examples:

To update an Auto Scaling group This example updates multiple properties at the same time.

>>> await client.update_auto_scaling_group(auto_scaling_group_name='my-auto-scaling-group', launch_template={'LaunchTemplateName': 'my-template-for-auto-scaling', 'Version': '2'}, min_size=1, max_size=5, new_instances_protected_from_scale_in=True)
Source code in docs_src/capo_auto_scaling/_services/async_auto_scaling.py
async def update_auto_scaling_group(
    self,
    *,
    config_overrides: Optional[AsyncAutoScalingClientConfig] = None,
    auto_scaling_group_name: Optional[
        "capo_auto_scaling.types.xml_string_max_len255.XmlStringMaxLen255"
    ] = None,
    launch_configuration_name: Optional[
        "capo_auto_scaling.types.xml_string_max_len255.XmlStringMaxLen255"
    ] = None,
    launch_template: Optional[
        "capo_auto_scaling.types.launch_template_specification.LaunchTemplateSpecification"
    ] = None,
    mixed_instances_policy: Optional[
        "capo_auto_scaling.types.mixed_instances_policy.MixedInstancesPolicy"
    ] = None,
    min_size: Optional[
        "capo_auto_scaling.types.auto_scaling_group_min_size.AutoScalingGroupMinSize"
    ] = None,
    max_size: Optional[
        "capo_auto_scaling.types.auto_scaling_group_max_size.AutoScalingGroupMaxSize"
    ] = None,
    desired_capacity: Optional[
        "capo_auto_scaling.types.auto_scaling_group_desired_capacity.AutoScalingGroupDesiredCapacity"
    ] = None,
    default_cooldown: Optional["capo_auto_scaling.types.cooldown.Cooldown"] = None,
    availability_zones: Optional[
        "capo_auto_scaling.types.availability_zones.AvailabilityZones"
    ] = None,
    availability_zone_ids: Optional[
        "capo_auto_scaling.types.availability_zone_ids.AvailabilityZoneIds"
    ] = None,
    health_check_type: Optional[
        "capo_auto_scaling.types.xml_string_max_len32.XmlStringMaxLen32"
    ] = None,
    health_check_grace_period: Optional[
        "capo_auto_scaling.types.health_check_grace_period.HealthCheckGracePeriod"
    ] = None,
    placement_group: Optional[
        "capo_auto_scaling.types.update_placement_group_param.UpdatePlacementGroupParam"
    ] = None,
    vpc_zone_identifier: Optional[
        "capo_auto_scaling.types.xml_string_max_len5000.XmlStringMaxLen5000"
    ] = None,
    termination_policies: Optional[
        "capo_auto_scaling.types.termination_policies.TerminationPolicies"
    ] = None,
    new_instances_protected_from_scale_in: Optional[
        "capo_auto_scaling.types.instance_protected.InstanceProtected"
    ] = None,
    service_linked_role_arn: Optional[
        "capo_auto_scaling.types.resource_name.ResourceName"
    ] = None,
    max_instance_lifetime: Optional[
        "capo_auto_scaling.types.max_instance_lifetime.MaxInstanceLifetime"
    ] = None,
    capacity_rebalance: Optional[
        "capo_auto_scaling.types.capacity_rebalance_enabled.CapacityRebalanceEnabled"
    ] = None,
    context: Optional["capo_auto_scaling.types.context.Context"] = None,
    desired_capacity_type: Optional[
        "capo_auto_scaling.types.xml_string_max_len255.XmlStringMaxLen255"
    ] = None,
    default_instance_warmup: Optional[
        "capo_auto_scaling.types.default_instance_warmup.DefaultInstanceWarmup"
    ] = None,
    instance_maintenance_policy: Optional[
        "capo_auto_scaling.types.instance_maintenance_policy.InstanceMaintenancePolicy"
    ] = None,
    availability_zone_distribution: Optional[
        "capo_auto_scaling.types.availability_zone_distribution.AvailabilityZoneDistribution"
    ] = None,
    availability_zone_impairment_policy: Optional[
        "capo_auto_scaling.types.availability_zone_impairment_policy.AvailabilityZoneImpairmentPolicy"
    ] = None,
    skip_zonal_shift_validation: Optional[
        "capo_auto_scaling.types.skip_zonal_shift_validation.SkipZonalShiftValidation"
    ] = None,
    capacity_reservation_specification: Optional[
        "capo_auto_scaling.types.capacity_reservation_specification.CapacityReservationSpecification"
    ] = None,
    instance_lifecycle_policy: Optional[
        "capo_auto_scaling.types.instance_lifecycle_policy.InstanceLifecyclePolicy"
    ] = None,
    deletion_protection: Optional[
        "capo_auto_scaling.types.deletion_protection.DeletionProtection"
    ] = None,
) -> None:
    """<p> <b>We strongly recommend that all Auto Scaling groups use launch templates to ensure full functionality for Amazon EC2 Auto Scaling and Amazon EC2.</b> </p> <p>Updates the configuration for the specified Auto Scaling group.</p> <p>To update an Auto Scaling group, specify the name of the group and the property that you want to change. Any properties that you don't specify are not changed by this update request. The new settings take effect on any scaling activities after this call returns. </p> <p>If you associate a new launch configuration or template with an Auto Scaling group, all new instances will get the updated configuration. Existing instances continue to run with the configuration that they were originally launched with. When you update a group to specify a mixed instances policy instead of a launch configuration or template, existing instances may be replaced to match the new purchasing options that you specified in the policy. For example, if the group currently has 100% On-Demand capacity and the policy specifies 50% Spot capacity, this means that half of your instances will be gradually terminated and relaunched as Spot Instances. When replacing instances, Amazon EC2 Auto Scaling launches new instances before terminating the old ones, so that updating your group does not compromise the performance or availability of your application.</p> <p>Note the following about changing <code>DesiredCapacity</code>, <code>MaxSize</code>, or <code>MinSize</code>:</p> <ul> <li> <p>If a scale-in activity occurs as a result of a new <code>DesiredCapacity</code> value that is lower than the current size of the group, the Auto Scaling group uses its termination policy to determine which instances to terminate.</p> </li> <li> <p>If you specify a new value for <code>MinSize</code> without specifying a value for <code>DesiredCapacity</code>, and the new <code>MinSize</code> is larger than the current size of the group, this sets the group's <code>DesiredCapacity</code> to the new <code>MinSize</code> value.</p> </li> <li> <p>If you specify a new value for <code>MaxSize</code> without specifying a value for <code>DesiredCapacity</code>, and the new <code>MaxSize</code> is smaller than the current size of the group, this sets the group's <code>DesiredCapacity</code> to the new <code>MaxSize</code> value.</p> </li> </ul> <p>To see which properties have been set, call the <a href="https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_DescribeAutoScalingGroups.html">DescribeAutoScalingGroups</a> API. To view the scaling policies for an Auto Scaling group, call the <a href="https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_DescribePolicies.html">DescribePolicies</a> API. If the group has scaling policies, you can update them by calling the <a href="https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_PutScalingPolicy.html">PutScalingPolicy</a> API.</p>

    Args:
        auto_scaling_group_name: <p>The name of the Auto Scaling group.</p>
        launch_configuration_name: <p>The name of the launch configuration. If you specify <code>LaunchConfigurationName</code> in your update request, you can't specify <code>LaunchTemplate</code> or <code>MixedInstancesPolicy</code>.</p>
        launch_template: <p>The launch template and version to use to specify the updates. If you specify <code>LaunchTemplate</code> in your update request, you can't specify <code>LaunchConfigurationName</code> or <code>MixedInstancesPolicy</code>.</p>
        mixed_instances_policy: <p>The mixed instances policy. For more information, see <a href="https://docs.aws.amazon.com/autoscaling/ec2/userguide/ec2-auto-scaling-mixed-instances-groups.html">Auto Scaling groups with multiple instance types and purchase options</a> in the <i>Amazon EC2 Auto Scaling User Guide</i>.</p> <p>You can remove the Distribution Segments configuration by specifying <code>OnDemandBaseCapacity</code> or <code>OnDemandPercentageAboveBaseCapacity</code>. You can also remove it explicitly by specifying an empty list for <code>DistributionSegments</code>.</p>
        min_size: <p>The minimum size of the Auto Scaling group.</p>
        max_size: <p>The maximum size of the Auto Scaling group.</p> <note> <p>With a mixed instances policy that uses instance weighting, Amazon EC2 Auto Scaling may need to go above <code>MaxSize</code> to meet your capacity requirements. In this event, Amazon EC2 Auto Scaling will never go above <code>MaxSize</code> by more than your largest instance weight (weights that define how many units each instance contributes to the desired capacity of the group).</p> </note>
        desired_capacity: <p>The desired capacity is the initial capacity of the Auto Scaling group after this operation completes and the capacity it attempts to maintain. This number must be greater than or equal to the minimum size of the group and less than or equal to the maximum size of the group.</p>
        default_cooldown: <p> <i>Only needed if you use simple scaling policies.</i> </p> <p>The amount of time, in seconds, between one scaling activity ending and another one starting due to simple scaling policies. For more information, see <a href="https://docs.aws.amazon.com/autoscaling/ec2/userguide/ec2-auto-scaling-scaling-cooldowns.html">Scaling cooldowns for Amazon EC2 Auto Scaling</a> in the <i>Amazon EC2 Auto Scaling User Guide</i>.</p>
        availability_zones: <p>One or more Availability Zones for the group.</p>
        availability_zone_ids: <p> A list of Availability Zone IDs for the Auto Scaling group. You cannot specify both AvailabilityZones and AvailabilityZoneIds in the same request. </p>
        health_check_type: <p>A comma-separated value string of one or more health check types.</p> <p>The valid values are <code>EC2</code>, <code>EBS</code>, <code>ELB</code>, and <code>VPC_LATTICE</code>. <code>EC2</code> is the default health check and cannot be disabled. For more information, see <a href="https://docs.aws.amazon.com/autoscaling/ec2/userguide/ec2-auto-scaling-health-checks.html">Health checks for instances in an Auto Scaling group</a> in the <i>Amazon EC2 Auto Scaling User Guide</i>.</p> <p>Only specify <code>EC2</code> if you must clear a value that was previously set.</p>
        health_check_grace_period: <p>The amount of time, in seconds, that Amazon EC2 Auto Scaling waits before checking the health status of an EC2 instance that has come into service and marking it unhealthy due to a failed health check. This is useful if your instances do not immediately pass their health checks after they enter the <code>InService</code> state. For more information, see <a href="https://docs.aws.amazon.com/autoscaling/ec2/userguide/health-check-grace-period.html">Set the health check grace period for an Auto Scaling group</a> in the <i>Amazon EC2 Auto Scaling User Guide</i>.</p>
        placement_group: <p>The name of an existing placement group into which to launch your instances. To remove the placement group setting, pass an empty string for <code>placement-group</code>. For more information about placement groups, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/placement-groups.html">Placement groups</a> in the <i>Amazon EC2 User Guide</i>.</p> <note> <p>A <i>cluster</i> placement group is a logical grouping of instances within a single Availability Zone. You cannot specify multiple Availability Zones and a cluster placement group. </p> </note>
        vpc_zone_identifier: <p>A comma-separated list of subnet IDs for a virtual private cloud (VPC). If you specify <code>VPCZoneIdentifier</code> with <code>AvailabilityZones</code>, the subnets that you specify must reside in those Availability Zones.</p>
        termination_policies: <p>A policy or a list of policies that are used to select the instances to terminate. The policies are executed in the order that you list them. For more information, see <a href="https://docs.aws.amazon.com/autoscaling/ec2/userguide/ec2-auto-scaling-termination-policies.html">Configure termination policies for Amazon EC2 Auto Scaling</a> in the <i>Amazon EC2 Auto Scaling User Guide</i>.</p> <p>Valid values: <code>Default</code> | <code>AllocationStrategy</code> | <code>ClosestToNextInstanceHour</code> | <code>NewestInstance</code> | <code>OldestInstance</code> | <code>OldestLaunchConfiguration</code> | <code>OldestLaunchTemplate</code> | <code>arn:aws:lambda:region:account-id:function:my-function:my-alias</code> </p>
        new_instances_protected_from_scale_in: <p>Indicates whether newly launched instances are protected from termination by Amazon EC2 Auto Scaling when scaling in. For more information about preventing instances from terminating on scale in, see <a href="https://docs.aws.amazon.com/autoscaling/ec2/userguide/ec2-auto-scaling-instance-protection.html">Use instance scale-in protection</a> in the <i>Amazon EC2 Auto Scaling User Guide</i>.</p>
        service_linked_role_arn: <p>The Amazon Resource Name (ARN) of the service-linked role that the Auto Scaling group uses to call other Amazon Web Services on your behalf. For more information, see <a href="https://docs.aws.amazon.com/autoscaling/ec2/userguide/autoscaling-service-linked-role.html">Service-linked roles</a> in the <i>Amazon EC2 Auto Scaling User Guide</i>.</p>
        max_instance_lifetime: <p>The maximum amount of time, in seconds, that an instance can be in service. The default is null. If specified, the value must be either 0 or a number equal to or greater than 86,400 seconds (1 day). To clear a previously set value, specify a new value of 0. For more information, see <a href="https://docs.aws.amazon.com/autoscaling/ec2/userguide/asg-max-instance-lifetime.html">Replacing Auto Scaling instances based on maximum instance lifetime</a> in the <i>Amazon EC2 Auto Scaling User Guide</i>.</p>
        capacity_rebalance: <p>Enables or disables Capacity Rebalancing. If Capacity Rebalancing is disabled, proactive replacement of at-risk Spot Instances does not occur. For more information, see <a href="https://docs.aws.amazon.com/autoscaling/ec2/userguide/ec2-auto-scaling-capacity-rebalancing.html">Capacity Rebalancing in Auto Scaling to replace at-risk Spot Instances</a> in the <i>Amazon EC2 Auto Scaling User Guide</i>.</p> <note> <p>To suspend rebalancing across Availability Zones, use the <a href="https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_SuspendedProcess.html">SuspendProcesses</a> API.</p> </note>
        context: <p>Reserved.</p>
        desired_capacity_type: <p>The unit of measurement for the value specified for desired capacity. Amazon EC2 Auto Scaling supports <code>DesiredCapacityType</code> for attribute-based instance type selection only. For more information, see <a href="https://docs.aws.amazon.com/autoscaling/ec2/userguide/create-mixed-instances-group-attribute-based-instance-type-selection.html">Create a mixed instances group using attribute-based instance type selection</a> in the <i>Amazon EC2 Auto Scaling User Guide</i>.</p> <p>By default, Amazon EC2 Auto Scaling specifies <code>units</code>, which translates into number of instances.</p> <p>Valid values: <code>units</code> | <code>vcpu</code> | <code>memory-mib</code> </p>
        default_instance_warmup: <p>The amount of time, in seconds, until a new instance is considered to have finished initializing and resource consumption to become stable after it enters the <code>InService</code> state. </p> <p>During an instance refresh, Amazon EC2 Auto Scaling waits for the warm-up period after it replaces an instance before it moves on to replacing the next instance. Amazon EC2 Auto Scaling also waits for the warm-up period before aggregating the metrics for new instances with existing instances in the Amazon CloudWatch metrics that are used for scaling, resulting in more reliable usage data. For more information, see <a href="https://docs.aws.amazon.com/autoscaling/ec2/userguide/ec2-auto-scaling-default-instance-warmup.html">Set the default instance warmup for an Auto Scaling group</a> in the <i>Amazon EC2 Auto Scaling User Guide</i>.</p> <important> <p>To manage various warm-up settings at the group level, we recommend that you set the default instance warmup, <i>even if it is set to 0 seconds</i>. To remove a value that you previously set, include the property but specify <code>-1</code> for the value. However, we strongly recommend keeping the default instance warmup enabled by specifying a value of <code>0</code> or other nominal value.</p> </important>
        instance_maintenance_policy: <p>An instance maintenance policy. For more information, see <a href="https://docs.aws.amazon.com/autoscaling/ec2/userguide/ec2-auto-scaling-instance-maintenance-policy.html">Set instance maintenance policy</a> in the <i>Amazon EC2 Auto Scaling User Guide</i>.</p>
        availability_zone_distribution: <p> The instance capacity distribution across Availability Zones. </p>
        availability_zone_impairment_policy: <p> The policy for Availability Zone impairment. </p>
        skip_zonal_shift_validation: <p> If you enable zonal shift with cross-zone disabled load balancers, capacity could become imbalanced across Availability Zones. To skip the validation, specify <code>true</code>. For more information, see <a href="https://docs.aws.amazon.com/autoscaling/ec2/userguide/ec2-auto-scaling-zonal-shift.html">Auto Scaling group zonal shift</a> in the <i>Amazon EC2 Auto Scaling User Guide</i>. </p>
        capacity_reservation_specification: <p> The capacity reservation specification for the Auto Scaling group. </p>
        instance_lifecycle_policy: <p> The instance lifecycle policy for the Auto Scaling group. This policy controls instance behavior when an instance transitions through its lifecycle states. Configure retention triggers to specify when instances should move to a <code>Retained</code> state instead of automatic termination. </p> <p>For more information, see <a href="https://docs.aws.amazon.com/autoscaling/ec2/userguide/instance-lifecycle-policy.html"> Control instance retention with instance lifecycle policies</a> in the <i>Amazon EC2 Auto Scaling User Guide</i>. </p>
        deletion_protection: <p> The deletion protection setting for the Auto Scaling group. This setting helps safeguard your Auto Scaling group and its instances by controlling whether the <code>DeleteAutoScalingGroup</code> operation is allowed. When deletion protection is enabled, users cannot delete the Auto Scaling group according to the specified protection level until the setting is changed back to a less restrictive level. </p> <p> The valid values are <code>none</code>, <code>prevent-force-deletion</code>, and <code>prevent-all-deletion</code>. </p> <p> Default: <code>none</code> </p> <p> For more information, see <a href="https://docs.aws.amazon.com/autoscaling/ec2/userguide/resource-deletion-protection.html"> Configure deletion protection for your Amazon EC2 Auto Scaling resources</a> in the <i>Amazon EC2 Auto Scaling User Guide</i>. </p>

    Raises:
        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.scaling_activity_in_progress_fault.ScalingActivityInProgressFault: <p>The operation can't be performed because there are scaling activities in progress.</p>
        capo_auto_scaling.errors.service_linked_role_failure.ServiceLinkedRoleFailure: <p>The service-linked role is not yet ready for use.</p>
        capo_auto_scaling.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To update an Auto Scaling group
        This example updates multiple properties at the same time.

        >>> await client.update_auto_scaling_group(auto_scaling_group_name='my-auto-scaling-group', launch_template={'LaunchTemplateName': 'my-template-for-auto-scaling', 'Version': '2'}, min_size=1, max_size=5, new_instances_protected_from_scale_in=True)
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_auto_scaling.types.update_auto_scaling_group_type.UpdateAutoScalingGroupType]",
    ) -> AsyncOperationResponse[None]:
        import capo_auto_scaling._operations.auto_scaling_2011_01_01.update_auto_scaling_group

        (
            output,
            http_response,
        ) = await capo_auto_scaling._operations.auto_scaling_2011_01_01.update_auto_scaling_group.async_update_auto_scaling_group(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("UpdateAutoScalingGroup")
    )
    input_: capo_auto_scaling.types.update_auto_scaling_group_type.UpdateAutoScalingGroupType = {}
    if auto_scaling_group_name is not None:
        input_["auto_scaling_group_name"] = auto_scaling_group_name
    if launch_configuration_name is not None:
        input_["launch_configuration_name"] = launch_configuration_name
    if launch_template is not None:
        input_["launch_template"] = launch_template
    if mixed_instances_policy is not None:
        input_["mixed_instances_policy"] = mixed_instances_policy
    if min_size is not None:
        input_["min_size"] = min_size
    if max_size is not None:
        input_["max_size"] = max_size
    if desired_capacity is not None:
        input_["desired_capacity"] = desired_capacity
    if default_cooldown is not None:
        input_["default_cooldown"] = default_cooldown
    if availability_zones is not None:
        input_["availability_zones"] = availability_zones
    if availability_zone_ids is not None:
        input_["availability_zone_ids"] = availability_zone_ids
    if health_check_type is not None:
        input_["health_check_type"] = health_check_type
    if health_check_grace_period is not None:
        input_["health_check_grace_period"] = health_check_grace_period
    if placement_group is not None:
        input_["placement_group"] = placement_group
    if vpc_zone_identifier is not None:
        input_["vpc_zone_identifier"] = vpc_zone_identifier
    if termination_policies is not None:
        input_["termination_policies"] = termination_policies
    if new_instances_protected_from_scale_in is not None:
        input_["new_instances_protected_from_scale_in"] = (
            new_instances_protected_from_scale_in
        )
    if service_linked_role_arn is not None:
        input_["service_linked_role_arn"] = service_linked_role_arn
    if max_instance_lifetime is not None:
        input_["max_instance_lifetime"] = max_instance_lifetime
    if capacity_rebalance is not None:
        input_["capacity_rebalance"] = capacity_rebalance
    if context is not None:
        input_["context"] = context
    if desired_capacity_type is not None:
        input_["desired_capacity_type"] = desired_capacity_type
    if default_instance_warmup is not None:
        input_["default_instance_warmup"] = default_instance_warmup
    if instance_maintenance_policy is not None:
        input_["instance_maintenance_policy"] = instance_maintenance_policy
    if availability_zone_distribution is not None:
        input_["availability_zone_distribution"] = availability_zone_distribution
    if availability_zone_impairment_policy is not None:
        input_["availability_zone_impairment_policy"] = (
            availability_zone_impairment_policy
        )
    if skip_zonal_shift_validation is not None:
        input_["skip_zonal_shift_validation"] = skip_zonal_shift_validation
    if capacity_reservation_specification is not None:
        input_["capacity_reservation_specification"] = (
            capacity_reservation_specification
        )
    if instance_lifecycle_policy is not None:
        input_["instance_lifecycle_policy"] = instance_lifecycle_policy
    if deletion_protection is not None:
        input_["deletion_protection"] = deletion_protection

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output