I need multiple count conditions in a resource block. I am looping through a list to create resources based on the list but I also need to check if they are created in the correct environment. What I need is something like this : If the environment variable is test then do a loop on the length of table_maps_local
resource "google_monitoring_alert_policy" "tables_as_map" {
count = var.environment == "test" ? 1 : 0
count = length(local.table_maps_local)
I know we can not set count twice. Any hints on how to proceed on this would be appreciated. Thank you!
CodePudding user response:
You can just do that using one count
:
resource "google_monitoring_alert_policy" "tables_as_map" {
count = var.environment == "test" ? length(local.table_maps_local) : 0