Skip to content

Commit fe4cca7

Browse files
committed
Try another approach. I hate hcl
1 parent 33ef64e commit fe4cca7

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

modules/mysql/main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,10 @@ resource "google_sql_database_instance" "default" {
162162
allowed_consumer_projects = ip_configuration.value.psc_allowed_consumer_projects
163163

164164
dynamic "psc_auto_connections" {
165-
for_each = ip_configuration.value.psc_auto_connections
165+
for_each = lookup(ip_configuration.value, "psc_auto_connections", [])
166166
content {
167-
consumer_network = each.value.consumer_network
168-
consumer_service_project_id = each.value.consumer_service_project_id
167+
consumer_network = psc_auto_connections.value.consumer_network
168+
consumer_service_project_id = psc_auto_connections.value.consumer_service_project_id
169169
}
170170
}
171171
}

modules/mysql/read_replica.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,10 @@ resource "google_sql_database_instance" "replicas" {
9494
allowed_consumer_projects = ip_configuration.value.psc_allowed_consumer_projects
9595

9696
dynamic "psc_auto_connections" {
97-
for_each = ip_configuration.value.psc_auto_connections
97+
for_each = lookup(ip_configuration.value, "psc_auto_connections", [])
9898
content {
99-
consumer_network = each.value.consumer_network
100-
consumer_service_project_id = each.value.consumer_service_project_id
99+
consumer_network = psc_auto_connections.value.consumer_network
100+
consumer_service_project_id = psc_auto_connections.value.consumer_service_project_id
101101
}
102102
}
103103
}

modules/postgresql/main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,10 @@ resource "google_sql_database_instance" "default" {
147147
allowed_consumer_projects = ip_configuration.value.psc_allowed_consumer_projects
148148

149149
dynamic "psc_auto_connections" {
150-
for_each = ip_configuration.value.psc_auto_connections
150+
for_each = lookup(ip_configuration.value, "psc_auto_connections", [])
151151
content {
152-
consumer_network = each.value.consumer_network
153-
consumer_service_project_id = each.value.consumer_service_project_id
152+
consumer_network = psc_auto_connections.value.consumer_network
153+
consumer_service_project_id = psc_auto_connections.value.consumer_service_project_id
154154
}
155155
}
156156
}

modules/postgresql/read_replica.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ resource "google_sql_database_instance" "replicas" {
6969
allowed_consumer_projects = ip_configuration.value.psc_enabled ? ip_configuration.value.psc_allowed_consumer_projects : []
7070

7171
dynamic "psc_auto_connections" {
72-
for_each = ip_configuration.value.psc_auto_connections
72+
for_each = lookup(ip_configuration.value, "psc_auto_connections", [])
7373
content {
74-
consumer_network = each.value.consumer_network
75-
consumer_service_project_id = each.value.consumer_service_project_id
74+
consumer_network = psc_auto_connections.value.consumer_network
75+
consumer_service_project_id = psc_auto_connections.value.consumer_service_project_id
7676
}
7777
}
7878
}

0 commit comments

Comments
 (0)