<p>The <code>desired_capacity</code> in Terraform is marked <a href="https://www.terraform.io/docs/providers/aws/r/autoscaling_group.html#desired_capacity" rel="noreferrer">in the documentation</a> as optional. So with a proper <code>min_size</code> value, Terraform <a href="https://www.terraform.io/docs/providers/aws/r/autoscaling_group.html#waiting-for-capacity" rel="noreferrer">can wait</a> until the minimum capacity is reached before continuing.</p>

<p>The above, with the addition of scale policy can effectively manage capacity without being specific about <code>desired_capacity</code> in your Terraform code. This will prevent you from having Terraform override the capacity in place at the moment of execution.</p>

CC BY-SA 3.0
2017-03-01T02:30:47.463Z
2017-03-01T02:30:47.463Z
Evgeny Zislis
<p>How can I manage changes in desired capacity due to scaling policies in AutoScaling Group state in terraform?</p>

<p>Specifically, suppose I provision an <a href="https://www.terraform.io/docs/providers/aws/r/autoscaling_group.html" rel="noreferrer">aws_autoscaling_group resource</a> with terraform with a <a href="https://www.terraform.io/docs/providers/aws/r/autoscaling_group.html#desired_capacity" rel="noreferrer">desired_capacity</a> 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. </p>

<p>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?</p>

<amazon-web-services><terraform><autoscaling><capacity-planning>
How can I manage changes in desired capacity due to scaling policies in AutoScaling Group state?
Anthony Neace
# How can I manage changes in desired capacity due to scaling policies in AutoScaling Group state?

(Asked by: username_0 on 2017-03-01)

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](https://www.terraform.io/docs/providers/aws/r/autoscaling_group.html) with terraform with a [desired\_capacity](https://www.terraform.io/docs/providers/aws/r/autoscaling_group.html#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?

**Tags:** amazon-web-services, terraform, autoscaling, capacity-planning


---

## 1 answers

### Answer by username_1 on 2017-03-01. Score: 10 | Accepted answer

The `desired_capacity` in Terraform is marked [in the documentation](https://www.terraform.io/docs/providers/aws/r/autoscaling_group.html#desired_capacity) as optional. So with a proper `min_size` value, Terraform [can wait](https://www.terraform.io/docs/providers/aws/r/autoscaling_group.html#waiting-for-capacity) 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.


---

