'How do I write the terraform for an aws_autoscaling_policy for Step Scaling to set capacity units?
The terraform for StepScaling is fairly limited for this resource. It includes terraform for removing and adding capacities, however, I am trying to set a number of capacities based on the lower and upper bounds of my Cloudwatch metric.
Essentially, I am trying to recreate and write up this resource (Dynamic Scaling Policy on Auto Scaling group) in terraform:
Policy type: Step Scaling
Scaling policy name: scale-out
CloudWatch alarm: my-sqs-alarm
Take the action: Set to
1 capacity units when 1 <= ApproximateNumberOfMessagesVisible < 6
2 capacity units when 6 <= ApproximateNumberOfMessagesVisible < 11
3 capacity units when 11 <= ApproximateNumberOfMessagesVisible < +infinity
This is what I have so far:
resource "aws_autoscaling_policy" "scale-out" {
name = "scale-out"
policy_type = "StepScaling"
autoscaling_group_name = aws_autoscaling_group.autoscaler.name
How do I recreate my steps from the AWS console in terraform?
Solution 1:[1]
The solution is to set:
adjustment_type = "ExactCapacity"
Then I got the configuration I wanted by writing:
step_adjustment {
scaling_adjustment = 1
metric_interval_lower_bound = 0
metric_interval_upper_bound = 5
}
step_adjustment {
scaling_adjustment = 2
metric_interval_lower_bound = 5
metric_interval_upper_bound = 10
}
step_adjustment {
scaling_adjustment = 3
metric_interval_lower_bound = 10
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Kelly |

