I’m familiar with using for_each and count to conditionally create single resources and dynamic blocks. I’m wondering if there’s a way to apply a conditional to all of the resources in a specific .tf file?
The use case is that I’m writing a module for an azure linux VM. Most of the time, we’d just connect the VM to an existing subnet, but if we don’t want to for some reason (say, we’re doing e2e module testing, or just throwing something up there for a quick hackathon or PoC) I want to module to create the vnets/subnets/NIC/Bastion necessary.
I know I can just copy/paste the conditional for each of the resources, but that feels inelegant.
The only other option I can think of is writing a “vm networking” module specifically for these use cases, but that also feels like the wrong answer for some reason.
TIA