AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.
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.
For .NET Core this operation is only available in asynchronous form. Please refer to UpdateAutoScalingGroupAsync.
Namespace: Amazon.AutoScaling
Assembly: AWSSDK.AutoScaling.dll
Version: 3.x.y.z
public abstract UpdateAutoScalingGroupResponse UpdateAutoScalingGroup( UpdateAutoScalingGroupRequest request )
Container for the necessary parameters to execute the UpdateAutoScalingGroup service method.
Exception | Condition |
---|---|
ResourceContentionException | You already have a pending update to an Amazon EC2 Auto Scaling resource (for example, an Auto Scaling group, instance, or load balancer). |
ScalingActivityInProgressException | The operation can't be performed because there are scaling activities in progress. |
ServiceLinkedRoleFailureException | The service-linked role is not yet ready for use. |
This example updates multiple properties at the same time.
var client = new AmazonAutoScalingClient(); var response = client.UpdateAutoScalingGroup(new UpdateAutoScalingGroupRequest { AutoScalingGroupName = "my-auto-scaling-group", LaunchTemplate = new LaunchTemplateSpecification { LaunchTemplateName = "my-template-for-auto-scaling", Version = "2" }, MaxSize = 5, MinSize = 1, NewInstancesProtectedFromScaleIn = true });
.NET Framework:
Supported in: 4.5, 4.0, 3.5