Skip to content

Commit 8a1cd6f

Browse files
fix: prevent unnecessary updates when cpu_options is unset (#4806)
This PR will replace: ```hcl cpu_options { core_count = var.cpu_options != null ? var.cpu_options.core_count : null threads_per_core = var.cpu_options != null ? var.cpu_options.threads_per_core : null } ``` with: ```hcl dynamic "cpu_options" { for_each = var.cpu_options != null ? [var.cpu_options] : [] content { core_count = try(cpu_options.value.core_count, null) threads_per_core = try(cpu_options.value.threads_per_core, null) } } ``` This way, if `cpu_options` is not set, Terraform will **not force a resource update every time**. This issue was introduced in PR #4789 <img width="346" height="94" alt="image" src="https://github.com/user-attachments/assets/5a3ca60d-7300-4957-91c3-ff87c2cd5b62" />
1 parent 3f115cd commit 8a1cd6f

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

modules/runners/main.tf

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,12 @@ resource "aws_launch_template" "runner" {
160160
}
161161
}
162162

163-
cpu_options {
164-
core_count = var.cpu_options != null ? var.cpu_options.core_count : null
165-
threads_per_core = var.cpu_options != null ? var.cpu_options.threads_per_core : null
163+
dynamic "cpu_options" {
164+
for_each = var.cpu_options != null ? [var.cpu_options] : []
165+
content {
166+
core_count = try(cpu_options.value.core_count, null)
167+
threads_per_core = try(cpu_options.value.threads_per_core, null)
168+
}
166169
}
167170

168171
monitoring {

0 commit comments

Comments
 (0)