Creates or updates a scaling policy for an Auto Scaling group. To update an existing scaling policy, use the existing policy name and set the parameters to change. Any existing parameter not changed in an update to an existing policy is not changed in this update request.
autoscaling_put_scaling_policy(AutoScalingGroupName, PolicyName,
PolicyType, AdjustmentType, MinAdjustmentStep, MinAdjustmentMagnitude,
ScalingAdjustment, Cooldown, MetricAggregationType, StepAdjustments,
EstimatedInstanceWarmup, TargetTrackingConfiguration)
[required] The name of the Auto Scaling group.
[required] The name of the policy.
The policy type. The valid values are SimpleScaling
, StepScaling
,
and TargetTrackingScaling
. If the policy type is null, the value is
treated as SimpleScaling
.
Specifies whether the ScalingAdjustment
parameter is an absolute
number or a percentage of the current capacity. The valid values are
ChangeInCapacity
, ExactCapacity
, and PercentChangeInCapacity
.
Valid only if the policy type is StepScaling
or SimpleScaling
. For
more information, see Scaling Adjustment Types
in the Amazon EC2 Auto Scaling User Guide.
Available for backward compatibility. Use MinAdjustmentMagnitude
instead.
The minimum number of instances to scale. If the value of
AdjustmentType
is PercentChangeInCapacity
, the scaling policy
changes the DesiredCapacity
of the Auto Scaling group by at least this
many instances. Otherwise, the error is ValidationError
.
This property replaces the MinAdjustmentStep
property. For example,
suppose that you create a step scaling policy to scale out an Auto
Scaling group by 25 percent and you specify a MinAdjustmentMagnitude
of 2. If the group has 4 instances and the scaling policy is performed,
25 percent of 4 is 1. However, because you specified a
MinAdjustmentMagnitude
of 2, Amazon EC2 Auto Scaling scales out the
group by 2 instances.
Valid only if the policy type is SimpleScaling
or StepScaling
.
The amount by which a simple scaling policy scales the Auto Scaling
group in response to an alarm breach. The adjustment is based on the
value that you specified in the AdjustmentType
parameter (either an
absolute number or a percentage). A positive value adds to the current
capacity and a negative value subtracts from the current capacity. For
exact capacity, you must specify a positive value.
Conditional: If you specify SimpleScaling
for the policy type, you
must specify this parameter. (Not used with any other policy type.)
The amount of time, in seconds, after a scaling activity completes before any further dynamic scaling activities can start. If this parameter is not specified, the default cooldown period for the group applies.
Valid only if the policy type is SimpleScaling
. For more information,
see Scaling Cooldowns
in the Amazon EC2 Auto Scaling User Guide.
The aggregation type for the CloudWatch metrics. The valid values are
Minimum
, Maximum
, and Average
. If the aggregation type is null,
the value is treated as Average
.
Valid only if the policy type is StepScaling
.
A set of adjustments that enable you to scale based on the size of the alarm breach.
Conditional: If you specify StepScaling
for the policy type, you must
specify this parameter. (Not used with any other policy type.)
The estimated time, in seconds, until a newly launched instance can contribute to the CloudWatch metrics. The default is to use the value specified for the default cooldown period for the group.
Valid only if the policy type is StepScaling
or
TargetTrackingScaling
.
A target tracking scaling policy. Includes support for predefined or customized metrics.
For more information, see TargetTrackingConfiguration in the Amazon EC2 Auto Scaling API Reference.
Conditional: If you specify TargetTrackingScaling
for the policy type,
you must specify this parameter. (Not used with any other policy type.)
svc$put_scaling_policy( AutoScalingGroupName = "string", PolicyName = "string", PolicyType = "string", AdjustmentType = "string", MinAdjustmentStep = 123, MinAdjustmentMagnitude = 123, ScalingAdjustment = 123, Cooldown = 123, MetricAggregationType = "string", StepAdjustments = list( list( MetricIntervalLowerBound = 123.0, MetricIntervalUpperBound = 123.0, ScalingAdjustment = 123 ) ), EstimatedInstanceWarmup = 123, TargetTrackingConfiguration = list( PredefinedMetricSpecification = list( PredefinedMetricType = "ASGAverageCPUUtilization"|"ASGAverageNetworkIn"|"ASGAverageNetworkOut"|"ALBRequestCountPerTarget", ResourceLabel = "string" ), CustomizedMetricSpecification = list( MetricName = "string", Namespace = "string", Dimensions = list( list( Name = "string", Value = "string" ) ), Statistic = "Average"|"Minimum"|"Maximum"|"SampleCount"|"Sum", Unit = "string" ), TargetValue = 123.0, DisableScaleIn = TRUE|FALSE ) )
For more information about using scaling policies to scale your Auto Scaling group automatically, see Dynamic Scaling in the Amazon EC2 Auto Scaling User Guide.
# NOT RUN {
# This example adds the specified policy to the specified Auto Scaling
# group.
# }
# NOT RUN {
svc$put_scaling_policy(
AdjustmentType = "ChangeInCapacity",
AutoScalingGroupName = "my-auto-scaling-group",
PolicyName = "ScaleIn",
ScalingAdjustment = -1L
)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab