-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(misconf): properly expand dynamic blocks #7612
Conversation
Signed-off-by: nikpivkin <nikita.pivkin@smartforce.io>
Signed-off-by: nikpivkin <nikita.pivkin@smartforce.io>
@@ -567,7 +567,7 @@ resource "something" "else" { | |||
for_each = toset(["true"]) | |||
|
|||
content { | |||
ok = each.value | |||
ok = blah.value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For reviewers: this test should not have run successfully because dynamic blocks do not create an each
object.
Signed-off-by: nikpivkin <nikita.pivkin@smartforce.io>
pkg/iac/terraform/block.go
Outdated
if forEachVal.IsNull() || !forEachVal.IsKnown() { | ||
return cty.NilVal, errors.New("cannot use a null or unknown value in for_each") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my coverage this seems to be untested so I decided to investigate. Would this ever be reached since we already check for !forEachVal.CanIterateElements()
prior to this? If you have a sample input, it'd be nice to understand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this check is unreachable, I removed it. 4d3de2a
Signed-off-by: nikpivkin <nikita.pivkin@smartforce.io>
It looks like the issue is still there (0.57.0):
I'm using the same module as before (https://github.com/Azure/terraform-azurerm-avm-res-compute-virtualmachine/blob/main/main.backup.tf) |
I'm seeing similar issues still with 0.57.0:
|
Hi @stewartcampbell ! You are using blocks of data that cannot be analyzed statically in some cases #7731 (comment) |
Description
This PR separates the logic for expanding dynamic blocks from expanding the
for-each
meta argument.Related issues
Checklist