Loading...
Loading...
### Terraform Version ``` Terraform v1.0.11 on darwin_amd64 + provider registry.terraform.io/hashicorp/null v3.1.0 ``` ### Terraform Configuration Files https://github.com/notfromstatefarm/tf-module-var-issue ### Debug Output [Output of terraform plan when it tries to delete the resources](https://gist.github.com/notfromstatefarm/2dffd4432bbd02866aa9c6d2d848917a) ### Expected Behavior When adding a new, unreferenced key/value to a subset of objects inside of a map, it shouldn't change anything (or should show an error for inconsistent types?) ### Actual Behavior Terraform plans to delete the resource using the map in a conditional for_each if the key is not added to *all* objects ### Steps to Reproduce 1. Apply as is 2. Uncomment one of the bye parameters in test.tf 3. Apply will now show it deleting the resource inside the module that uses a for_each with an if statement, but not the unconditional for_each, nor the resource outside of the module. If both byes are uncommented, everything is normal. Also listed in repo README ### Additional Context I noticed that when there's a map of objects with just a single field and you add another field to one of the objects you receive the following error: `The given value is not suitable for child module variable "tests" defined at testmodule/variables.tf:1,1-17: all map elements must have the same type.` Example of this additional context: No error: ``` locals { tests = { ab = { enabled = true } cd = { enabled = true } } } ``` Has error: ``` locals { tests = { ab = { enabled = true asdf = 123 } cd = { enabled = true } } } ``` I assume this error should be showing in this issue's scenario too and for some reason it isn't when there's more than two fields.. and even more strangely is only breaking if statements that aren't even using the additional field. ### Important things to note 1. for_each **not using if** and for_each **outside of the module** works fine 2. setting conditional to false doesn't matter, both true and false result in resource being deleted 3. There are no errors, it is simply planning to delete the resource ### References None that I could find
Click on a version to see all relevant bugs
Terraform Integration
Learn more about where this data comes from
Bug Scrub Advisor
Streamline upgrades with automated vendor bug scrubs
BugZero Enterprise
Wish you caught this bug sooner? Get proactive today.