updateAutoScalingGroup method
- required String autoScalingGroupName,
- List<
String> ? availabilityZones, - bool? capacityRebalance,
- int? defaultCooldown,
- int? desiredCapacity,
- int? healthCheckGracePeriod,
- String? healthCheckType,
- String? launchConfigurationName,
- LaunchTemplateSpecification? launchTemplate,
- int? maxInstanceLifetime,
- int? maxSize,
- int? minSize,
- MixedInstancesPolicy? mixedInstancesPolicy,
- bool? newInstancesProtectedFromScaleIn,
- String? placementGroup,
- String? serviceLinkedRoleARN,
- List<
String> ? terminationPolicies, - String? vPCZoneIdentifier,
Updates the configuration for the specified Auto Scaling group.
To update an Auto Scaling group, specify the name of the group and the parameter that you want to change. Any parameters 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 forDesiredCapacity
, and the newMinSize
is larger than the current size of the group, this sets the group'sDesiredCapacity
to the newMinSize
value. -
If you specify a new value for
MaxSize
without specifying a value forDesiredCapacity
, and the newMaxSize
is smaller than the current size of the group, this sets the group'sDesiredCapacity
to the newMaxSize
value.
May throw ScalingActivityInProgressFault. May throw ResourceContentionFault. May throw ServiceLinkedRoleFailure.
Parameter autoScalingGroupName
:
The name of the Auto Scaling group.
Parameter availabilityZones
:
One or more Availability Zones for the group.
Parameter capacityRebalance
:
Enables or disables Capacity Rebalancing. For more information, see Amazon
EC2 Auto Scaling Capacity Rebalancing in the Amazon EC2 Auto
Scaling User Guide.
Parameter defaultCooldown
:
The amount of time, in seconds, after a scaling activity completes before
another scaling activity can start. The default value is 300
.
This setting applies when using simple scaling policies, but not when
using other scaling policies or scheduled scaling. For more information,
see Scaling
cooldowns for Amazon EC2 Auto Scaling in the Amazon EC2 Auto
Scaling User Guide.
Parameter desiredCapacity
:
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.
Parameter healthCheckGracePeriod
:
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.
The default value is 0
. For more information, see Health
check grace period in the Amazon EC2 Auto Scaling User Guide.
Conditional: Required if you are adding an ELB
health check.
Parameter healthCheckType
:
The service to use for the health checks. The valid values are
EC2
and ELB
. If you configure an Auto Scaling
group to use ELB health checks, it considers the instance unhealthy if it
fails either the EC2 status checks or the load balancer health checks.
Parameter launchConfigurationName
:
The name of the launch configuration. If you specify
LaunchConfigurationName
in your update request, you can't
specify LaunchTemplate
or MixedInstancesPolicy
.
Parameter launchTemplate
:
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
.
Parameter maxInstanceLifetime
:
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.
Parameter maxSize
:
The maximum size of the Auto Scaling group.
Parameter minSize
:
The minimum size of the Auto Scaling group.
Parameter mixedInstancesPolicy
:
An embedded object that specifies a mixed instances policy. When you make
changes to an existing policy, all optional parameters are left unchanged
if not specified. For more information, see Auto
Scaling groups with multiple instance types and purchase options in
the Amazon EC2 Auto Scaling User Guide.
Parameter newInstancesProtectedFromScaleIn
:
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 Instance
scale-in protection in the Amazon EC2 Auto Scaling User Guide.
Parameter placementGroup
:
The name of an existing placement group into which to launch your
instances, if any. A placement group is a logical grouping of instances
within a single Availability Zone. You cannot specify multiple
Availability Zones and a placement group. For more information, see Placement
Groups in the Amazon EC2 User Guide for Linux Instances.
Parameter serviceLinkedRoleARN
:
The Amazon Resource Name (ARN) of the service-linked role that the Auto
Scaling group uses to call other AWS services on your behalf. For more
information, see Service-linked
roles in the Amazon EC2 Auto Scaling User Guide.
Parameter terminationPolicies
:
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 Controlling
which Auto Scaling instances terminate during scale in in the
Amazon EC2 Auto Scaling User Guide.
Parameter vPCZoneIdentifier
:
A comma-separated list of subnet IDs for a virtual private cloud (VPC). If
you specify VPCZoneIdentifier
with
AvailabilityZones
, the subnets that you specify for this
parameter must reside in those Availability Zones.
Implementation
Future<void> updateAutoScalingGroup({
required String autoScalingGroupName,
List<String>? availabilityZones,
bool? capacityRebalance,
int? defaultCooldown,
int? desiredCapacity,
int? healthCheckGracePeriod,
String? healthCheckType,
String? launchConfigurationName,
LaunchTemplateSpecification? launchTemplate,
int? maxInstanceLifetime,
int? maxSize,
int? minSize,
MixedInstancesPolicy? mixedInstancesPolicy,
bool? newInstancesProtectedFromScaleIn,
String? placementGroup,
String? serviceLinkedRoleARN,
List<String>? terminationPolicies,
String? vPCZoneIdentifier,
}) async {
ArgumentError.checkNotNull(autoScalingGroupName, 'autoScalingGroupName');
_s.validateStringLength(
'autoScalingGroupName',
autoScalingGroupName,
1,
255,
isRequired: true,
);
_s.validateStringLength(
'healthCheckType',
healthCheckType,
1,
32,
);
_s.validateStringLength(
'launchConfigurationName',
launchConfigurationName,
1,
255,
);
_s.validateStringLength(
'placementGroup',
placementGroup,
1,
255,
);
_s.validateStringLength(
'serviceLinkedRoleARN',
serviceLinkedRoleARN,
1,
1600,
);
_s.validateStringLength(
'vPCZoneIdentifier',
vPCZoneIdentifier,
1,
2047,
);
final $request = <String, dynamic>{};
$request['AutoScalingGroupName'] = autoScalingGroupName;
availabilityZones?.also((arg) => $request['AvailabilityZones'] = arg);
capacityRebalance?.also((arg) => $request['CapacityRebalance'] = arg);
defaultCooldown?.also((arg) => $request['DefaultCooldown'] = arg);
desiredCapacity?.also((arg) => $request['DesiredCapacity'] = arg);
healthCheckGracePeriod
?.also((arg) => $request['HealthCheckGracePeriod'] = arg);
healthCheckType?.also((arg) => $request['HealthCheckType'] = arg);
launchConfigurationName
?.also((arg) => $request['LaunchConfigurationName'] = arg);
launchTemplate?.also((arg) => $request['LaunchTemplate'] = arg);
maxInstanceLifetime?.also((arg) => $request['MaxInstanceLifetime'] = arg);
maxSize?.also((arg) => $request['MaxSize'] = arg);
minSize?.also((arg) => $request['MinSize'] = arg);
mixedInstancesPolicy?.also((arg) => $request['MixedInstancesPolicy'] = arg);
newInstancesProtectedFromScaleIn
?.also((arg) => $request['NewInstancesProtectedFromScaleIn'] = arg);
placementGroup?.also((arg) => $request['PlacementGroup'] = arg);
serviceLinkedRoleARN?.also((arg) => $request['ServiceLinkedRoleARN'] = arg);
terminationPolicies?.also((arg) => $request['TerminationPolicies'] = arg);
vPCZoneIdentifier?.also((arg) => $request['VPCZoneIdentifier'] = arg);
await _protocol.send(
$request,
action: 'UpdateAutoScalingGroup',
version: '2011-01-01',
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
shape: shapes['UpdateAutoScalingGroupType'],
shapes: shapes,
);
}