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

Terraform interpolation should only evaluate one branch of a condition #34366

Closed
giner opened this issue Dec 6, 2023 · 2 comments
Closed

Terraform interpolation should only evaluate one branch of a condition #34366

giner opened this issue Dec 6, 2023 · 2 comments
Labels
bug duplicate issue closed because another issue already tracks this problem

Comments

@giner
Copy link

giner commented Dec 6, 2023

Terraform Version

Terraform v1.5.7

Terraform Configuration Files

locals {
  map = {}

  res1 = true || local.map["nonexist"]
  res2 = false && local.map["nonexist"]
}

Debug Output

│ Error: Invalid index
│ 
│   on test.tf line 4, in locals:4:   res1 = true || local.map["nonexist"]
│     ├────────────────
│     │ local.map is object with no attributes
│ 
│ The given key does not identify an element in this collection value.
╵
╷
│ Error: Invalid index
│ 
│   on test.tf line 5, in locals:5:   res2 = false && local.map["nonexist"]
│     ├────────────────
│     │ local.map is object with no attributes
│ 
│ The given key does not identify an element in this collection value.

Expected Behavior

Only one branch of a condition should be evaluated

Actual Behavior

Both branches of a condition are evaluated

Steps to Reproduce

terraform apply

Additional Context

No response

References

#15605

@giner giner added bug new new issue not yet triaged labels Dec 6, 2023
@jbardin
Copy link
Member

jbardin commented Dec 6, 2023

Duplicate of #24128

@jbardin jbardin marked this as a duplicate of #24128 Dec 6, 2023
@jbardin jbardin closed this as completed Dec 6, 2023
@crw crw added duplicate issue closed because another issue already tracks this problem and removed new new issue not yet triaged labels Dec 6, 2023
Copy link
Contributor

github-actions bot commented Jan 6, 2024

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug duplicate issue closed because another issue already tracks this problem
Projects
None yet
Development

No branches or pull requests

3 participants