snippetterraformModerate
How can I manage changes in desired capacity due to scaling policies in AutoScaling Group state?
Viewed 0 times
canduegrouppoliciescapacityscalingdesiredmanagechangesstate
Problem
How can I manage changes in desired capacity due to scaling policies in AutoScaling Group state in terraform?
Specifically, suppose I provision an aws_autoscaling_group resource with terraform with a desired_capacity of 4 and a scaleup policy on high CPU utilization. Later, the autoscaling group has updated via scaling policies to a desired capacity of 6 but this state isn't captured in my terraform .tfstate.
If I want to make a subsequent change to my autoscaling group state via terraform, how can I make the change without resetting the desired_capacity (since it has not changed in the .tf)? Can I automate updating the desired_capacity to match current group size somehow, or should I just not set desired_capacity at all?
Specifically, suppose I provision an aws_autoscaling_group resource with terraform with a desired_capacity of 4 and a scaleup policy on high CPU utilization. Later, the autoscaling group has updated via scaling policies to a desired capacity of 6 but this state isn't captured in my terraform .tfstate.
If I want to make a subsequent change to my autoscaling group state via terraform, how can I make the change without resetting the desired_capacity (since it has not changed in the .tf)? Can I automate updating the desired_capacity to match current group size somehow, or should I just not set desired_capacity at all?
Solution
The
The above, with the addition of scale policy can effectively manage capacity without being specific about
desired_capacity in Terraform is marked in the documentation as optional. So with a proper min_size value, Terraform can wait until the minimum capacity is reached before continuing.The above, with the addition of scale policy can effectively manage capacity without being specific about
desired_capacity in your Terraform code. This will prevent you from having Terraform override the capacity in place at the moment of execution.Context
StackExchange DevOps Q#128, answer score: 10
Revisions (0)
No revisions yet.