I need to bind depends_on with multiple resource base on the condition.
I am using for_each as creating multiple resource for same type at resource level.
Now, I want to reference other resources using depends_on property based on on the other property value like below e.g.
depends_on = each.value.backend_address_pool? [azurerm_lb.load_balancer, azurerm_lb_backend_address_pool.pool_address] :[ azurerm_lb.load_balancer ]
but Terraform won’t allow that, as it requires a static list. I’ve tried:
- Checking dependent property null or not.
- Using concat function to generate list.
How can I express this dependency?