Skip to content

Commit c3d6536

Browse files
committed
get gke module to wait on network creation correctly
1 parent d969d86 commit c3d6536

File tree

1 file changed

+7
-2
lines changed
  • examples/private_zonal_with_networking

1 file changed

+7
-2
lines changed

examples/private_zonal_with_networking/main.tf

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ module "gcp-network" {
4444
}
4545

4646
data "google_compute_subnetwork" "subnetwork" {
47-
name = module.gcp-network.subnets_names[0]
47+
name = var.subnetwork
4848
project = var.project_id
4949
region = var.region
5050
depends_on = [module.gcp-network]
@@ -57,7 +57,12 @@ module "gke" {
5757
regional = false
5858
region = var.region
5959
zones = slice(var.zones, 0, 1)
60-
network = data.google_compute_subnetwork.subnetwork.network
60+
61+
// This craziness gets a plain network name from the reference link which is the
62+
// only way to force cluster creation to wait on network creation without a
63+
// depends_on link. Tests use terraform 0.12.6, which does not have regex or regexall
64+
network = reverse(split("/", data.google_compute_subnetwork.subnetwork.network))[0]
65+
6166
subnetwork = data.google_compute_subnetwork.subnetwork.name
6267
ip_range_pods = var.ip_range_pods_name
6368
ip_range_services = var.ip_range_services_name

0 commit comments

Comments
 (0)