Skip to content

Commit 8717668

Browse files
author
Florencia Comuzzi
committed
dict conditional
1 parent 2b3ff13 commit 8717668

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

modules/private-k8s-cluster/main.tf

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ resource "google_container_node_pool" "gke_nodes" {
9797

9898
# Create jump host to access private k8s cluster
9999
resource "google_compute_address" "my_internal_ip_addr" {
100-
count = var.create_jump_host ? 1 : 0
100+
for_each = var.create_jump_host ? {test=1} : {}
101101
project = var.project_id
102102
address_type = "INTERNAL"
103103
region = var.region
@@ -108,7 +108,7 @@ resource "google_compute_address" "my_internal_ip_addr" {
108108
}
109109

110110
resource "google_compute_instance" "default" {
111-
count = var.create_jump_host ? 1 : 0
111+
for_each = var.create_jump_host ? {test=1} : {}
112112
project = var.project_id
113113
zone = "${var.region}-b"
114114
name = "jump-host"
@@ -129,7 +129,7 @@ resource "google_compute_instance" "default" {
129129

130130
## Create Firewall to access jump host via iap
131131
resource "google_compute_firewall" "rules" {
132-
count = var.create_jump_host ? 1 : 0
132+
for_each = var.create_jump_host ? {test=1} : {}
133133
project = var.project_id
134134
name = "allow-ssh"
135135
network = var.network_name
@@ -143,22 +143,22 @@ resource "google_compute_firewall" "rules" {
143143
}
144144

145145
resource "google_service_account" "jump_host" {
146-
count = var.create_jump_host ? 1 : 0
146+
for_each = var.create_jump_host ? {test=1} : {}
147147
account_id = "jump-host-sa-${random_string.identifier.result}"
148148
display_name = "Jump host service account"
149149
}
150150

151151
## Create IAP SSH permissions for your test instance
152152
resource "google_project_iam_member" "project" {
153-
count = var.create_jump_host ? 1 : 0
153+
for_each = var.create_jump_host ? {test=1} : {}
154154
project = var.project_id
155155
role = "roles/iap.tunnelResourceAccessor"
156156
member = "serviceAccount:${google_service_account.jump_host.email}"
157157
}
158158

159159
# create cloud router for nat gateway
160160
resource "google_compute_router" "router" {
161-
count = var.create_jump_host ? 1 : 0
161+
for_each = var.create_jump_host ? {test=1} : {}
162162
project = var.project_id
163163
name = "nat-router"
164164
network = var.network_name
@@ -167,7 +167,7 @@ resource "google_compute_router" "router" {
167167

168168
## Create Nat Gateway
169169
module "cloud-nat" {
170-
count = var.create_jump_host ? 1 : 0
170+
for_each = var.create_jump_host ? {test=1} : {}
171171
source = "terraform-google-modules/cloud-nat/google"
172172
version = "~> 1.2"
173173
project_id = var.project_id

0 commit comments

Comments
 (0)