Policy

Provides an AutoScaling Scaling Policy resource.

NOTE: You may want to omit desired_capacity attribute from attached aws.autoscaling.Group when using autoscaling policies. It’s good practice to pick either manual or dynamic (policy-based) scaling.

Example Usage

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
    public MyStack()
    {
        var bar = new Aws.AutoScaling.Group("bar", new Aws.AutoScaling.GroupArgs
        {
            AvailabilityZones = 
            {
                "us-east-1a",
            },
            ForceDelete = true,
            HealthCheckGracePeriod = 300,
            HealthCheckType = "ELB",
            LaunchConfiguration = aws_launch_configuration.Foo.Name,
            MaxSize = 5,
            MinSize = 2,
        });
        var bat = new Aws.AutoScaling.Policy("bat", new Aws.AutoScaling.PolicyArgs
        {
            AdjustmentType = "ChangeInCapacity",
            AutoscalingGroupName = bar.Name,
            Cooldown = 300,
            ScalingAdjustment = 4,
        });
    }

}
package main

import (
    "github.com/pulumi/pulumi-aws/sdk/v2/go/aws/autoscaling"
    "github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)

func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
        bar, err := autoscaling.NewGroup(ctx, "bar", &autoscaling.GroupArgs{
            AvailabilityZones: pulumi.StringArray{
                pulumi.String("us-east-1a"),
            },
            ForceDelete:            pulumi.Bool(true),
            HealthCheckGracePeriod: pulumi.Int(300),
            HealthCheckType:        pulumi.String("ELB"),
            LaunchConfiguration:    pulumi.String(aws_launch_configuration.Foo.Name),
            MaxSize:                pulumi.Int(5),
            MinSize:                pulumi.Int(2),
        })
        if err != nil {
            return err
        }
        _, err = autoscaling.NewPolicy(ctx, "bat", &autoscaling.PolicyArgs{
            AdjustmentType:       pulumi.String("ChangeInCapacity"),
            AutoscalingGroupName: bar.Name,
            Cooldown:             pulumi.Int(300),
            ScalingAdjustment:    pulumi.Int(4),
        })
        if err != nil {
            return err
        }
        return nil
    })
}
import pulumi
import pulumi_aws as aws

bar = aws.autoscaling.Group("bar",
    availability_zones=["us-east-1a"],
    force_delete=True,
    health_check_grace_period=300,
    health_check_type="ELB",
    launch_configuration=aws_launch_configuration["foo"]["name"],
    max_size=5,
    min_size=2)
bat = aws.autoscaling.Policy("bat",
    adjustment_type="ChangeInCapacity",
    autoscaling_group_name=bar.name,
    cooldown=300,
    scaling_adjustment=4)
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const bar = new aws.autoscaling.Group("bar", {
    availabilityZones: ["us-east-1a"],
    forceDelete: true,
    healthCheckGracePeriod: 300,
    healthCheckType: "ELB",
    launchConfiguration: aws_launch_configuration_foo.name,
    maxSize: 5,
    minSize: 2,
});
const bat = new aws.autoscaling.Policy("bat", {
    adjustmentType: "ChangeInCapacity",
    autoscalingGroupName: bar.name,
    cooldown: 300,
    scalingAdjustment: 4,
});

Create a Policy Resource

new Policy(name: string, args: PolicyArgs, opts?: CustomResourceOptions);
def Policy(resource_name, opts=None, adjustment_type=None, autoscaling_group_name=None, cooldown=None, estimated_instance_warmup=None, metric_aggregation_type=None, min_adjustment_magnitude=None, name=None, policy_type=None, scaling_adjustment=None, step_adjustments=None, target_tracking_configuration=None, __props__=None);
func NewPolicy(ctx *Context, name string, args PolicyArgs, opts ...ResourceOption) (*Policy, error)
public Policy(string name, PolicyArgs args, CustomResourceOptions? opts = null)
name string
The unique name of the resource.
args PolicyArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
opts ResourceOptions
A bag of options that control this resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args PolicyArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args PolicyArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

Policy Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.

Inputs

The Policy resource accepts the following input properties:

AutoscalingGroupName string

The name of the autoscaling group.

AdjustmentType string

Specifies whether the adjustment is an absolute number or a percentage of the current capacity. Valid values are ChangeInCapacity, ExactCapacity, and PercentChangeInCapacity.

Cooldown int

The amount of time, in seconds, after a scaling activity completes and before the next scaling activity can start.

EstimatedInstanceWarmup int

The estimated time, in seconds, until a newly launched instance will contribute CloudWatch metrics. Without a value, AWS will default to the group’s specified cooldown period.

MetricAggregationType string

The aggregation type for the policy’s metrics. Valid values are “Minimum”, “Maximum”, and “Average”. Without a value, AWS will treat the aggregation type as “Average”.

MinAdjustmentMagnitude int
Name string

The name of the dimension.

PolicyType string

The policy type, either “SimpleScaling”, “StepScaling” or “TargetTrackingScaling”. If this value isn’t provided, AWS will default to “SimpleScaling.”

ScalingAdjustment int

The number of members by which to scale, when the adjustment bounds are breached. A positive value scales up. A negative value scales down.

StepAdjustments List<PolicyStepAdjustmentArgs>

A set of adjustments that manage group scaling. These have the following structure:

TargetTrackingConfiguration PolicyTargetTrackingConfigurationArgs

A target tracking policy. These have the following structure:

AutoscalingGroupName string

The name of the autoscaling group.

AdjustmentType string

Specifies whether the adjustment is an absolute number or a percentage of the current capacity. Valid values are ChangeInCapacity, ExactCapacity, and PercentChangeInCapacity.

Cooldown int

The amount of time, in seconds, after a scaling activity completes and before the next scaling activity can start.

EstimatedInstanceWarmup int

The estimated time, in seconds, until a newly launched instance will contribute CloudWatch metrics. Without a value, AWS will default to the group’s specified cooldown period.

MetricAggregationType string

The aggregation type for the policy’s metrics. Valid values are “Minimum”, “Maximum”, and “Average”. Without a value, AWS will treat the aggregation type as “Average”.

MinAdjustmentMagnitude int
Name string

The name of the dimension.

PolicyType string

The policy type, either “SimpleScaling”, “StepScaling” or “TargetTrackingScaling”. If this value isn’t provided, AWS will default to “SimpleScaling.”

ScalingAdjustment int

The number of members by which to scale, when the adjustment bounds are breached. A positive value scales up. A negative value scales down.

StepAdjustments []PolicyStepAdjustment

A set of adjustments that manage group scaling. These have the following structure:

TargetTrackingConfiguration PolicyTargetTrackingConfiguration

A target tracking policy. These have the following structure:

autoscalingGroupName string

The name of the autoscaling group.

adjustmentType string

Specifies whether the adjustment is an absolute number or a percentage of the current capacity. Valid values are ChangeInCapacity, ExactCapacity, and PercentChangeInCapacity.

cooldown number

The amount of time, in seconds, after a scaling activity completes and before the next scaling activity can start.

estimatedInstanceWarmup number

The estimated time, in seconds, until a newly launched instance will contribute CloudWatch metrics. Without a value, AWS will default to the group’s specified cooldown period.

metricAggregationType string

The aggregation type for the policy’s metrics. Valid values are “Minimum”, “Maximum”, and “Average”. Without a value, AWS will treat the aggregation type as “Average”.

minAdjustmentMagnitude number
name string

The name of the dimension.

policyType string

The policy type, either “SimpleScaling”, “StepScaling” or “TargetTrackingScaling”. If this value isn’t provided, AWS will default to “SimpleScaling.”

scalingAdjustment number

The number of members by which to scale, when the adjustment bounds are breached. A positive value scales up. A negative value scales down.

stepAdjustments PolicyStepAdjustment[]

A set of adjustments that manage group scaling. These have the following structure:

targetTrackingConfiguration PolicyTargetTrackingConfiguration

A target tracking policy. These have the following structure:

autoscaling_group_name str

The name of the autoscaling group.

adjustment_type str

Specifies whether the adjustment is an absolute number or a percentage of the current capacity. Valid values are ChangeInCapacity, ExactCapacity, and PercentChangeInCapacity.

cooldown float

The amount of time, in seconds, after a scaling activity completes and before the next scaling activity can start.

estimated_instance_warmup float

The estimated time, in seconds, until a newly launched instance will contribute CloudWatch metrics. Without a value, AWS will default to the group’s specified cooldown period.

metric_aggregation_type str

The aggregation type for the policy’s metrics. Valid values are “Minimum”, “Maximum”, and “Average”. Without a value, AWS will treat the aggregation type as “Average”.

min_adjustment_magnitude float
name str

The name of the dimension.

policy_type str

The policy type, either “SimpleScaling”, “StepScaling” or “TargetTrackingScaling”. If this value isn’t provided, AWS will default to “SimpleScaling.”

scaling_adjustment float

The number of members by which to scale, when the adjustment bounds are breached. A positive value scales up. A negative value scales down.

step_adjustments List[PolicyStepAdjustment]

A set of adjustments that manage group scaling. These have the following structure:

target_tracking_configuration Dict[PolicyTargetTrackingConfiguration]

A target tracking policy. These have the following structure:

Outputs

All input properties are implicitly available as output properties. Additionally, the Policy resource produces the following output properties:

Arn string

The ARN assigned by AWS to the scaling policy.

Id string
The provider-assigned unique ID for this managed resource.
Arn string

The ARN assigned by AWS to the scaling policy.

Id string
The provider-assigned unique ID for this managed resource.
arn string

The ARN assigned by AWS to the scaling policy.

id string
The provider-assigned unique ID for this managed resource.
arn str

The ARN assigned by AWS to the scaling policy.

id str
The provider-assigned unique ID for this managed resource.

Look up an Existing Policy Resource

Get an existing Policy resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: PolicyState, opts?: CustomResourceOptions): Policy
static get(resource_name, id, opts=None, adjustment_type=None, arn=None, autoscaling_group_name=None, cooldown=None, estimated_instance_warmup=None, metric_aggregation_type=None, min_adjustment_magnitude=None, name=None, policy_type=None, scaling_adjustment=None, step_adjustments=None, target_tracking_configuration=None, __props__=None);
func GetPolicy(ctx *Context, name string, id IDInput, state *PolicyState, opts ...ResourceOption) (*Policy, error)
public static Policy Get(string name, Input<string> id, PolicyState? state, CustomResourceOptions? opts = null)
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.

The following state arguments are supported:

AdjustmentType string

Specifies whether the adjustment is an absolute number or a percentage of the current capacity. Valid values are ChangeInCapacity, ExactCapacity, and PercentChangeInCapacity.

Arn string

The ARN assigned by AWS to the scaling policy.

AutoscalingGroupName string

The name of the autoscaling group.

Cooldown int

The amount of time, in seconds, after a scaling activity completes and before the next scaling activity can start.

EstimatedInstanceWarmup int

The estimated time, in seconds, until a newly launched instance will contribute CloudWatch metrics. Without a value, AWS will default to the group’s specified cooldown period.

MetricAggregationType string

The aggregation type for the policy’s metrics. Valid values are “Minimum”, “Maximum”, and “Average”. Without a value, AWS will treat the aggregation type as “Average”.

MinAdjustmentMagnitude int
Name string

The name of the dimension.

PolicyType string

The policy type, either “SimpleScaling”, “StepScaling” or “TargetTrackingScaling”. If this value isn’t provided, AWS will default to “SimpleScaling.”

ScalingAdjustment int

The number of members by which to scale, when the adjustment bounds are breached. A positive value scales up. A negative value scales down.

StepAdjustments List<PolicyStepAdjustmentArgs>

A set of adjustments that manage group scaling. These have the following structure:

TargetTrackingConfiguration PolicyTargetTrackingConfigurationArgs

A target tracking policy. These have the following structure:

AdjustmentType string

Specifies whether the adjustment is an absolute number or a percentage of the current capacity. Valid values are ChangeInCapacity, ExactCapacity, and PercentChangeInCapacity.

Arn string

The ARN assigned by AWS to the scaling policy.

AutoscalingGroupName string

The name of the autoscaling group.

Cooldown int

The amount of time, in seconds, after a scaling activity completes and before the next scaling activity can start.

EstimatedInstanceWarmup int

The estimated time, in seconds, until a newly launched instance will contribute CloudWatch metrics. Without a value, AWS will default to the group’s specified cooldown period.

MetricAggregationType string

The aggregation type for the policy’s metrics. Valid values are “Minimum”, “Maximum”, and “Average”. Without a value, AWS will treat the aggregation type as “Average”.

MinAdjustmentMagnitude int
Name string

The name of the dimension.

PolicyType string

The policy type, either “SimpleScaling”, “StepScaling” or “TargetTrackingScaling”. If this value isn’t provided, AWS will default to “SimpleScaling.”

ScalingAdjustment int

The number of members by which to scale, when the adjustment bounds are breached. A positive value scales up. A negative value scales down.

StepAdjustments []PolicyStepAdjustment

A set of adjustments that manage group scaling. These have the following structure:

TargetTrackingConfiguration PolicyTargetTrackingConfiguration

A target tracking policy. These have the following structure:

adjustmentType string

Specifies whether the adjustment is an absolute number or a percentage of the current capacity. Valid values are ChangeInCapacity, ExactCapacity, and PercentChangeInCapacity.

arn string

The ARN assigned by AWS to the scaling policy.

autoscalingGroupName string

The name of the autoscaling group.

cooldown number

The amount of time, in seconds, after a scaling activity completes and before the next scaling activity can start.

estimatedInstanceWarmup number

The estimated time, in seconds, until a newly launched instance will contribute CloudWatch metrics. Without a value, AWS will default to the group’s specified cooldown period.

metricAggregationType string

The aggregation type for the policy’s metrics. Valid values are “Minimum”, “Maximum”, and “Average”. Without a value, AWS will treat the aggregation type as “Average”.

minAdjustmentMagnitude number
name string

The name of the dimension.

policyType string

The policy type, either “SimpleScaling”, “StepScaling” or “TargetTrackingScaling”. If this value isn’t provided, AWS will default to “SimpleScaling.”

scalingAdjustment number

The number of members by which to scale, when the adjustment bounds are breached. A positive value scales up. A negative value scales down.

stepAdjustments PolicyStepAdjustment[]

A set of adjustments that manage group scaling. These have the following structure:

targetTrackingConfiguration PolicyTargetTrackingConfiguration

A target tracking policy. These have the following structure:

adjustment_type str

Specifies whether the adjustment is an absolute number or a percentage of the current capacity. Valid values are ChangeInCapacity, ExactCapacity, and PercentChangeInCapacity.

arn str

The ARN assigned by AWS to the scaling policy.

autoscaling_group_name str

The name of the autoscaling group.

cooldown float

The amount of time, in seconds, after a scaling activity completes and before the next scaling activity can start.

estimated_instance_warmup float

The estimated time, in seconds, until a newly launched instance will contribute CloudWatch metrics. Without a value, AWS will default to the group’s specified cooldown period.

metric_aggregation_type str

The aggregation type for the policy’s metrics. Valid values are “Minimum”, “Maximum”, and “Average”. Without a value, AWS will treat the aggregation type as “Average”.

min_adjustment_magnitude float
name str

The name of the dimension.

policy_type str

The policy type, either “SimpleScaling”, “StepScaling” or “TargetTrackingScaling”. If this value isn’t provided, AWS will default to “SimpleScaling.”

scaling_adjustment float

The number of members by which to scale, when the adjustment bounds are breached. A positive value scales up. A negative value scales down.

step_adjustments List[PolicyStepAdjustment]

A set of adjustments that manage group scaling. These have the following structure:

target_tracking_configuration Dict[PolicyTargetTrackingConfiguration]

A target tracking policy. These have the following structure:

Supporting Types

PolicyStepAdjustment

See the input and output API doc for this type.

See the input and output API doc for this type.

See the input and output API doc for this type.

ScalingAdjustment int

The number of members by which to scale, when the adjustment bounds are breached. A positive value scales up. A negative value scales down.

MetricIntervalLowerBound string

The lower bound for the difference between the alarm threshold and the CloudWatch metric. Without a value, AWS will treat this bound as infinity.

MetricIntervalUpperBound string

The upper bound for the difference between the alarm threshold and the CloudWatch metric. Without a value, AWS will treat this bound as infinity. The upper bound must be greater than the lower bound.

ScalingAdjustment int

The number of members by which to scale, when the adjustment bounds are breached. A positive value scales up. A negative value scales down.

MetricIntervalLowerBound string

The lower bound for the difference between the alarm threshold and the CloudWatch metric. Without a value, AWS will treat this bound as infinity.

MetricIntervalUpperBound string

The upper bound for the difference between the alarm threshold and the CloudWatch metric. Without a value, AWS will treat this bound as infinity. The upper bound must be greater than the lower bound.

scalingAdjustment number

The number of members by which to scale, when the adjustment bounds are breached. A positive value scales up. A negative value scales down.

metricIntervalLowerBound string

The lower bound for the difference between the alarm threshold and the CloudWatch metric. Without a value, AWS will treat this bound as infinity.

metricIntervalUpperBound string

The upper bound for the difference between the alarm threshold and the CloudWatch metric. Without a value, AWS will treat this bound as infinity. The upper bound must be greater than the lower bound.

scaling_adjustment float

The number of members by which to scale, when the adjustment bounds are breached. A positive value scales up. A negative value scales down.

metricIntervalLowerBound str

The lower bound for the difference between the alarm threshold and the CloudWatch metric. Without a value, AWS will treat this bound as infinity.

metricIntervalUpperBound str

The upper bound for the difference between the alarm threshold and the CloudWatch metric. Without a value, AWS will treat this bound as infinity. The upper bound must be greater than the lower bound.

PolicyTargetTrackingConfiguration

See the input and output API doc for this type.

See the input and output API doc for this type.

See the input and output API doc for this type.

TargetValue double

The target value for the metric.

CustomizedMetricSpecification PolicyTargetTrackingConfigurationCustomizedMetricSpecificationArgs

A customized metric. Conflicts with predefined_metric_specification.

DisableScaleIn bool

Indicates whether scale in by the target tracking policy is disabled.

PredefinedMetricSpecification PolicyTargetTrackingConfigurationPredefinedMetricSpecificationArgs

A predefined metric. Conflicts with customized_metric_specification.

TargetValue float64

The target value for the metric.

CustomizedMetricSpecification PolicyTargetTrackingConfigurationCustomizedMetricSpecification

A customized metric. Conflicts with predefined_metric_specification.

DisableScaleIn bool

Indicates whether scale in by the target tracking policy is disabled.

PredefinedMetricSpecification PolicyTargetTrackingConfigurationPredefinedMetricSpecification

A predefined metric. Conflicts with customized_metric_specification.

targetValue number

The target value for the metric.

customizedMetricSpecification PolicyTargetTrackingConfigurationCustomizedMetricSpecification

A customized metric. Conflicts with predefined_metric_specification.

disableScaleIn boolean

Indicates whether scale in by the target tracking policy is disabled.

predefinedMetricSpecification PolicyTargetTrackingConfigurationPredefinedMetricSpecification

A predefined metric. Conflicts with customized_metric_specification.

targetValue float

The target value for the metric.

customizedMetricSpecification Dict[PolicyTargetTrackingConfigurationCustomizedMetricSpecification]

A customized metric. Conflicts with predefined_metric_specification.

disableScaleIn bool

Indicates whether scale in by the target tracking policy is disabled.

predefinedMetricSpecification Dict[PolicyTargetTrackingConfigurationPredefinedMetricSpecification]

A predefined metric. Conflicts with customized_metric_specification.

PolicyTargetTrackingConfigurationCustomizedMetricSpecification

See the input and output API doc for this type.

See the input and output API doc for this type.

See the input and output API doc for this type.

MetricName string

The name of the metric.

Namespace string

The namespace of the metric.

Statistic string

The statistic of the metric.

MetricDimensions List<PolicyTargetTrackingConfigurationCustomizedMetricSpecificationMetricDimensionArgs>

The dimensions of the metric.

Unit string

The unit of the metric.

MetricName string

The name of the metric.

Namespace string

The namespace of the metric.

Statistic string

The statistic of the metric.

MetricDimensions []PolicyTargetTrackingConfigurationCustomizedMetricSpecificationMetricDimension

The dimensions of the metric.

Unit string

The unit of the metric.

metricName string

The name of the metric.

namespace string

The namespace of the metric.

statistic string

The statistic of the metric.

metricDimensions PolicyTargetTrackingConfigurationCustomizedMetricSpecificationMetricDimension[]

The dimensions of the metric.

unit string

The unit of the metric.

metric_name str

The name of the metric.

namespace str

The namespace of the metric.

statistic str

The statistic of the metric.

metricDimensions List[PolicyTargetTrackingConfigurationCustomizedMetricSpecificationMetricDimension]

The dimensions of the metric.

unit str

The unit of the metric.

PolicyTargetTrackingConfigurationCustomizedMetricSpecificationMetricDimension

See the input and output API doc for this type.

See the input and output API doc for this type.

See the input and output API doc for this type.

Name string

The name of the dimension.

Value string

The value of the dimension.

Name string

The name of the dimension.

Value string

The value of the dimension.

name string

The name of the dimension.

value string

The value of the dimension.

name str

The name of the dimension.

value str

The value of the dimension.

PolicyTargetTrackingConfigurationPredefinedMetricSpecification

See the input and output API doc for this type.

See the input and output API doc for this type.

See the input and output API doc for this type.

PredefinedMetricType string

The metric type.

ResourceLabel string

Identifies the resource associated with the metric type.

PredefinedMetricType string

The metric type.

ResourceLabel string

Identifies the resource associated with the metric type.

predefinedMetricType string

The metric type.

resourceLabel string

Identifies the resource associated with the metric type.

predefinedMetricType str

The metric type.

resourceLabel str

Identifies the resource associated with the metric type.

Package Details

Repository
https://github.com/pulumi/pulumi-aws
License
Apache-2.0
Notes
This Pulumi package is based on the aws Terraform Provider.