Resource: aws_autoscaling_policy#
Manages an Auto Scaling policy.
~> 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#
resource "aws_autoscaling_policy" "example" {
name = "terraform-test"
scaling_adjustment = 4
adjustment_type = "ChangeInCapacity"
cooldown = 300
autoscaling_group_name = "example-asg" # asg is created manually
}
Argument Reference#
name- (Required) The name of the policy.autoscaling_group_name- (Required) The name of the autoscaling group.adjustment_type- (Optional) Specifies whether the adjustment is an absolute number or a percentage of the current capacity.- Valid values:
ChangeInCapacity,ExactCapacity,PercentChangeInCapacity
- Valid values:
policy_type- (Optional) The policy type.- Valid values:
SimpleScaling
- Valid values:
min_adjustment_magnitude- (Optional) Minimum value to scale by whenadjustment_typeis set toPercentChangeInCapacity.cooldown- (Optional) The amount of time, in seconds, after a scaling activity completes and before the next scaling activity can start.scaling_adjustment- (Optional) The amount by which the Auto Scaling group is scaled when the scaling policy is executed
Attribute Reference#
Supported attributes#
In addition to all arguments above, the following attributes are exported:
arn- The Amazon Resource Name (ARN) of the scaling policy.id- The scaling policy's name.name- The scaling policy's name.autoscaling_group_name- The scaling policy's assigned autoscaling group.adjustment_type- The scaling policy's adjustment type.policy_type- The scaling policy's type.
Unsupported attributes#
~> Note These attributes may be present in the terraform.tfstate file, but they have preset values and cannot be specified in configuration files.
The following attributes are not currently supported:
estimated_instance_warmup, metric_aggregation_type, predictive_scaling_configuration, step_adjustment, target_tracking_configuration.
Import#
AutoScaling scaling policy can be imported using the autoscaling_group_name and name separated by /.
$ terraform import aws_autoscaling_policy.test-policy asg-name/policy-name