Empty Tuple Error on Modules that are Disabled

Error: Invalid index
on <module path> in output "var_i_need.id":
<line number>:   value = resource_name.var_i_need[0].id
| resource_name.var_i_need is empty tuple

Going from 0.12.10 to 0.12.17 was probably not a great idea, but I read through the CHANGELOG and nothing stood out to me, so checking here to find out what I missed.

Previously, if a module was disabled, I could get away with referencing the index in an empty tuple.

Now, even if the module is disabled–I’m getting the above error (which makes sense, as the resource was never created, and the output shouldn’t resolve to anything).

With 0.12.17 it appears I have to write it as:

value = var.module_enabled ? resource_name.var_i_need[0].id : null

Can anyone point me to an issue or changelog that explains this change? I’d like to have a better understanding of what’s going on.


I think it’s this one https://github.com/hashicorp/terraform/pull/22846 from 0.12.11 https://github.com/hashicorp/terraform/blob/master/CHANGELOG.md#01211-october-17-2019