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?

1 Answer 1


The 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.