putScalingPolicy

Creates or updates a scaling policy for an Auto Scaling group. Scaling policies are used to scale an Auto Scaling group based on configurable metrics. If no policies are defined, the dynamic scaling and predictive scaling features are not used.

For more information about using dynamic scaling, see Target tracking scaling policies and Step and simple scaling policies in the Amazon EC2 Auto Scaling User Guide.

For more information about using predictive scaling, see Predictive scaling for Amazon EC2 Auto Scaling in the Amazon EC2 Auto Scaling User Guide.

You can view the scaling policies for an Auto Scaling group using the DescribePolicies API call. If you are no longer using a scaling policy, you can delete it by calling the DeletePolicy API.

Samples


fun main() { 
   //sampleStart 
   // This example adds the specified policy to the specified Auto Scaling group.
val resp = autoScalingClient.putScalingPolicy {
    autoScalingGroupName = "my-auto-scaling-group"
    policyName = "alb1000-target-tracking-scaling-policy"
    policyType = "TargetTrackingScaling"
    targetTrackingConfiguration = TargetTrackingConfiguration {
        targetValue = 1000.0.toDouble()
        predefinedMetricSpecification = PredefinedMetricSpecification {
            predefinedMetricType = MetricType.fromValue("ALBRequestCountPerTarget")
            resourceLabel = "app/my-alb/778d41231b141a0f/targetgroup/my-alb-target-group/943f017f100becff"
        }
    }
} 
   //sampleEnd
}