Skip to content

Fix dynamic for_each error for archs#67

Open
wlynch wants to merge 1 commit intochainguard-dev:mainfrom
wlynch:arch-var
Open

Fix dynamic for_each error for archs#67
wlynch wants to merge 1 commit intochainguard-dev:mainfrom
wlynch:arch-var

Conversation

@wlynch
Copy link
Copy Markdown
Member

@wlynch wlynch commented Oct 15, 2025

Error: Invalid for_each argument

  on .terraform/modules/base/main.tf line 55, in resource "cosign_attest" "this":
  55:   for_each = var.skip_attest ? [] : local.archs
    ├────────────────
    │ local.archs is a set of dynamic, known only after apply
    │ var.skip_attest is false

We can't derive this easily from the build output, even though it's the right thing to do.

This isn't an optimal solution, but this moves the arch value to a var, which then requires that the archs must match the built archs else it will error on signing. I don't particularly like this, but I don't know how else we can do this within only terraform without trying to determin this based on computed dynamic outputs. :(

```
Error: Invalid for_each argument

  on .terraform/modules/base/main.tf line 55, in resource "cosign_attest" "this":
  55:   for_each = var.skip_attest ? [] : local.archs
    ├────────────────
    │ local.archs is a set of dynamic, known only after apply
    │ var.skip_attest is false
```

We can't derive this easily from the build output, even though it's the right thing to do.

This isn't an optimal solution, but this moves the arch value to a var, which then requires
that the archs must match the built archs else it will error on signing. I don't particularly
like this, but I don't know how else we can do this within only terraform without trying to determin
this based on computed dynamic outputs. :(
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.

1 participant