Skip to content

fix(azure/aks): make ACR attach plan-stable for greenfield applies#448

Merged
jcastiarena merged 2 commits into
mainfrom
fix/azure-aks-acr-attach-greenfield
Jul 24, 2026
Merged

fix(azure/aks): make ACR attach plan-stable for greenfield applies#448
jcastiarena merged 2 commits into
mainfrom
fix/azure-aks-acr-attach-greenfield

Conversation

@jcastiarena

@jcastiarena jcastiarena commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

What

Fix a greenfield single-apply failure in the Azure aks module. attached_acr_id_map gated on var.acr_id != null, whose condition is unknown at plan time when the ACR is created in the same run — leaving the for_each key set unknown and failing the plan with Invalid for_each argument.

Change

Add an optional attach_acr bool (default null) and gate on it, falling back to the legacy behaviour when unset:

attached_acr_id_map = (var.attach_acr != null ? var.attach_acr : var.acr_id != null) ? { acr = var.acr_id } : {}

Backward compatible

The default (null) reproduces the current behaviour exactly — no existing consumer changes:

attach_acr acr_id Result
null (default) known, non-null attach (as today)
null (default) known, null / omitted no attach (as today)
null (default) unknown at plan fails (same as today — no regression)
true unknown at plan attach, plan-stable (the greenfield fix)
false any no attach

Greenfield single-apply is fixed by opting in with attach_acr = true; setting false force-disables.

Verification

  • pre-commit run on the changed files: OpenTofu fmt / validate / tofu test → Passed
  • commitlint → Passed
  • README regenerated with terraform-docs

@jcastiarena
jcastiarena force-pushed the fix/azure-aks-acr-attach-greenfield branch from f7b13e7 to 808b60d Compare July 22, 2026 21:01
@jcastiarena jcastiarena changed the title fix(azure/aks): allow ACR attach when acr_id is known after apply fix(azure/aks)!: gate ACR attach on static attach_acr flag Jul 22, 2026
@jcastiarena
jcastiarena force-pushed the fix/azure-aks-acr-attach-greenfield branch from 808b60d to 442bc11 Compare July 24, 2026 13:32
@jcastiarena jcastiarena changed the title fix(azure/aks)!: gate ACR attach on static attach_acr flag fix(azure/aks): make ACR attach plan-stable for greenfield applies Jul 24, 2026
attached_acr_id_map gated on `var.acr_id != null`, whose condition is
unknown at plan time when the ACR is created in the same run, leaving the
for_each key set unknown and failing the plan with "Invalid for_each
argument".

Add an optional `attach_acr` bool (default null). When null it preserves
the legacy "attach iff acr_id is non-null" behaviour, so existing
consumers are unaffected. Setting attach_acr=true fixes the for_each key
set at plan time even when acr_id is only known after apply, enabling a
single-apply greenfield; false force-disables.
@jcastiarena
jcastiarena force-pushed the fix/azure-aks-acr-attach-greenfield branch from 442bc11 to f43ddfb Compare July 24, 2026 16:14
@jcastiarena
jcastiarena merged commit 92b29f8 into main Jul 24, 2026
79 of 82 checks passed
@jcastiarena
jcastiarena deleted the fix/azure-aks-acr-attach-greenfield branch July 24, 2026 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants