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
DesiredCapacityvalue 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
MinSizewithout specifying a value forDesiredCapacity, and the newMinSizeis larger than the current size of the group, this sets the group'sDesiredCapacityto the newMinSizevalue. -
If you specify a new value for
MaxSizewithout specifying a value forDesiredCapacity, and the newMaxSizeis smaller than the current size of the group, this sets the group'sDesiredCapacityto the newMaxSizevalue.
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
LaunchConfigurationNamein your update request, you can't specifyLaunchTemplateorMixedInstancesPolicy. -
launch_template(Optional[LaunchTemplateSpecification], default:None) –The launch template and version to use to specify the updates. If you specify
LaunchTemplatein your update request, you can't specifyLaunchConfigurationNameorMixedInstancesPolicy. -
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
OnDemandBaseCapacityorOnDemandPercentageAboveBaseCapacity. You can also remove it explicitly by specifying an empty list forDistributionSegments. -
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
MaxSizeto meet your capacity requirements. In this event, Amazon EC2 Auto Scaling will never go aboveMaxSizeby 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, andVPC_LATTICE.EC2is 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
EC2if 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
InServicestate. 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
VPCZoneIdentifierwithAvailabilityZones, 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
DesiredCapacityTypefor 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
InServicestate.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
-1for the value. However, we strongly recommend keeping the default instance warmup enabled by specifying a value of0or 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
Retainedstate 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
DeleteAutoScalingGroupoperation 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, andprevent-all-deletion.Default:
noneFor more information, see Configure deletion protection for your Amazon EC2 Auto Scaling resources in the Amazon EC2 Auto Scaling User Guide.
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.
-
ServiceLinkedRoleFailure–The service-linked role is not yet ready for use.
-
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)
Source code in docs_src/capo_auto_scaling/_services/async_auto_scaling.py
5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 | |