diff --git a/main.tf b/main.tf index 5627591e..77da2943 100644 --- a/main.tf +++ b/main.tf @@ -49,6 +49,14 @@ resource "google_compute_subnetwork" "subnetwork" { secondary_ip_range = "${var.secondary_ranges[lookup(var.subnets[count.index], "subnet_name")]}" } +data "google_compute_subnetwork" "created_subnets" { + count = "${length(var.subnets)}" + + name = "${lookup(var.subnets[count.index], "subnet_name")}" + region = "${lookup(var.subnets[count.index], "subnet_region")}" + project = "${var.project_id}" +} + /****************************************** Routes *****************************************/ diff --git a/outputs.tf b/outputs.tf index 270f7d8b..1e58047d 100644 --- a/outputs.tf +++ b/outputs.tf @@ -50,7 +50,7 @@ output "subnets_flow_logs" { } output "subnets_secondary_ranges" { - value = "${google_compute_subnetwork.subnetwork.*.secondary_ip_range}" + value = "${data.google_compute_subnetwork.created_subnets.*.secondary_ip_range}" description = "The secondary ranges associated with these subnets" }