Updates the configuration for the specified Auto Scaling group.
autoscaling_update_auto_scaling_group(AutoScalingGroupName,
LaunchConfigurationName, LaunchTemplate, MixedInstancesPolicy, MinSize,
MaxSize, DesiredCapacity, DefaultCooldown, AvailabilityZones,
HealthCheckType, HealthCheckGracePeriod, PlacementGroup,
VPCZoneIdentifier, TerminationPolicies,
NewInstancesProtectedFromScaleIn, ServiceLinkedRoleARN,
MaxInstanceLifetime)
[required] The name of the Auto Scaling group.
The name of the launch configuration. If you specify
LaunchConfigurationName
in your update request, you can\'t specify
LaunchTemplate
or MixedInstancesPolicy
.
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
.
For more information, see LaunchTemplateSpecification in the Amazon EC2 Auto Scaling API Reference.
An embedded object that specifies a mixed instances policy.
In your call to UpdateAutoScalingGroup
, you can make changes to the
policy that is specified. All optional parameters are left unchanged if
not specified.
For more information, see MixedInstancesPolicy in the Amazon EC2 Auto Scaling API Reference and Auto Scaling Groups with Multiple Instance Types and Purchase Options in the Amazon EC2 Auto Scaling User Guide.
The minimum size of the Auto Scaling group.
The maximum size of the Auto Scaling group.
The number of EC2 instances that should be running in the Auto Scaling group. 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.
The amount of time, in seconds, after a scaling activity completes
before another scaling activity can start. The default value is 300
.
This cooldown period is not used when a scaling-specific cooldown is
specified.
Cooldown periods are not supported for target tracking scaling policies, step scaling policies, or scheduled scaling. For more information, see Scaling Cooldowns in the Amazon EC2 Auto Scaling User Guide.
One or more Availability Zones for the group.
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.
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: This parameter is required if you are adding an ELB
health check.
The name of the 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.
A comma-separated list of subnet IDs for virtual private cloud (VPC).
If you specify VPCZoneIdentifier
with AvailabilityZones
, the subnets
that you specify for this parameter must reside in those Availability
Zones.
A standalone termination policy or a list of termination policies used to select the instance to terminate. The policies are executed in the order that they are listed.
For more information, see Controlling Which Instances Auto Scaling Terminates During Scale In in the Amazon EC2 Auto Scaling User Guide.
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 Protection in the Amazon EC2 Auto Scaling User Guide.
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.
The maximum amount of time, in seconds, that an instance can be in service.
Valid Range: Minimum value of 604800.
svc$update_auto_scaling_group( AutoScalingGroupName = "string", LaunchConfigurationName = "string", LaunchTemplate = list( LaunchTemplateId = "string", LaunchTemplateName = "string", Version = "string" ), MixedInstancesPolicy = list( LaunchTemplate = list( LaunchTemplateSpecification = list( LaunchTemplateId = "string", LaunchTemplateName = "string", Version = "string" ), Overrides = list( list( InstanceType = "string", WeightedCapacity = "string" ) ) ), InstancesDistribution = list( OnDemandAllocationStrategy = "string", OnDemandBaseCapacity = 123, OnDemandPercentageAboveBaseCapacity = 123, SpotAllocationStrategy = "string", SpotInstancePools = 123, SpotMaxPrice = "string" ) ), MinSize = 123, MaxSize = 123, DesiredCapacity = 123, DefaultCooldown = 123, AvailabilityZones = list( "string" ), HealthCheckType = "string", HealthCheckGracePeriod = 123, PlacementGroup = "string", VPCZoneIdentifier = "string", TerminationPolicies = list( "string" ), NewInstancesProtectedFromScaleIn = TRUE|FALSE, ServiceLinkedRoleARN = "string", MaxInstanceLifetime = 123 )
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\ 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 event 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 parameters have been set, use DescribeAutoScalingGroups. You can also view the scaling policies for an Auto Scaling group using DescribePolicies. If the group has scaling policies, you can update them using PutScalingPolicy.
# NOT RUN {
# This example updates the launch configuration of the specified Auto
# Scaling group.
# }
# NOT RUN {
svc$update_auto_scaling_group(
AutoScalingGroupName = "my-auto-scaling-group",
LaunchConfigurationName = "new-launch-config"
)
# }
# NOT RUN {
# This example updates the minimum size and maximum size of the specified
# Auto Scaling group.
# }
# NOT RUN {
svc$update_auto_scaling_group(
AutoScalingGroupName = "my-auto-scaling-group",
MaxSize = 3L,
MinSize = 1L
)
# }
# NOT RUN {
# This example enables instance protection for the specified Auto Scaling
# group.
# }
# NOT RUN {
svc$update_auto_scaling_group(
AutoScalingGroupName = "my-auto-scaling-group",
NewInstancesProtectedFromScaleIn = TRUE
)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab