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

Recursive loop expanding variables in included module #675

Closed
MrMickS opened this issue Apr 16, 2021 · 0 comments · Fixed by #677
Closed

Recursive loop expanding variables in included module #675

MrMickS opened this issue Apr 16, 2021 · 0 comments · Fixed by #677
Assignees
Labels
Projects

Comments

@MrMickS
Copy link

MrMickS commented Apr 16, 2021

When testing a module call which passes through the following input:

  filename = "${path.module}/${var.filename}"

It triggers an infinite loop when var.filename is used in a templatefile call inside the module.

The attached zip file contains a simple example to demonstrate the issue. recursive_loop_error.zip

Running Terrascan in debug mode on this gives the following when the infinite loop starts:

2021-04-16T14:29:30.379Z	debug	commons/resource.go:62	created resource config for resource 'example', file: '/src/recursive_loop_error/dummy/main.tf'
2021-04-16T14:29:30.379Z	debug	commons/variable-references.go:109	resolving variable ref "${templatefile(\n    var.filename,\n    {\n      foo = \"bar\"\n    }\n  )}" in parent module call
2021-04-16T14:29:30.379Z	debug	commons/variable-references.go:57	extracted variable name "filename" from reference "${templatefile(\n    var.filename,\n    {\n      foo = \"bar\"\n    }\n  )}"
2021-04-16T14:29:30.382Z	debug	commons/variable-references.go:155	resolved str variable ref: '${templatefile(
    var.filename,
    {
      foo = "bar"
    }
  )}', value: '${templatefile(
    ${path.module}/${var.filename},
    {
      foo = "bar"
    }
  )}'
2021-04-16T14:29:30.382Z	debug	commons/variable-references.go:109	resolving variable ref "${templatefile(\n    ${path.module}/${var.filename},\n    {\n      foo = \"bar\"\n    }\n  )}" in parent module call
2021-04-16T14:29:30.382Z	debug	commons/variable-references.go:57	extracted variable name "filename" from reference "${templatefile(\n    ${path.module}/${var.filename},\n    {\n      foo = \"bar\"\n    }\n  )}"
2021-04-16T14:29:30.386Z	debug	commons/variable-references.go:155	resolved str variable ref: '${templatefile(
    ${path.module}/${var.filename},
    {
      foo = "bar"
    }
  )}', value: '${templatefile(
    ${path.module}/${path.module}/${var.filename},
    {
      foo = "bar"
    }
  )}'
2021-04-16T14:29:30.387Z	debug	commons/variable-references.go:109	resolving variable ref "${templatefile(\n    ${path.module}/${path.module}/${var.filename},\n    {\n      foo = \"bar\"\n    }\n  )}" in parent module call
2021-04-16T14:29:30.388Z	debug	commons/variable-references.go:57	extracted variable name "filename" from reference "${templatefile(\n    ${path.module}/${path.module}/${var.filename},\n    {\n      foo = \"bar\"\n    }\n  )}"
2021-04-16T14:29:30.389Z	debug	commons/variable-references.go:155	resolved str variable ref: '${templatefile(
    ${path.module}/${path.module}/${var.filename},
    {
      foo = "bar"
    }
  )}', value: '${templatefile(
    ${path.module}/${path.module}/${path.module}/${var.filename},
    {
      foo = "bar"
    }
  )}'


If you need any more information please contact me.

Edited to sort out link to Zip file.

@patilpankaj212 patilpankaj212 self-assigned this Apr 19, 2021
@patilpankaj212 patilpankaj212 added this to To do in Main Board via automation Apr 19, 2021
@patilpankaj212 patilpankaj212 linked a pull request Apr 19, 2021 that will close this issue
@patilpankaj212 patilpankaj212 moved this from To do to Review in progress in Main Board Apr 19, 2021
Main Board automation moved this from Review in progress to Done Apr 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

Successfully merging a pull request may close this issue.

2 participants