Policy
Provides an AutoScaling Scaling Policy resource.
NOTE: You may want to omit
desired_capacityattribute from attachedaws.autoscaling.Groupwhen 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:
- Autoscaling
Group stringName The name of the autoscaling group.
- Adjustment
Type string Specifies whether the adjustment is an absolute number or a percentage of the current capacity. Valid values are
ChangeInCapacity,ExactCapacity, andPercentChangeInCapacity.- Cooldown int
The amount of time, in seconds, after a scaling activity completes and before the next scaling activity can start.
- Estimated
Instance intWarmup 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 stringType 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 intMagnitude - Name string
The name of the dimension.
- Policy
Type string The policy type, either “SimpleScaling”, “StepScaling” or “TargetTrackingScaling”. If this value isn’t provided, AWS will default to “SimpleScaling.”
- Scaling
Adjustment 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.
- Step
Adjustments List<PolicyStep Adjustment Args> A set of adjustments that manage group scaling. These have the following structure:
- Target
Tracking PolicyConfiguration Target Tracking Configuration Args A target tracking policy. These have the following structure:
- Autoscaling
Group stringName The name of the autoscaling group.
- Adjustment
Type string Specifies whether the adjustment is an absolute number or a percentage of the current capacity. Valid values are
ChangeInCapacity,ExactCapacity, andPercentChangeInCapacity.- Cooldown int
The amount of time, in seconds, after a scaling activity completes and before the next scaling activity can start.
- Estimated
Instance intWarmup 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 stringType 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 intMagnitude - Name string
The name of the dimension.
- Policy
Type string The policy type, either “SimpleScaling”, “StepScaling” or “TargetTrackingScaling”. If this value isn’t provided, AWS will default to “SimpleScaling.”
- Scaling
Adjustment 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.
- Step
Adjustments []PolicyStep Adjustment A set of adjustments that manage group scaling. These have the following structure:
- Target
Tracking PolicyConfiguration Target Tracking Configuration A target tracking policy. These have the following structure:
- autoscaling
Group stringName The name of the autoscaling group.
- adjustment
Type string Specifies whether the adjustment is an absolute number or a percentage of the current capacity. Valid values are
ChangeInCapacity,ExactCapacity, andPercentChangeInCapacity.- cooldown number
The amount of time, in seconds, after a scaling activity completes and before the next scaling activity can start.
- estimated
Instance numberWarmup 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 stringType 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 numberMagnitude - name string
The name of the dimension.
- policy
Type string The policy type, either “SimpleScaling”, “StepScaling” or “TargetTrackingScaling”. If this value isn’t provided, AWS will default to “SimpleScaling.”
- scaling
Adjustment 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.
- step
Adjustments PolicyStep Adjustment[] A set of adjustments that manage group scaling. These have the following structure:
- target
Tracking PolicyConfiguration Target Tracking Configuration A target tracking policy. These have the following structure:
- autoscaling_
group_ strname 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, andPercentChangeInCapacity.- cooldown float
The amount of time, in seconds, after a scaling activity completes and before the next scaling activity can start.
- estimated_
instance_ floatwarmup 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_ strtype 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_ floatmagnitude - 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[PolicyStep Adjustment] A set of adjustments that manage group scaling. These have the following structure:
- target_
tracking_ Dict[Policyconfiguration Target Tracking Configuration] 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:
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): Policystatic 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:
- Adjustment
Type string Specifies whether the adjustment is an absolute number or a percentage of the current capacity. Valid values are
ChangeInCapacity,ExactCapacity, andPercentChangeInCapacity.- Arn string
The ARN assigned by AWS to the scaling policy.
- Autoscaling
Group stringName 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.
- Estimated
Instance intWarmup 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 stringType 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 intMagnitude - Name string
The name of the dimension.
- Policy
Type string The policy type, either “SimpleScaling”, “StepScaling” or “TargetTrackingScaling”. If this value isn’t provided, AWS will default to “SimpleScaling.”
- Scaling
Adjustment 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.
- Step
Adjustments List<PolicyStep Adjustment Args> A set of adjustments that manage group scaling. These have the following structure:
- Target
Tracking PolicyConfiguration Target Tracking Configuration Args A target tracking policy. These have the following structure:
- Adjustment
Type string Specifies whether the adjustment is an absolute number or a percentage of the current capacity. Valid values are
ChangeInCapacity,ExactCapacity, andPercentChangeInCapacity.- Arn string
The ARN assigned by AWS to the scaling policy.
- Autoscaling
Group stringName 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.
- Estimated
Instance intWarmup 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 stringType 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 intMagnitude - Name string
The name of the dimension.
- Policy
Type string The policy type, either “SimpleScaling”, “StepScaling” or “TargetTrackingScaling”. If this value isn’t provided, AWS will default to “SimpleScaling.”
- Scaling
Adjustment 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.
- Step
Adjustments []PolicyStep Adjustment A set of adjustments that manage group scaling. These have the following structure:
- Target
Tracking PolicyConfiguration Target Tracking Configuration A target tracking policy. These have the following structure:
- adjustment
Type string Specifies whether the adjustment is an absolute number or a percentage of the current capacity. Valid values are
ChangeInCapacity,ExactCapacity, andPercentChangeInCapacity.- arn string
The ARN assigned by AWS to the scaling policy.
- autoscaling
Group stringName 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.
- estimated
Instance numberWarmup 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 stringType 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 numberMagnitude - name string
The name of the dimension.
- policy
Type string The policy type, either “SimpleScaling”, “StepScaling” or “TargetTrackingScaling”. If this value isn’t provided, AWS will default to “SimpleScaling.”
- scaling
Adjustment 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.
- step
Adjustments PolicyStep Adjustment[] A set of adjustments that manage group scaling. These have the following structure:
- target
Tracking PolicyConfiguration Target Tracking Configuration 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, andPercentChangeInCapacity.- arn str
The ARN assigned by AWS to the scaling policy.
- autoscaling_
group_ strname 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_ floatwarmup 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_ strtype 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_ floatmagnitude - 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[PolicyStep Adjustment] A set of adjustments that manage group scaling. These have the following structure:
- target_
tracking_ Dict[Policyconfiguration Target Tracking Configuration] A target tracking policy. These have the following structure:
Supporting Types
PolicyStepAdjustment
- Scaling
Adjustment 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.
- Metric
Interval stringLower Bound The lower bound for the difference between the alarm threshold and the CloudWatch metric. Without a value, AWS will treat this bound as infinity.
- Metric
Interval stringUpper Bound 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 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.
- Metric
Interval stringLower Bound The lower bound for the difference between the alarm threshold and the CloudWatch metric. Without a value, AWS will treat this bound as infinity.
- Metric
Interval stringUpper Bound 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 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.
- metric
Interval stringLower Bound The lower bound for the difference between the alarm threshold and the CloudWatch metric. Without a value, AWS will treat this bound as infinity.
- metric
Interval stringUpper Bound 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.
- metric
Interval strLower Bound The lower bound for the difference between the alarm threshold and the CloudWatch metric. Without a value, AWS will treat this bound as infinity.
- metric
Interval strUpper Bound 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
- Target
Value double The target value for the metric.
- Customized
Metric PolicySpecification Target Tracking Configuration Customized Metric Specification Args A customized metric. Conflicts with
predefined_metric_specification.- Disable
Scale boolIn Indicates whether scale in by the target tracking policy is disabled.
- Predefined
Metric PolicySpecification Target Tracking Configuration Predefined Metric Specification Args A predefined metric. Conflicts with
customized_metric_specification.
- Target
Value float64 The target value for the metric.
- Customized
Metric PolicySpecification Target Tracking Configuration Customized Metric Specification A customized metric. Conflicts with
predefined_metric_specification.- Disable
Scale boolIn Indicates whether scale in by the target tracking policy is disabled.
- Predefined
Metric PolicySpecification Target Tracking Configuration Predefined Metric Specification A predefined metric. Conflicts with
customized_metric_specification.
- target
Value number The target value for the metric.
- customized
Metric PolicySpecification Target Tracking Configuration Customized Metric Specification A customized metric. Conflicts with
predefined_metric_specification.- disable
Scale booleanIn Indicates whether scale in by the target tracking policy is disabled.
- predefined
Metric PolicySpecification Target Tracking Configuration Predefined Metric Specification A predefined metric. Conflicts with
customized_metric_specification.
- target
Value float The target value for the metric.
- customized
Metric Dict[PolicySpecification Target Tracking Configuration Customized Metric Specification] A customized metric. Conflicts with
predefined_metric_specification.- disable
Scale boolIn Indicates whether scale in by the target tracking policy is disabled.
- predefined
Metric Dict[PolicySpecification Target Tracking Configuration Predefined Metric Specification] A predefined metric. Conflicts with
customized_metric_specification.
PolicyTargetTrackingConfigurationCustomizedMetricSpecification
- Metric
Name string The name of the metric.
- Namespace string
The namespace of the metric.
- Statistic string
The statistic of the metric.
- Metric
Dimensions List<PolicyTarget Tracking Configuration Customized Metric Specification Metric Dimension Args> The dimensions of the metric.
- Unit string
The unit of the metric.
- Metric
Name string The name of the metric.
- Namespace string
The namespace of the metric.
- Statistic string
The statistic of the metric.
- Metric
Dimensions []PolicyTarget Tracking Configuration Customized Metric Specification Metric Dimension The dimensions of the metric.
- Unit string
The unit of the metric.
- metric
Name string The name of the metric.
- namespace string
The namespace of the metric.
- statistic string
The statistic of the metric.
- metric
Dimensions PolicyTarget Tracking Configuration Customized Metric Specification Metric Dimension[] 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.
- metric
Dimensions List[PolicyTarget Tracking Configuration Customized Metric Specification Metric Dimension] The dimensions of the metric.
- unit str
The unit of the metric.
PolicyTargetTrackingConfigurationCustomizedMetricSpecificationMetricDimension
PolicyTargetTrackingConfigurationPredefinedMetricSpecification
- Predefined
Metric stringType The metric type.
- Resource
Label string Identifies the resource associated with the metric type.
- Predefined
Metric stringType The metric type.
- Resource
Label string Identifies the resource associated with the metric type.
- predefined
Metric stringType The metric type.
- resource
Label string Identifies the resource associated with the metric type.
- predefined
Metric strType The metric type.
- resource
Label 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
awsTerraform Provider.