Skip to content
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

Local expansion recursive infinite loop #690

Closed
MrMickS opened this issue Apr 23, 2021 · 3 comments · Fixed by #700
Closed

Local expansion recursive infinite loop #690

MrMickS opened this issue Apr 23, 2021 · 3 comments · Fixed by #700
Assignees

Comments

@MrMickS
Copy link

MrMickS commented Apr 23, 2021

Hi,

I've found another infinite loop based using modules. If you have a local value (local.foo) in the root that is the same as a local value (local.foo) in the module and have the one in the module expand out using the one from the root it generates a recursive loop.

2021-04-23T12:18:12.078Z	debug	commons/local-references.go:56	extracted local value name "foo" from reference "${local.foo}"
2021-04-23T12:18:12.079Z	debug	commons/local-references.go:92	resolved str local value ref: '${local.foo}', value: '${lower(var.bar != null ? var.bar : var.foo)}'
2021-04-23T12:18:12.079Z	debug	commons/variable-references.go:109	resolving variable ref "${lower(var.bar != null ? var.bar : var.foo)}" in parent module call
2021-04-23T12:18:12.079Z	debug	commons/variable-references.go:57	extracted variable name "bar" from reference "${lower(var.bar != null ? var.bar : var.foo)}"
2021-04-23T12:18:12.090Z	debug	commons/variable-references.go:155	resolved str variable ref: '${lower(var.bar != null ? var.bar : var.foo)}', value: '${lower(${local.foo} != null ? var.bar : var.foo)}'
2021-04-23T12:18:12.091Z	debug	commons/local-references.go:56	extracted local value name "foo" from reference "${lower(${local.foo} != null ? var.bar : var.foo)}"
2021-04-23T12:18:12.099Z	debug	commons/local-references.go:92	resolved str local value ref: '${lower(${local.foo} != null ? var.bar : var.foo)}', value: '${lower(${lower(var.bar != null ? var.bar : var.foo)} != null ? var.bar : var.foo)}'
2021-04-23T12:18:12.100Z	debug	commons/variable-references.go:109	resolving variable ref "${lower(${lower(var.bar != null ? var.bar : var.foo)} != null ? var.bar : var.foo)}" in parent module call
2021-04-23T12:18:12.100Z	debug	commons/variable-references.go:57	extracted variable name "bar" from reference "${lower(${lower(var.bar != null ? var.bar : var.foo)} != null ? var.bar : var.foo)}"
2021-04-23T12:18:12.134Z	debug	commons/variable-references.go:155	resolved str variable ref: '${lower(${lower(var.bar != null ? var.bar : var.foo)} != null ? var.bar : var.foo)}', value: '${lower(${lower(${local.foo} != null ? var.bar : var.foo)} != null ? var.bar : var.foo)}'
2021-04-23T12:18:12.134Z	debug	commons/local-references.go:56	extracted local value name "foo" from reference "${lower(${lower(${local.foo} != null ? var.bar : var.foo)} != null ? var.bar : var.foo)}"

We can work around by renaming locals but that's for the one's we know about.

I've attached a zip file with Terraform that reproduces the error.
locals_loop_error.zip

@kanchwala-yusuf
Copy link
Contributor

@MrMickS, thank you for reporting this and also uploading a example. This indeed is causing terrascan to go into an infinite loop.

@MrMickS
Copy link
Author

MrMickS commented Apr 24, 2021

@MrMickS, thank you for reporting this and also uploading a example. This indeed is causing terrascan to go into an infinite loop.

Its always better with an example, I've been on the receiving error of issues reported with only vague descriptions. It wasn't happening all the time for us so I wanted to understand what the trigger was. Having identified it we can work around the problem internally.

@kanchwala-yusuf
Copy link
Contributor

I will let @patilpankaj212 , take a stab at this! He has been nailing some these issues recently!

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 a pull request may close this issue.

3 participants