diff --git a/README.md b/README.md index 6d70bb087e..5b19f0ffe2 100644 --- a/README.md +++ b/README.md @@ -260,7 +260,7 @@ The node_pools variable takes the following parameters: | max_unavailable | The number of nodes that can be simultaneously unavailable during an upgrade. Increasing max_unavailable raises the number of nodes that can be upgraded in parallel. Can be set to 0 or greater. | 0 | Optional | | min_count | Minimum number of nodes in the NodePool. Must be >=0 and <= max_count. Should be used when autoscaling is true | 1 | Optional | | name | The name of the node pool | | Required | -| node_count | The number of nodes in the nodepool when autoscaling is false. Otherwise defaults to 1. Only valid for non-autoscaling clusters | | Required | +| node_count | The number of nodes in the nodepool when autoscaling is false. Otherwise defaults to 1. Only valid for non-autoscaling clusers | | Required | | node_locations | The list of zones in which the cluster's nodes are located. Nodes must be in the region of their regional cluster or in the same region as their cluster's zone for zonal clusters. Defaults to cluster level node locations if nothing is specified | " " | Optional | | node_metadata | Options to expose the node metadata to the workload running on the node | | Optional | | preemptible | A boolean that represents whether or not the underlying node VMs are preemptible | false | Optional | diff --git a/examples/deploy_service/main.tf b/examples/deploy_service/main.tf index 5a659b79bc..a41361489a 100644 --- a/examples/deploy_service/main.tf +++ b/examples/deploy_service/main.tf @@ -27,15 +27,14 @@ provider "kubernetes" { } module "gke" { - source = "../../" - project_id = var.project_id - name = "${local.cluster_type}-cluster${var.cluster_name_suffix}" - region = var.region - network = var.network - subnetwork = var.subnetwork - - ip_range_pods = var.ip_range_pods - ip_range_services = var.ip_range_services + source = "../../" + project_id = var.project_id + name = "${local.cluster_type}-cluster${var.cluster_name_suffix}" + region = var.region + network = google_compute_network.main.name + subnetwork = google_compute_subnetwork.main.name + ip_range_pods = google_compute_subnetwork.main.secondary_ip_range[0].range_name + ip_range_services = google_compute_subnetwork.main.secondary_ip_range[1].range_name create_service_account = false service_account = var.compute_engine_service_account } diff --git a/test/fixtures/node_pool/network.tf b/examples/deploy_service/network.tf similarity index 96% rename from test/fixtures/node_pool/network.tf rename to examples/deploy_service/network.tf index 13e6e76076..0eba769d6f 100644 --- a/test/fixtures/node_pool/network.tf +++ b/examples/deploy_service/network.tf @@ -20,13 +20,10 @@ resource "random_string" "suffix" { upper = false } -provider "google" { - project = var.project_ids[0] -} - resource "google_compute_network" "main" { name = "cft-gke-test-${random_string.suffix.result}" auto_create_subnetworks = false + project = var.project_id } resource "google_compute_subnetwork" "main" { diff --git a/examples/deploy_service/variables.tf b/examples/deploy_service/variables.tf index dd5475f238..e7b26c2475 100644 --- a/examples/deploy_service/variables.tf +++ b/examples/deploy_service/variables.tf @@ -27,22 +27,6 @@ variable "region" { description = "The region to host the cluster in" } -variable "network" { - description = "The VPC network to host the cluster in" -} - -variable "subnetwork" { - description = "The subnetwork to host the cluster in" -} - -variable "ip_range_pods" { - description = "The secondary ip range to use for pods" -} - -variable "ip_range_services" { - description = "The secondary ip range to use for services" -} - variable "compute_engine_service_account" { description = "Service account to associate to the nodes in the cluster" } diff --git a/examples/disable_client_cert/main.tf b/examples/disable_client_cert/main.tf index 8696ffc0de..72c6fab158 100644 --- a/examples/disable_client_cert/main.tf +++ b/examples/disable_client_cert/main.tf @@ -29,14 +29,15 @@ provider "kubernetes" { module "gke" { source = "../../" - project_id = var.project_id - name = "${local.cluster_type}-cluster${var.cluster_name_suffix}" - region = var.region - network = var.network + project_id = var.project_id + name = "${local.cluster_type}-cluster${var.cluster_name_suffix}" + region = var.region + network = google_compute_network.main.name + network_project_id = var.network_project_id - subnetwork = var.subnetwork - ip_range_pods = var.ip_range_pods - ip_range_services = var.ip_range_services + subnetwork = google_compute_subnetwork.main.name + ip_range_pods = google_compute_subnetwork.main.secondary_ip_range[0].range_name + ip_range_services = google_compute_subnetwork.main.secondary_ip_range[1].range_name create_service_account = false service_account = var.compute_engine_service_account issue_client_certificate = false diff --git a/test/fixtures/shared_vpc/network.tf b/examples/disable_client_cert/network.tf similarity index 88% rename from test/fixtures/shared_vpc/network.tf rename to examples/disable_client_cert/network.tf index 94bb29e63c..0eba769d6f 100644 --- a/test/fixtures/shared_vpc/network.tf +++ b/examples/disable_client_cert/network.tf @@ -20,19 +20,16 @@ resource "random_string" "suffix" { upper = false } -provider "google" { - project = var.project_ids[0] -} - resource "google_compute_network" "main" { name = "cft-gke-test-${random_string.suffix.result}" auto_create_subnetworks = false + project = var.project_id } resource "google_compute_subnetwork" "main" { name = "cft-gke-test-${random_string.suffix.result}" ip_cidr_range = "10.0.0.0/17" - region = var.region + region = "europe-west4" network = google_compute_network.main.self_link secondary_ip_range { @@ -44,5 +41,9 @@ resource "google_compute_subnetwork" "main" { range_name = "cft-gke-test-services-${random_string.suffix.result}" ip_cidr_range = "192.168.64.0/18" } -} + secondary_ip_range { + range_name = "test" + ip_cidr_range = "172.16.0.0/18" + } +} diff --git a/examples/disable_client_cert/variables.tf b/examples/disable_client_cert/variables.tf index 6f1bc61945..bb5ac836ba 100644 --- a/examples/disable_client_cert/variables.tf +++ b/examples/disable_client_cert/variables.tf @@ -27,26 +27,10 @@ variable "region" { description = "The region to host the cluster in" } -variable "network" { - description = "The VPC network to host the cluster in" -} - variable "network_project_id" { description = "The GCP project housing the VPC network to host the cluster in" } -variable "subnetwork" { - description = "The subnetwork to host the cluster in" -} - -variable "ip_range_pods" { - description = "The secondary ip range to use for pods" -} - -variable "ip_range_services" { - description = "The secondary ip range to use for services" -} - variable "compute_engine_service_account" { description = "Service account to associate to the nodes in the cluster" } diff --git a/examples/node_pool/README.md b/examples/node_pool/README.md index 48d27a1e9c..85a116dd29 100644 --- a/examples/node_pool/README.md +++ b/examples/node_pool/README.md @@ -10,12 +10,8 @@ This example illustrates how to create a cluster with multiple custom node-pool | cluster\_autoscaling | Cluster autoscaling configuration. See [more details](https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1beta1/projects.locations.clusters#clusterautoscaling) |
object({
enabled = bool
autoscaling_profile = string
min_cpu_cores = number
max_cpu_cores = number
min_memory_gb = number
max_memory_gb = number
gpu_resources = list(object({
resource_type = string
minimum = number
maximum = number
}))
})
|
{
"autoscaling_profile": "BALANCED",
"enabled": false,
"gpu_resources": [],
"max_cpu_cores": 0,
"max_memory_gb": 0,
"min_cpu_cores": 0,
"min_memory_gb": 0
}
| no | | cluster\_name\_suffix | A suffix to append to the default cluster name | `string` | `""` | no | | compute\_engine\_service\_account | Service account to associate to the nodes in the cluster | `any` | n/a | yes | -| ip\_range\_pods | The secondary ip range to use for pods | `any` | n/a | yes | -| ip\_range\_services | The secondary ip range to use for services | `any` | n/a | yes | -| network | The VPC network to host the cluster in | `any` | n/a | yes | | project\_id | The project ID to host the cluster in | `any` | n/a | yes | | region | The region to host the cluster in | `any` | n/a | yes | -| subnetwork | The subnetwork to host the cluster in | `any` | n/a | yes | | zones | The zone to host the cluster in (required if is a zonal cluster) | `list(string)` | n/a | yes | ## Outputs diff --git a/examples/node_pool/main.tf b/examples/node_pool/main.tf index c6159e18eb..35dad311be 100644 --- a/examples/node_pool/main.tf +++ b/examples/node_pool/main.tf @@ -32,10 +32,10 @@ module "gke" { name = "${local.cluster_type}-cluster${var.cluster_name_suffix}" region = var.region zones = var.zones - network = var.network - subnetwork = var.subnetwork - ip_range_pods = var.ip_range_pods - ip_range_services = var.ip_range_services + network = google_compute_network.main.name + subnetwork = google_compute_subnetwork.main.name + ip_range_pods = google_compute_subnetwork.main.secondary_ip_range[0].range_name + ip_range_services = google_compute_subnetwork.main.secondary_ip_range[1].range_name create_service_account = false remove_default_node_pool = true disable_legacy_metadata_endpoints = false diff --git a/examples/node_pool/network.tf b/examples/node_pool/network.tf new file mode 100644 index 0000000000..0eba769d6f --- /dev/null +++ b/examples/node_pool/network.tf @@ -0,0 +1,49 @@ +/** + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +resource "random_string" "suffix" { + length = 4 + special = false + upper = false +} + +resource "google_compute_network" "main" { + name = "cft-gke-test-${random_string.suffix.result}" + auto_create_subnetworks = false + project = var.project_id +} + +resource "google_compute_subnetwork" "main" { + name = "cft-gke-test-${random_string.suffix.result}" + ip_cidr_range = "10.0.0.0/17" + region = "europe-west4" + network = google_compute_network.main.self_link + + secondary_ip_range { + range_name = "cft-gke-test-pods-${random_string.suffix.result}" + ip_cidr_range = "192.168.0.0/18" + } + + secondary_ip_range { + range_name = "cft-gke-test-services-${random_string.suffix.result}" + ip_cidr_range = "192.168.64.0/18" + } + + secondary_ip_range { + range_name = "test" + ip_cidr_range = "172.16.0.0/18" + } +} diff --git a/examples/node_pool/outputs.tf b/examples/node_pool/outputs.tf index 01a13147c2..0d770aa809 100644 --- a/examples/node_pool/outputs.tf +++ b/examples/node_pool/outputs.tf @@ -32,4 +32,3 @@ output "service_account" { description = "The default service account used for running nodes." value = module.gke.service_account } - diff --git a/examples/node_pool/variables.tf b/examples/node_pool/variables.tf index ac76aa1a05..148dc707af 100644 --- a/examples/node_pool/variables.tf +++ b/examples/node_pool/variables.tf @@ -32,22 +32,6 @@ variable "zones" { description = "The zone to host the cluster in (required if is a zonal cluster)" } -variable "network" { - description = "The VPC network to host the cluster in" -} - -variable "subnetwork" { - description = "The subnetwork to host the cluster in" -} - -variable "ip_range_pods" { - description = "The secondary ip range to use for pods" -} - -variable "ip_range_services" { - description = "The secondary ip range to use for services" -} - variable "compute_engine_service_account" { description = "Service account to associate to the nodes in the cluster" } diff --git a/examples/node_pool_update_variant/README.md b/examples/node_pool_update_variant/README.md index 15a8967569..88a53dc4a3 100644 --- a/examples/node_pool_update_variant/README.md +++ b/examples/node_pool_update_variant/README.md @@ -9,12 +9,8 @@ This example illustrates how to create a cluster with multiple custom node-pool |------|-------------|------|---------|:--------:| | cluster\_name\_suffix | A suffix to append to the default cluster name | `string` | `""` | no | | compute\_engine\_service\_account | Service account to associate to the nodes in the cluster | `any` | n/a | yes | -| ip\_range\_pods | The secondary ip range to use for pods | `any` | n/a | yes | -| ip\_range\_services | The secondary ip range to use for services | `any` | n/a | yes | -| network | The VPC network to host the cluster in | `any` | n/a | yes | | project\_id | The project ID to host the cluster in | `any` | n/a | yes | | region | The region to host the cluster in | `any` | n/a | yes | -| subnetwork | The subnetwork to host the cluster in | `any` | n/a | yes | | zones | The zone to host the cluster in (required if is a zonal cluster) | `list(string)` | n/a | yes | ## Outputs diff --git a/examples/node_pool_update_variant/main.tf b/examples/node_pool_update_variant/main.tf index 7fd842f7a0..dc95f55941 100644 --- a/examples/node_pool_update_variant/main.tf +++ b/examples/node_pool_update_variant/main.tf @@ -18,12 +18,6 @@ locals { cluster_type = "node-pool-update-variant" } -data "google_compute_subnetwork" "subnetwork" { - name = var.subnetwork - project = var.project_id - region = var.region -} - data "google_client_config" "default" {} provider "kubernetes" { @@ -39,10 +33,10 @@ module "gke" { regional = false region = var.region zones = var.zones - network = var.network - subnetwork = var.subnetwork - ip_range_pods = var.ip_range_pods - ip_range_services = var.ip_range_services + network = google_compute_network.main.name + subnetwork = google_compute_subnetwork.main.name + ip_range_pods = google_compute_subnetwork.main.secondary_ip_range[0].range_name + ip_range_services = google_compute_subnetwork.main.secondary_ip_range[1].range_name create_service_account = false service_account = var.compute_engine_service_account enable_private_endpoint = true @@ -51,7 +45,7 @@ module "gke" { master_authorized_networks = [ { - cidr_block = data.google_compute_subnetwork.subnetwork.ip_cidr_range + cidr_block = google_compute_subnetwork.main.ip_cidr_range display_name = "VPC" }, ] diff --git a/test/fixtures/simple_regional_with_kubeconfig/network.tf b/examples/node_pool_update_variant/network.tf similarity index 96% rename from test/fixtures/simple_regional_with_kubeconfig/network.tf rename to examples/node_pool_update_variant/network.tf index acb91a126b..fd3494411b 100644 --- a/test/fixtures/simple_regional_with_kubeconfig/network.tf +++ b/examples/node_pool_update_variant/network.tf @@ -20,13 +20,10 @@ resource "random_string" "suffix" { upper = false } -provider "google" { - project = var.project_ids[0] -} - resource "google_compute_network" "main" { name = "cft-gke-test-${random_string.suffix.result}" auto_create_subnetworks = false + project = var.project_id } resource "google_compute_subnetwork" "main" { diff --git a/examples/node_pool_update_variant/test_outputs.tf b/examples/node_pool_update_variant/test_outputs.tf index e64c40e477..27d0f80bc3 100644 --- a/examples/node_pool_update_variant/test_outputs.tf +++ b/examples/node_pool_update_variant/test_outputs.tf @@ -31,11 +31,11 @@ output "cluster_name" { } output "network" { - value = var.network + value = google_compute_network.main.name } output "subnetwork" { - value = var.subnetwork + value = google_compute_subnetwork.main.name } output "location" { @@ -44,12 +44,12 @@ output "location" { output "ip_range_pods" { description = "The secondary IP range used for pods" - value = var.ip_range_pods + value = google_compute_subnetwork.main.secondary_ip_range[0].range_name } output "ip_range_services" { description = "The secondary IP range used for services" - value = var.ip_range_services + value = google_compute_subnetwork.main.secondary_ip_range[1].range_name } output "zones" { diff --git a/examples/node_pool_update_variant/variables.tf b/examples/node_pool_update_variant/variables.tf index 485ac1ff3b..cab0cdc60f 100644 --- a/examples/node_pool_update_variant/variables.tf +++ b/examples/node_pool_update_variant/variables.tf @@ -32,22 +32,6 @@ variable "zones" { description = "The zone to host the cluster in (required if is a zonal cluster)" } -variable "network" { - description = "The VPC network to host the cluster in" -} - -variable "subnetwork" { - description = "The subnetwork to host the cluster in" -} - -variable "ip_range_pods" { - description = "The secondary ip range to use for pods" -} - -variable "ip_range_services" { - description = "The secondary ip range to use for services" -} - variable "compute_engine_service_account" { description = "Service account to associate to the nodes in the cluster" } diff --git a/examples/node_pool_update_variant_beta/README.md b/examples/node_pool_update_variant_beta/README.md index 6699d2e400..ed3b8710f6 100644 --- a/examples/node_pool_update_variant_beta/README.md +++ b/examples/node_pool_update_variant_beta/README.md @@ -10,12 +10,8 @@ This example illustrates how to create a cluster with multiple custom node-pool | cluster\_name\_suffix | A suffix to append to the default cluster name | `string` | `""` | no | | compute\_engine\_service\_account | Service account to associate to the nodes in the cluster | `any` | n/a | yes | | credentials\_path | The path to the GCP credentials JSON file | `any` | n/a | yes | -| ip\_range\_pods | The secondary ip range to use for pods | `any` | n/a | yes | -| ip\_range\_services | The secondary ip range to use for services | `any` | n/a | yes | -| network | The VPC network to host the cluster in | `any` | n/a | yes | | project\_id | The project ID to host the cluster in | `any` | n/a | yes | | region | The region to host the cluster in | `any` | n/a | yes | -| subnetwork | The subnetwork to host the cluster in | `any` | n/a | yes | | zones | The zone to host the cluster in (required if is a zonal cluster) | `list(string)` | n/a | yes | ## Outputs diff --git a/examples/node_pool_update_variant_beta/main.tf b/examples/node_pool_update_variant_beta/main.tf index b9710fca15..ea0d36618c 100644 --- a/examples/node_pool_update_variant_beta/main.tf +++ b/examples/node_pool_update_variant_beta/main.tf @@ -23,12 +23,6 @@ provider "google-beta" { region = var.region } -data "google_compute_subnetwork" "subnetwork" { - name = var.subnetwork - project = var.project_id - region = var.region -} - data "google_client_config" "default" {} provider "kubernetes" { @@ -44,10 +38,10 @@ module "gke" { regional = false region = var.region zones = var.zones - network = var.network - subnetwork = var.subnetwork - ip_range_pods = var.ip_range_pods - ip_range_services = var.ip_range_services + network = google_compute_network.main.name + subnetwork = google_compute_subnetwork.main.name + ip_range_pods = google_compute_subnetwork.main.secondary_ip_range[0].range_name + ip_range_services = google_compute_subnetwork.main.secondary_ip_range[1].range_name create_service_account = false service_account = var.compute_engine_service_account enable_private_endpoint = true @@ -56,7 +50,7 @@ module "gke" { master_authorized_networks = [ { - cidr_block = data.google_compute_subnetwork.subnetwork.ip_cidr_range + cidr_block = google_compute_subnetwork.main.ip_cidr_range display_name = "VPC" }, ] diff --git a/test/fixtures/simple_zonal_with_asm/network.tf b/examples/node_pool_update_variant_beta/network.tf similarity index 96% rename from test/fixtures/simple_zonal_with_asm/network.tf rename to examples/node_pool_update_variant_beta/network.tf index 0b538b4b58..fd3494411b 100644 --- a/test/fixtures/simple_zonal_with_asm/network.tf +++ b/examples/node_pool_update_variant_beta/network.tf @@ -20,13 +20,10 @@ resource "random_string" "suffix" { upper = false } -provider "google" { - project = var.project_ids[2] -} - resource "google_compute_network" "main" { name = "cft-gke-test-${random_string.suffix.result}" auto_create_subnetworks = false + project = var.project_id } resource "google_compute_subnetwork" "main" { diff --git a/examples/node_pool_update_variant_beta/test_outputs.tf b/examples/node_pool_update_variant_beta/test_outputs.tf index e64c40e477..27d0f80bc3 100644 --- a/examples/node_pool_update_variant_beta/test_outputs.tf +++ b/examples/node_pool_update_variant_beta/test_outputs.tf @@ -31,11 +31,11 @@ output "cluster_name" { } output "network" { - value = var.network + value = google_compute_network.main.name } output "subnetwork" { - value = var.subnetwork + value = google_compute_subnetwork.main.name } output "location" { @@ -44,12 +44,12 @@ output "location" { output "ip_range_pods" { description = "The secondary IP range used for pods" - value = var.ip_range_pods + value = google_compute_subnetwork.main.secondary_ip_range[0].range_name } output "ip_range_services" { description = "The secondary IP range used for services" - value = var.ip_range_services + value = google_compute_subnetwork.main.secondary_ip_range[1].range_name } output "zones" { diff --git a/examples/node_pool_update_variant_beta/variables.tf b/examples/node_pool_update_variant_beta/variables.tf index a1377c4dd2..83dbb2be81 100644 --- a/examples/node_pool_update_variant_beta/variables.tf +++ b/examples/node_pool_update_variant_beta/variables.tf @@ -36,22 +36,6 @@ variable "zones" { description = "The zone to host the cluster in (required if is a zonal cluster)" } -variable "network" { - description = "The VPC network to host the cluster in" -} - -variable "subnetwork" { - description = "The subnetwork to host the cluster in" -} - -variable "ip_range_pods" { - description = "The secondary ip range to use for pods" -} - -variable "ip_range_services" { - description = "The secondary ip range to use for services" -} - variable "compute_engine_service_account" { description = "Service account to associate to the nodes in the cluster" } diff --git a/examples/node_pool_update_variant_public_beta/README.md b/examples/node_pool_update_variant_public_beta/README.md index 6699d2e400..ed3b8710f6 100644 --- a/examples/node_pool_update_variant_public_beta/README.md +++ b/examples/node_pool_update_variant_public_beta/README.md @@ -10,12 +10,8 @@ This example illustrates how to create a cluster with multiple custom node-pool | cluster\_name\_suffix | A suffix to append to the default cluster name | `string` | `""` | no | | compute\_engine\_service\_account | Service account to associate to the nodes in the cluster | `any` | n/a | yes | | credentials\_path | The path to the GCP credentials JSON file | `any` | n/a | yes | -| ip\_range\_pods | The secondary ip range to use for pods | `any` | n/a | yes | -| ip\_range\_services | The secondary ip range to use for services | `any` | n/a | yes | -| network | The VPC network to host the cluster in | `any` | n/a | yes | | project\_id | The project ID to host the cluster in | `any` | n/a | yes | | region | The region to host the cluster in | `any` | n/a | yes | -| subnetwork | The subnetwork to host the cluster in | `any` | n/a | yes | | zones | The zone to host the cluster in (required if is a zonal cluster) | `list(string)` | n/a | yes | ## Outputs diff --git a/examples/node_pool_update_variant_public_beta/main.tf b/examples/node_pool_update_variant_public_beta/main.tf index f369cfb7dd..65719fe1c7 100644 --- a/examples/node_pool_update_variant_public_beta/main.tf +++ b/examples/node_pool_update_variant_public_beta/main.tf @@ -23,12 +23,6 @@ provider "google-beta" { region = var.region } -data "google_compute_subnetwork" "subnetwork" { - name = var.subnetwork - project = var.project_id - region = var.region -} - data "google_client_config" "default" {} provider "kubernetes" { @@ -43,16 +37,16 @@ module "gke" { name = "${local.cluster_type}-cluster${var.cluster_name_suffix}" region = var.region zones = var.zones - network = var.network - subnetwork = var.subnetwork - ip_range_pods = var.ip_range_pods - ip_range_services = var.ip_range_services + network = google_compute_network.main.name + subnetwork = google_compute_subnetwork.main.name + ip_range_pods = google_compute_subnetwork.main.secondary_ip_range[0].range_name + ip_range_services = google_compute_subnetwork.main.secondary_ip_range[1].range_name create_service_account = false service_account = var.compute_engine_service_account master_authorized_networks = [ { - cidr_block = data.google_compute_subnetwork.subnetwork.ip_cidr_range + cidr_block = google_compute_subnetwork.main.ip_cidr_range display_name = "VPC" }, ] diff --git a/test/fixtures/node_pool_update_variant/network.tf b/examples/node_pool_update_variant_public_beta/network.tf similarity index 96% rename from test/fixtures/node_pool_update_variant/network.tf rename to examples/node_pool_update_variant_public_beta/network.tf index 94bb29e63c..fd3494411b 100644 --- a/test/fixtures/node_pool_update_variant/network.tf +++ b/examples/node_pool_update_variant_public_beta/network.tf @@ -20,13 +20,10 @@ resource "random_string" "suffix" { upper = false } -provider "google" { - project = var.project_ids[0] -} - resource "google_compute_network" "main" { name = "cft-gke-test-${random_string.suffix.result}" auto_create_subnetworks = false + project = var.project_id } resource "google_compute_subnetwork" "main" { @@ -45,4 +42,3 @@ resource "google_compute_subnetwork" "main" { ip_cidr_range = "192.168.64.0/18" } } - diff --git a/examples/node_pool_update_variant_public_beta/test_outputs.tf b/examples/node_pool_update_variant_public_beta/test_outputs.tf index e64c40e477..27d0f80bc3 100644 --- a/examples/node_pool_update_variant_public_beta/test_outputs.tf +++ b/examples/node_pool_update_variant_public_beta/test_outputs.tf @@ -31,11 +31,11 @@ output "cluster_name" { } output "network" { - value = var.network + value = google_compute_network.main.name } output "subnetwork" { - value = var.subnetwork + value = google_compute_subnetwork.main.name } output "location" { @@ -44,12 +44,12 @@ output "location" { output "ip_range_pods" { description = "The secondary IP range used for pods" - value = var.ip_range_pods + value = google_compute_subnetwork.main.secondary_ip_range[0].range_name } output "ip_range_services" { description = "The secondary IP range used for services" - value = var.ip_range_services + value = google_compute_subnetwork.main.secondary_ip_range[1].range_name } output "zones" { diff --git a/examples/node_pool_update_variant_public_beta/variables.tf b/examples/node_pool_update_variant_public_beta/variables.tf index a1377c4dd2..83dbb2be81 100644 --- a/examples/node_pool_update_variant_public_beta/variables.tf +++ b/examples/node_pool_update_variant_public_beta/variables.tf @@ -36,22 +36,6 @@ variable "zones" { description = "The zone to host the cluster in (required if is a zonal cluster)" } -variable "network" { - description = "The VPC network to host the cluster in" -} - -variable "subnetwork" { - description = "The subnetwork to host the cluster in" -} - -variable "ip_range_pods" { - description = "The secondary ip range to use for pods" -} - -variable "ip_range_services" { - description = "The secondary ip range to use for services" -} - variable "compute_engine_service_account" { description = "Service account to associate to the nodes in the cluster" } diff --git a/examples/private_zonal_with_networking/main.tf b/examples/private_zonal_with_networking/main.tf index 9910b9bb12..341789033d 100644 --- a/examples/private_zonal_with_networking/main.tf +++ b/examples/private_zonal_with_networking/main.tf @@ -27,11 +27,11 @@ module "gcp-network" { version = ">= 4.0.1, < 5.0.0" project_id = var.project_id - network_name = var.network + network_name = google_compute_network.main.name subnets = [ { - subnet_name = var.subnetwork + subnet_name = google_compute_subnetwork.main.name subnet_ip = "10.0.0.0/17" subnet_region = var.region subnet_private_access = "true" @@ -67,10 +67,10 @@ module "gke" { region = var.region zones = slice(var.zones, 0, 1) - network = module.gcp-network.network_name - subnetwork = module.gcp-network.subnets_names[0] - ip_range_pods = var.ip_range_pods_name - ip_range_services = var.ip_range_services_name + network = google_compute_network.main.name + subnetwork = google_compute_subnetwork.main.name + ip_range_pods = google_compute_subnetwork.main.secondary_ip_range[0].range_name + ip_range_services = google_compute_subnetwork.main.secondary_ip_range[1].range_name create_service_account = true enable_private_endpoint = true enable_private_nodes = true diff --git a/test/fixtures/simple_regional/network.tf b/examples/private_zonal_with_networking/network.tf similarity index 96% rename from test/fixtures/simple_regional/network.tf rename to examples/private_zonal_with_networking/network.tf index 94bb29e63c..fd3494411b 100644 --- a/test/fixtures/simple_regional/network.tf +++ b/examples/private_zonal_with_networking/network.tf @@ -20,13 +20,10 @@ resource "random_string" "suffix" { upper = false } -provider "google" { - project = var.project_ids[0] -} - resource "google_compute_network" "main" { name = "cft-gke-test-${random_string.suffix.result}" auto_create_subnetworks = false + project = var.project_id } resource "google_compute_subnetwork" "main" { @@ -45,4 +42,3 @@ resource "google_compute_subnetwork" "main" { ip_cidr_range = "192.168.64.0/18" } } - diff --git a/examples/private_zonal_with_networking/test_outputs.tf b/examples/private_zonal_with_networking/test_outputs.tf index e8eeacb9ef..db88aad6e6 100644 --- a/examples/private_zonal_with_networking/test_outputs.tf +++ b/examples/private_zonal_with_networking/test_outputs.tf @@ -22,11 +22,11 @@ output "project_id" { } output "network" { - value = var.network + value = google_compute_network.main.name } output "subnetwork" { - value = var.subnetwork + value = google_compute_subnetwork.main.name } output "location" { @@ -37,14 +37,14 @@ output "region" { value = var.region } -output "ip_range_pods_name" { +output "ip_range_pods" { description = "The secondary IP range used for pods" - value = var.ip_range_pods_name + value = google_compute_subnetwork.main.secondary_ip_range[0].range_name } -output "ip_range_services_name" { +output "ip_range_services" { description = "The secondary IP range used for services" - value = var.ip_range_services_name + value = google_compute_subnetwork.main.secondary_ip_range[1].range_name } output "zones" { diff --git a/examples/private_zonal_with_networking/variables.tf b/examples/private_zonal_with_networking/variables.tf index 2c3edc9304..41671944fa 100644 --- a/examples/private_zonal_with_networking/variables.tf +++ b/examples/private_zonal_with_networking/variables.tf @@ -31,24 +31,3 @@ variable "zones" { type = list(string) description = "The zone to host the cluster in (required if is a zonal cluster)" } - -variable "network" { - description = "The VPC network created to host the cluster in" - default = "gke-network" -} - -variable "subnetwork" { - description = "The subnetwork created to host the cluster in" - default = "gke-subnet" -} - -variable "ip_range_pods_name" { - description = "The secondary ip range to use for pods" - default = "ip-range-pods" -} - -variable "ip_range_services_name" { - description = "The secondary ip range to use for services" - default = "ip-range-scv" -} - diff --git a/examples/safer_cluster_iap_bastion/variables.tf b/examples/safer_cluster_iap_bastion/variables.tf index 42dc4f5f29..1c7fb24d6b 100644 --- a/examples/safer_cluster_iap_bastion/variables.tf +++ b/examples/safer_cluster_iap_bastion/variables.tf @@ -32,38 +32,12 @@ variable "region" { } -variable "network_name" { - type = string - description = "The name of the network being created to host the cluster in" - default = "safer-cluster-network" -} - -variable "subnet_name" { - type = string - description = "The name of the subnet being created to host the cluster in" - default = "safer-cluster-subnet" -} - variable "subnet_ip" { type = string description = "The cidr range of the subnet" default = "10.10.10.0/24" } -variable "ip_range_pods_name" { - type = string - description = "The secondary ip range to use for pods" - - default = "ip-range-pods" -} - -variable "ip_range_services_name" { - type = string - description = "The secondary ip range to use for pods" - - default = "ip-range-svc" -} - variable "bastion_members" { type = list(string) description = "List of users, groups, SAs who need access to the bastion host" diff --git a/examples/shared_vpc/variables.tf b/examples/shared_vpc/variables.tf index 6f1bc61945..bb5ac836ba 100644 --- a/examples/shared_vpc/variables.tf +++ b/examples/shared_vpc/variables.tf @@ -27,26 +27,10 @@ variable "region" { description = "The region to host the cluster in" } -variable "network" { - description = "The VPC network to host the cluster in" -} - variable "network_project_id" { description = "The GCP project housing the VPC network to host the cluster in" } -variable "subnetwork" { - description = "The subnetwork to host the cluster in" -} - -variable "ip_range_pods" { - description = "The secondary ip range to use for pods" -} - -variable "ip_range_services" { - description = "The secondary ip range to use for services" -} - variable "compute_engine_service_account" { description = "Service account to associate to the nodes in the cluster" } diff --git a/examples/simple_regional/variables.tf b/examples/simple_regional/variables.tf index b60c83ed5d..70aaa08df4 100644 --- a/examples/simple_regional/variables.tf +++ b/examples/simple_regional/variables.tf @@ -27,22 +27,6 @@ variable "region" { description = "The region to host the cluster in" } -variable "network" { - description = "The VPC network to host the cluster in" -} - -variable "subnetwork" { - description = "The subnetwork to host the cluster in" -} - -variable "ip_range_pods" { - description = "The secondary ip range to use for pods" -} - -variable "ip_range_services" { - description = "The secondary ip range to use for services" -} - variable "compute_engine_service_account" { description = "Service account to associate to the nodes in the cluster" } diff --git a/examples/simple_regional_beta/test_outputs.tf b/examples/simple_regional_beta/test_outputs.tf index 71e5965e05..c6c0a5013f 100644 --- a/examples/simple_regional_beta/test_outputs.tf +++ b/examples/simple_regional_beta/test_outputs.tf @@ -31,11 +31,11 @@ output "cluster_name" { } output "network" { - value = var.network + value = google_compute_network.main.name } output "subnetwork" { - value = var.subnetwork + value = google_compute_subnetwork.main.name } output "location" { @@ -44,12 +44,12 @@ output "location" { output "ip_range_pods" { description = "The secondary IP range used for pods" - value = var.ip_range_pods + value = google_compute_subnetwork.main.secondary_ip_range[0].range_name } output "ip_range_services" { description = "The secondary IP range used for services" - value = var.ip_range_services + value = google_compute_subnetwork.main.secondary_ip_range[1].range_name } output "zones" { diff --git a/examples/simple_regional_beta/variables.tf b/examples/simple_regional_beta/variables.tf index c6dd8ec693..402e452e47 100644 --- a/examples/simple_regional_beta/variables.tf +++ b/examples/simple_regional_beta/variables.tf @@ -27,22 +27,6 @@ variable "region" { description = "The region to host the cluster in" } -variable "network" { - description = "The VPC network to host the cluster in" -} - -variable "subnetwork" { - description = "The subnetwork to host the cluster in" -} - -variable "ip_range_pods" { - description = "The secondary ip range to use for pods" -} - -variable "ip_range_services" { - description = "The secondary ip range to use for services" -} - variable "compute_engine_service_account" { description = "Service account to associate to the nodes in the cluster" } diff --git a/examples/simple_regional_private/main.tf b/examples/simple_regional_private/main.tf index 15c24d8ed8..b66b04370a 100644 --- a/examples/simple_regional_private/main.tf +++ b/examples/simple_regional_private/main.tf @@ -38,10 +38,10 @@ module "gke" { name = "${local.cluster_type}-cluster${var.cluster_name_suffix}" regional = true region = var.region - network = var.network - subnetwork = var.subnetwork - ip_range_pods = var.ip_range_pods - ip_range_services = var.ip_range_services + network = google_compute_network.main.name + subnetwork = google_compute_subnetwork.main.name + ip_range_pods = google_compute_subnetwork.main.secondary_ip_range[0].range_name + ip_range_services = google_compute_subnetwork.main.secondary_ip_range[1].range_name create_service_account = false service_account = var.compute_engine_service_account enable_private_endpoint = true diff --git a/examples/simple_regional_private/network.tf b/examples/simple_regional_private/network.tf new file mode 100644 index 0000000000..fd3494411b --- /dev/null +++ b/examples/simple_regional_private/network.tf @@ -0,0 +1,44 @@ +/** + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +resource "random_string" "suffix" { + length = 4 + special = false + upper = false +} + +resource "google_compute_network" "main" { + name = "cft-gke-test-${random_string.suffix.result}" + auto_create_subnetworks = false + project = var.project_id +} + +resource "google_compute_subnetwork" "main" { + name = "cft-gke-test-${random_string.suffix.result}" + ip_cidr_range = "10.0.0.0/17" + region = var.region + network = google_compute_network.main.self_link + + secondary_ip_range { + range_name = "cft-gke-test-pods-${random_string.suffix.result}" + ip_cidr_range = "192.168.0.0/18" + } + + secondary_ip_range { + range_name = "cft-gke-test-services-${random_string.suffix.result}" + ip_cidr_range = "192.168.64.0/18" + } +} diff --git a/examples/simple_regional_private/variables.tf b/examples/simple_regional_private/variables.tf index b7137be2f0..5d8814c75c 100644 --- a/examples/simple_regional_private/variables.tf +++ b/examples/simple_regional_private/variables.tf @@ -27,22 +27,6 @@ variable "region" { description = "The region to host the cluster in" } -variable "network" { - description = "The VPC network to host the cluster in" -} - -variable "subnetwork" { - description = "The subnetwork to host the cluster in" -} - -variable "ip_range_pods" { - description = "The secondary ip range to use for pods" -} - -variable "ip_range_services" { - description = "The secondary ip range to use for services" -} - variable "compute_engine_service_account" { description = "Service account to associate to the nodes in the cluster" } diff --git a/examples/simple_regional_private_beta/main.tf b/examples/simple_regional_private_beta/main.tf index 50c9374a4d..c44aa874bd 100644 --- a/examples/simple_regional_private_beta/main.tf +++ b/examples/simple_regional_private_beta/main.tf @@ -38,10 +38,10 @@ module "gke" { name = "${local.cluster_type}-cluster${var.cluster_name_suffix}" regional = true region = var.region - network = var.network - subnetwork = var.subnetwork - ip_range_pods = var.ip_range_pods - ip_range_services = var.ip_range_services + network = google_compute_network.main.name + subnetwork = google_compute_subnetwork.main.name + ip_range_pods = google_compute_subnetwork.main.secondary_ip_range[0].range_name + ip_range_services = google_compute_subnetwork.main.secondary_ip_range[1].range_name service_account = var.compute_engine_service_account enable_private_endpoint = true enable_private_nodes = true diff --git a/examples/simple_regional_private_beta/test_outputs.tf b/examples/simple_regional_private_beta/test_outputs.tf index 53eab4ee12..5557eb9eac 100644 --- a/examples/simple_regional_private_beta/test_outputs.tf +++ b/examples/simple_regional_private_beta/test_outputs.tf @@ -31,11 +31,11 @@ output "cluster_name" { } output "network" { - value = var.network + value = google_compute_network.main.name } output "subnetwork" { - value = var.subnetwork + value = google_compute_subnetwork.main.name } output "location" { @@ -44,12 +44,12 @@ output "location" { output "ip_range_pods" { description = "The secondary IP range used for pods" - value = var.ip_range_pods + value = google_compute_subnetwork.main.secondary_ip_range[0].range_name } output "ip_range_services" { description = "The secondary IP range used for services" - value = var.ip_range_services + value = google_compute_subnetwork.main.secondary_ip_range[1].range_name } output "zones" { diff --git a/examples/simple_regional_private_beta/variables.tf b/examples/simple_regional_private_beta/variables.tf index c0b651b691..88c6c9ef26 100644 --- a/examples/simple_regional_private_beta/variables.tf +++ b/examples/simple_regional_private_beta/variables.tf @@ -27,22 +27,6 @@ variable "region" { description = "The region to host the cluster in" } -variable "network" { - description = "The VPC network to host the cluster in" -} - -variable "subnetwork" { - description = "The subnetwork to host the cluster in" -} - -variable "ip_range_pods" { - description = "The secondary ip range to use for pods" -} - -variable "ip_range_services" { - description = "The secondary ip range to use for services" -} - variable "compute_engine_service_account" { description = "Service account to associate to the nodes in the cluster" } diff --git a/examples/simple_regional_with_kubeconfig/main.tf b/examples/simple_regional_with_kubeconfig/main.tf index 183c0721dc..f03ac82d26 100644 --- a/examples/simple_regional_with_kubeconfig/main.tf +++ b/examples/simple_regional_with_kubeconfig/main.tf @@ -32,8 +32,8 @@ module "gke" { name = "${local.cluster_type}-cluster${var.cluster_name_suffix}" regional = true region = var.region - network = var.network - subnetwork = var.subnetwork + ip_range_pods = google_compute_subnetwork.main.secondary_ip_range[0].range_name + ip_range_services = google_compute_subnetwork.main.secondary_ip_range[1].range_name ip_range_pods = var.ip_range_pods ip_range_services = var.ip_range_services create_service_account = false diff --git a/examples/simple_regional_with_kubeconfig/network.tf b/examples/simple_regional_with_kubeconfig/network.tf new file mode 100644 index 0000000000..fd3494411b --- /dev/null +++ b/examples/simple_regional_with_kubeconfig/network.tf @@ -0,0 +1,44 @@ +/** + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +resource "random_string" "suffix" { + length = 4 + special = false + upper = false +} + +resource "google_compute_network" "main" { + name = "cft-gke-test-${random_string.suffix.result}" + auto_create_subnetworks = false + project = var.project_id +} + +resource "google_compute_subnetwork" "main" { + name = "cft-gke-test-${random_string.suffix.result}" + ip_cidr_range = "10.0.0.0/17" + region = var.region + network = google_compute_network.main.self_link + + secondary_ip_range { + range_name = "cft-gke-test-pods-${random_string.suffix.result}" + ip_cidr_range = "192.168.0.0/18" + } + + secondary_ip_range { + range_name = "cft-gke-test-services-${random_string.suffix.result}" + ip_cidr_range = "192.168.64.0/18" + } +} diff --git a/examples/simple_regional_with_kubeconfig/test_outputs.tf b/examples/simple_regional_with_kubeconfig/test_outputs.tf index a0bc9a28f0..a03bb808e6 100755 --- a/examples/simple_regional_with_kubeconfig/test_outputs.tf +++ b/examples/simple_regional_with_kubeconfig/test_outputs.tf @@ -31,25 +31,24 @@ output "cluster_name" { } output "network" { - value = var.network + value = google_compute_network.main.name } output "subnetwork" { - value = var.subnetwork + value = google_compute_subnetwork.main.name } - output "location" { value = module.gke.location } output "ip_range_pods" { description = "The secondary IP range used for pods" - value = var.ip_range_pods + value = google_compute_subnetwork.main.secondary_ip_range[0].range_name } output "ip_range_services" { description = "The secondary IP range used for services" - value = var.ip_range_services + value = google_compute_subnetwork.main.secondary_ip_range[1].range_name } output "zones" { diff --git a/examples/simple_regional_with_kubeconfig/variables.tf b/examples/simple_regional_with_kubeconfig/variables.tf index 832e036d0a..e67b54ab8f 100644 --- a/examples/simple_regional_with_kubeconfig/variables.tf +++ b/examples/simple_regional_with_kubeconfig/variables.tf @@ -27,22 +27,6 @@ variable "region" { description = "The region to host the cluster in" } -variable "network" { - description = "The VPC network to host the cluster in" -} - -variable "subnetwork" { - description = "The subnetwork to host the cluster in" -} - -variable "ip_range_pods" { - description = "The secondary ip range to use for pods" -} - -variable "ip_range_services" { - description = "The secondary ip range to use for services" -} - variable "compute_engine_service_account" { description = "Service account to associate to the nodes in the cluster" } diff --git a/examples/simple_regional_with_networking/test_outputs.tf b/examples/simple_regional_with_networking/test_outputs.tf index a703679105..76caee67e8 100644 --- a/examples/simple_regional_with_networking/test_outputs.tf +++ b/examples/simple_regional_with_networking/test_outputs.tf @@ -26,25 +26,25 @@ output "region" { } output "network" { - value = var.network + value = google_compute_network.main.name } output "subnetwork" { - value = var.subnetwork + value = google_compute_subnetwork.main.name } output "location" { value = module.gke.location } -output "ip_range_pods_name" { +output "ip_range_pods" { description = "The secondary IP range used for pods" - value = var.ip_range_pods_name + value = google_compute_subnetwork.main.secondary_ip_range[0].range_name } -output "ip_range_services_name" { +output "ip_range_services" { description = "The secondary IP range used for services" - value = var.ip_range_services_name + value = google_compute_subnetwork.main.secondary_ip_range[1].range_name } output "zones" { diff --git a/examples/simple_regional_with_networking/variables.tf b/examples/simple_regional_with_networking/variables.tf index d54fafd78e..83dc65b3ca 100644 --- a/examples/simple_regional_with_networking/variables.tf +++ b/examples/simple_regional_with_networking/variables.tf @@ -27,24 +27,3 @@ variable "region" { description = "The region to host the cluster in" default = "us-central1" } - -variable "network" { - description = "The VPC network created to host the cluster in" - default = "gke-network" -} - -variable "subnetwork" { - description = "The subnetwork created to host the cluster in" - default = "gke-subnet" -} - -variable "ip_range_pods_name" { - description = "The secondary ip range to use for pods" - default = "ip-range-pods" -} - -variable "ip_range_services_name" { - description = "The secondary ip range to use for services" - default = "ip-range-scv" -} - diff --git a/examples/simple_zonal_private/main.tf b/examples/simple_zonal_private/main.tf index e845f41ca9..677d21441a 100644 --- a/examples/simple_zonal_private/main.tf +++ b/examples/simple_zonal_private/main.tf @@ -39,10 +39,10 @@ module "gke" { regional = false region = var.region zones = var.zones - network = var.network - subnetwork = var.subnetwork - ip_range_pods = var.ip_range_pods - ip_range_services = var.ip_range_services + network = google_compute_network.main.name + subnetwork = google_compute_subnetwork.main.name + ip_range_pods = google_compute_subnetwork.main.secondary_ip_range[0].range_name + ip_range_services = google_compute_subnetwork.main.secondary_ip_range[1].range_name create_service_account = false service_account = var.compute_engine_service_account enable_private_endpoint = true diff --git a/examples/simple_zonal_private/network.tf b/examples/simple_zonal_private/network.tf new file mode 100644 index 0000000000..fd3494411b --- /dev/null +++ b/examples/simple_zonal_private/network.tf @@ -0,0 +1,44 @@ +/** + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +resource "random_string" "suffix" { + length = 4 + special = false + upper = false +} + +resource "google_compute_network" "main" { + name = "cft-gke-test-${random_string.suffix.result}" + auto_create_subnetworks = false + project = var.project_id +} + +resource "google_compute_subnetwork" "main" { + name = "cft-gke-test-${random_string.suffix.result}" + ip_cidr_range = "10.0.0.0/17" + region = var.region + network = google_compute_network.main.self_link + + secondary_ip_range { + range_name = "cft-gke-test-pods-${random_string.suffix.result}" + ip_cidr_range = "192.168.0.0/18" + } + + secondary_ip_range { + range_name = "cft-gke-test-services-${random_string.suffix.result}" + ip_cidr_range = "192.168.64.0/18" + } +} diff --git a/examples/simple_zonal_private/variables.tf b/examples/simple_zonal_private/variables.tf index 485ac1ff3b..cab0cdc60f 100644 --- a/examples/simple_zonal_private/variables.tf +++ b/examples/simple_zonal_private/variables.tf @@ -32,22 +32,6 @@ variable "zones" { description = "The zone to host the cluster in (required if is a zonal cluster)" } -variable "network" { - description = "The VPC network to host the cluster in" -} - -variable "subnetwork" { - description = "The subnetwork to host the cluster in" -} - -variable "ip_range_pods" { - description = "The secondary ip range to use for pods" -} - -variable "ip_range_services" { - description = "The secondary ip range to use for services" -} - variable "compute_engine_service_account" { description = "Service account to associate to the nodes in the cluster" } diff --git a/examples/simple_zonal_with_asm/main.tf b/examples/simple_zonal_with_asm/main.tf index c7351435c3..0a9d184908 100644 --- a/examples/simple_zonal_with_asm/main.tf +++ b/examples/simple_zonal_with_asm/main.tf @@ -38,10 +38,10 @@ module "gke" { region = var.region zones = var.zones release_channel = "REGULAR" - network = var.network - subnetwork = var.subnetwork - ip_range_pods = var.ip_range_pods - ip_range_services = var.ip_range_services + network = google_compute_network.main.name + subnetwork = google_compute_subnetwork.main.name + ip_range_pods = google_compute_subnetwork.main.secondary_ip_range[0].range_name + ip_range_services = google_compute_subnetwork.main.secondary_ip_range[1].range_name network_policy = false cluster_resource_labels = { "mesh_id" : "proj-${data.google_project.project.number}" } identity_namespace = "${var.project_id}.svc.id.goog" diff --git a/test/fixtures/deploy_service/network.tf b/examples/simple_zonal_with_asm/network.tf similarity index 92% rename from test/fixtures/deploy_service/network.tf rename to examples/simple_zonal_with_asm/network.tf index 94bb29e63c..0f2a3d3e84 100644 --- a/test/fixtures/deploy_service/network.tf +++ b/examples/simple_zonal_with_asm/network.tf @@ -1,5 +1,5 @@ /** - * Copyright 2018 Google LLC + * Copyright 2021 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,16 +20,14 @@ resource "random_string" "suffix" { upper = false } -provider "google" { - project = var.project_ids[0] -} - resource "google_compute_network" "main" { + project = var.project_id name = "cft-gke-test-${random_string.suffix.result}" auto_create_subnetworks = false } resource "google_compute_subnetwork" "main" { + project = var.project_id name = "cft-gke-test-${random_string.suffix.result}" ip_cidr_range = "10.0.0.0/17" region = var.region @@ -45,4 +43,3 @@ resource "google_compute_subnetwork" "main" { ip_cidr_range = "192.168.64.0/18" } } - diff --git a/examples/simple_zonal_with_asm/test_outputs.tf b/examples/simple_zonal_with_asm/test_outputs.tf index 71e5965e05..c6c0a5013f 100644 --- a/examples/simple_zonal_with_asm/test_outputs.tf +++ b/examples/simple_zonal_with_asm/test_outputs.tf @@ -31,11 +31,11 @@ output "cluster_name" { } output "network" { - value = var.network + value = google_compute_network.main.name } output "subnetwork" { - value = var.subnetwork + value = google_compute_subnetwork.main.name } output "location" { @@ -44,12 +44,12 @@ output "location" { output "ip_range_pods" { description = "The secondary IP range used for pods" - value = var.ip_range_pods + value = google_compute_subnetwork.main.secondary_ip_range[0].range_name } output "ip_range_services" { description = "The secondary IP range used for services" - value = var.ip_range_services + value = google_compute_subnetwork.main.secondary_ip_range[1].range_name } output "zones" { diff --git a/examples/simple_zonal_with_asm/variables.tf b/examples/simple_zonal_with_asm/variables.tf index 6dd142621c..38c33acd3e 100644 --- a/examples/simple_zonal_with_asm/variables.tf +++ b/examples/simple_zonal_with_asm/variables.tf @@ -31,19 +31,3 @@ variable "zones" { type = list(string) description = "The zone to host the cluster in (required if is a zonal cluster)" } - -variable "network" { - description = "The VPC network to host the cluster in" -} - -variable "subnetwork" { - description = "The subnetwork to host the cluster in" -} - -variable "ip_range_pods" { - description = "The secondary ip range to use for pods" -} - -variable "ip_range_services" { - description = "The secondary ip range to use for services" -} diff --git a/examples/stub_domains/main.tf b/examples/stub_domains/main.tf index 808f4b4366..6041b3c010 100644 --- a/examples/stub_domains/main.tf +++ b/examples/stub_domains/main.tf @@ -31,10 +31,10 @@ module "gke" { project_id = var.project_id name = "${local.cluster_type}-cluster${var.cluster_name_suffix}" region = var.region - network = var.network - subnetwork = var.subnetwork - ip_range_pods = var.ip_range_pods - ip_range_services = var.ip_range_services + network = google_compute_network.main.name + subnetwork = google_compute_subnetwork.main.name + ip_range_pods = google_compute_subnetwork.main.secondary_ip_range[0].range_name + ip_range_services = google_compute_subnetwork.main.secondary_ip_range[1].range_name service_account = var.compute_engine_service_account create_service_account = false diff --git a/examples/stub_domains/network.tf b/examples/stub_domains/network.tf new file mode 100644 index 0000000000..fd3494411b --- /dev/null +++ b/examples/stub_domains/network.tf @@ -0,0 +1,44 @@ +/** + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +resource "random_string" "suffix" { + length = 4 + special = false + upper = false +} + +resource "google_compute_network" "main" { + name = "cft-gke-test-${random_string.suffix.result}" + auto_create_subnetworks = false + project = var.project_id +} + +resource "google_compute_subnetwork" "main" { + name = "cft-gke-test-${random_string.suffix.result}" + ip_cidr_range = "10.0.0.0/17" + region = var.region + network = google_compute_network.main.self_link + + secondary_ip_range { + range_name = "cft-gke-test-pods-${random_string.suffix.result}" + ip_cidr_range = "192.168.0.0/18" + } + + secondary_ip_range { + range_name = "cft-gke-test-services-${random_string.suffix.result}" + ip_cidr_range = "192.168.64.0/18" + } +} diff --git a/examples/stub_domains/variables.tf b/examples/stub_domains/variables.tf index b7137be2f0..5d8814c75c 100644 --- a/examples/stub_domains/variables.tf +++ b/examples/stub_domains/variables.tf @@ -27,22 +27,6 @@ variable "region" { description = "The region to host the cluster in" } -variable "network" { - description = "The VPC network to host the cluster in" -} - -variable "subnetwork" { - description = "The subnetwork to host the cluster in" -} - -variable "ip_range_pods" { - description = "The secondary ip range to use for pods" -} - -variable "ip_range_services" { - description = "The secondary ip range to use for services" -} - variable "compute_engine_service_account" { description = "Service account to associate to the nodes in the cluster" } diff --git a/examples/stub_domains_private/main.tf b/examples/stub_domains_private/main.tf index 3a04cfbe3e..793525173c 100644 --- a/examples/stub_domains_private/main.tf +++ b/examples/stub_domains_private/main.tf @@ -31,13 +31,13 @@ data "google_compute_subnetwork" "subnetwork" { module "gke" { source = "../../modules/private-cluster" - ip_range_pods = var.ip_range_pods - ip_range_services = var.ip_range_services + ip_range_pods = google_compute_subnetwork.main.secondary_ip_range[0].range_name + ip_range_services = google_compute_subnetwork.main.secondary_ip_range[1].range_name name = "stub-domains-private-cluster${var.cluster_name_suffix}" - network = var.network + network = google_compute_network.main.name project_id = var.project_id region = var.region - subnetwork = var.subnetwork + subnetwork = google_compute_subnetwork.main.name deploy_using_private_endpoint = true enable_private_endpoint = false diff --git a/examples/stub_domains_private/network.tf b/examples/stub_domains_private/network.tf new file mode 100644 index 0000000000..fd3494411b --- /dev/null +++ b/examples/stub_domains_private/network.tf @@ -0,0 +1,44 @@ +/** + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +resource "random_string" "suffix" { + length = 4 + special = false + upper = false +} + +resource "google_compute_network" "main" { + name = "cft-gke-test-${random_string.suffix.result}" + auto_create_subnetworks = false + project = var.project_id +} + +resource "google_compute_subnetwork" "main" { + name = "cft-gke-test-${random_string.suffix.result}" + ip_cidr_range = "10.0.0.0/17" + region = var.region + network = google_compute_network.main.self_link + + secondary_ip_range { + range_name = "cft-gke-test-pods-${random_string.suffix.result}" + ip_cidr_range = "192.168.0.0/18" + } + + secondary_ip_range { + range_name = "cft-gke-test-services-${random_string.suffix.result}" + ip_cidr_range = "192.168.64.0/18" + } +} diff --git a/examples/stub_domains_private/test_outputs.tf b/examples/stub_domains_private/test_outputs.tf index 53eab4ee12..5557eb9eac 100644 --- a/examples/stub_domains_private/test_outputs.tf +++ b/examples/stub_domains_private/test_outputs.tf @@ -31,11 +31,11 @@ output "cluster_name" { } output "network" { - value = var.network + value = google_compute_network.main.name } output "subnetwork" { - value = var.subnetwork + value = google_compute_subnetwork.main.name } output "location" { @@ -44,12 +44,12 @@ output "location" { output "ip_range_pods" { description = "The secondary IP range used for pods" - value = var.ip_range_pods + value = google_compute_subnetwork.main.secondary_ip_range[0].range_name } output "ip_range_services" { description = "The secondary IP range used for services" - value = var.ip_range_services + value = google_compute_subnetwork.main.secondary_ip_range[1].range_name } output "zones" { diff --git a/examples/stub_domains_private/variables.tf b/examples/stub_domains_private/variables.tf index b7137be2f0..5d8814c75c 100644 --- a/examples/stub_domains_private/variables.tf +++ b/examples/stub_domains_private/variables.tf @@ -27,22 +27,6 @@ variable "region" { description = "The region to host the cluster in" } -variable "network" { - description = "The VPC network to host the cluster in" -} - -variable "subnetwork" { - description = "The subnetwork to host the cluster in" -} - -variable "ip_range_pods" { - description = "The secondary ip range to use for pods" -} - -variable "ip_range_services" { - description = "The secondary ip range to use for services" -} - variable "compute_engine_service_account" { description = "Service account to associate to the nodes in the cluster" } diff --git a/examples/stub_domains_upstream_nameservers/main.tf b/examples/stub_domains_upstream_nameservers/main.tf index d9aa82baba..3ac2969512 100644 --- a/examples/stub_domains_upstream_nameservers/main.tf +++ b/examples/stub_domains_upstream_nameservers/main.tf @@ -31,10 +31,10 @@ module "gke" { project_id = var.project_id name = "${local.cluster_type}-cluster${var.cluster_name_suffix}" region = var.region - network = var.network - subnetwork = var.subnetwork - ip_range_pods = var.ip_range_pods - ip_range_services = var.ip_range_services + network = google_compute_network.main.name + subnetwork = google_compute_subnetwork.main.name + ip_range_pods = google_compute_subnetwork.main.secondary_ip_range[0].range_name + ip_range_services = google_compute_subnetwork.main.secondary_ip_range[1].range_name create_service_account = false service_account = var.compute_engine_service_account diff --git a/examples/stub_domains_upstream_nameservers/network.tf b/examples/stub_domains_upstream_nameservers/network.tf new file mode 100644 index 0000000000..fd3494411b --- /dev/null +++ b/examples/stub_domains_upstream_nameservers/network.tf @@ -0,0 +1,44 @@ +/** + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +resource "random_string" "suffix" { + length = 4 + special = false + upper = false +} + +resource "google_compute_network" "main" { + name = "cft-gke-test-${random_string.suffix.result}" + auto_create_subnetworks = false + project = var.project_id +} + +resource "google_compute_subnetwork" "main" { + name = "cft-gke-test-${random_string.suffix.result}" + ip_cidr_range = "10.0.0.0/17" + region = var.region + network = google_compute_network.main.self_link + + secondary_ip_range { + range_name = "cft-gke-test-pods-${random_string.suffix.result}" + ip_cidr_range = "192.168.0.0/18" + } + + secondary_ip_range { + range_name = "cft-gke-test-services-${random_string.suffix.result}" + ip_cidr_range = "192.168.64.0/18" + } +} diff --git a/examples/stub_domains_upstream_nameservers/test_outputs.tf b/examples/stub_domains_upstream_nameservers/test_outputs.tf index 53eab4ee12..5557eb9eac 100644 --- a/examples/stub_domains_upstream_nameservers/test_outputs.tf +++ b/examples/stub_domains_upstream_nameservers/test_outputs.tf @@ -31,11 +31,11 @@ output "cluster_name" { } output "network" { - value = var.network + value = google_compute_network.main.name } output "subnetwork" { - value = var.subnetwork + value = google_compute_subnetwork.main.name } output "location" { @@ -44,12 +44,12 @@ output "location" { output "ip_range_pods" { description = "The secondary IP range used for pods" - value = var.ip_range_pods + value = google_compute_subnetwork.main.secondary_ip_range[0].range_name } output "ip_range_services" { description = "The secondary IP range used for services" - value = var.ip_range_services + value = google_compute_subnetwork.main.secondary_ip_range[1].range_name } output "zones" { diff --git a/examples/stub_domains_upstream_nameservers/variables.tf b/examples/stub_domains_upstream_nameservers/variables.tf index b7137be2f0..5d8814c75c 100644 --- a/examples/stub_domains_upstream_nameservers/variables.tf +++ b/examples/stub_domains_upstream_nameservers/variables.tf @@ -27,22 +27,6 @@ variable "region" { description = "The region to host the cluster in" } -variable "network" { - description = "The VPC network to host the cluster in" -} - -variable "subnetwork" { - description = "The subnetwork to host the cluster in" -} - -variable "ip_range_pods" { - description = "The secondary ip range to use for pods" -} - -variable "ip_range_services" { - description = "The secondary ip range to use for services" -} - variable "compute_engine_service_account" { description = "Service account to associate to the nodes in the cluster" } diff --git a/examples/upstream_nameservers/main.tf b/examples/upstream_nameservers/main.tf index df8954c3b4..b385e47cfb 100644 --- a/examples/upstream_nameservers/main.tf +++ b/examples/upstream_nameservers/main.tf @@ -31,10 +31,10 @@ module "gke" { project_id = var.project_id name = "${local.cluster_type}-cluster${var.cluster_name_suffix}" region = var.region - network = var.network - subnetwork = var.subnetwork - ip_range_pods = var.ip_range_pods - ip_range_services = var.ip_range_services + network = google_compute_network.main.name + subnetwork = google_compute_subnetwork.main.name + ip_range_pods = google_compute_subnetwork.main.secondary_ip_range[0].range_name + ip_range_services = google_compute_subnetwork.main.secondary_ip_range[1].range_name create_service_account = false service_account = var.compute_engine_service_account diff --git a/examples/upstream_nameservers/network.tf b/examples/upstream_nameservers/network.tf new file mode 100644 index 0000000000..fd3494411b --- /dev/null +++ b/examples/upstream_nameservers/network.tf @@ -0,0 +1,44 @@ +/** + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +resource "random_string" "suffix" { + length = 4 + special = false + upper = false +} + +resource "google_compute_network" "main" { + name = "cft-gke-test-${random_string.suffix.result}" + auto_create_subnetworks = false + project = var.project_id +} + +resource "google_compute_subnetwork" "main" { + name = "cft-gke-test-${random_string.suffix.result}" + ip_cidr_range = "10.0.0.0/17" + region = var.region + network = google_compute_network.main.self_link + + secondary_ip_range { + range_name = "cft-gke-test-pods-${random_string.suffix.result}" + ip_cidr_range = "192.168.0.0/18" + } + + secondary_ip_range { + range_name = "cft-gke-test-services-${random_string.suffix.result}" + ip_cidr_range = "192.168.64.0/18" + } +} diff --git a/examples/upstream_nameservers/test_outputs.tf b/examples/upstream_nameservers/test_outputs.tf index 53eab4ee12..5557eb9eac 100644 --- a/examples/upstream_nameservers/test_outputs.tf +++ b/examples/upstream_nameservers/test_outputs.tf @@ -31,11 +31,11 @@ output "cluster_name" { } output "network" { - value = var.network + value = google_compute_network.main.name } output "subnetwork" { - value = var.subnetwork + value = google_compute_subnetwork.main.name } output "location" { @@ -44,12 +44,12 @@ output "location" { output "ip_range_pods" { description = "The secondary IP range used for pods" - value = var.ip_range_pods + value = google_compute_subnetwork.main.secondary_ip_range[0].range_name } output "ip_range_services" { description = "The secondary IP range used for services" - value = var.ip_range_services + value = google_compute_subnetwork.main.secondary_ip_range[1].range_name } output "zones" { diff --git a/examples/upstream_nameservers/variables.tf b/examples/upstream_nameservers/variables.tf index b7137be2f0..5d8814c75c 100644 --- a/examples/upstream_nameservers/variables.tf +++ b/examples/upstream_nameservers/variables.tf @@ -27,22 +27,6 @@ variable "region" { description = "The region to host the cluster in" } -variable "network" { - description = "The VPC network to host the cluster in" -} - -variable "subnetwork" { - description = "The subnetwork to host the cluster in" -} - -variable "ip_range_pods" { - description = "The secondary ip range to use for pods" -} - -variable "ip_range_services" { - description = "The secondary ip range to use for services" -} - variable "compute_engine_service_account" { description = "Service account to associate to the nodes in the cluster" } diff --git a/examples/workload_identity/main.tf b/examples/workload_identity/main.tf index e63ba4e273..5e3b0c3ccc 100644 --- a/examples/workload_identity/main.tf +++ b/examples/workload_identity/main.tf @@ -31,10 +31,10 @@ module "gke" { project_id = var.project_id name = "${local.cluster_type}-cluster${var.cluster_name_suffix}" region = var.region - network = var.network - subnetwork = var.subnetwork - ip_range_pods = var.ip_range_pods - ip_range_services = var.ip_range_services + network = google_compute_network.main.name + subnetwork = google_compute_subnetwork.main.name + ip_range_pods = google_compute_subnetwork.main.secondary_ip_range[0].range_name + ip_range_services = google_compute_subnetwork.main.secondary_ip_range[1].range_name remove_default_node_pool = true service_account = "create" node_metadata = "GKE_METADATA" diff --git a/examples/workload_identity/network.tf b/examples/workload_identity/network.tf new file mode 100644 index 0000000000..fd3494411b --- /dev/null +++ b/examples/workload_identity/network.tf @@ -0,0 +1,44 @@ +/** + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +resource "random_string" "suffix" { + length = 4 + special = false + upper = false +} + +resource "google_compute_network" "main" { + name = "cft-gke-test-${random_string.suffix.result}" + auto_create_subnetworks = false + project = var.project_id +} + +resource "google_compute_subnetwork" "main" { + name = "cft-gke-test-${random_string.suffix.result}" + ip_cidr_range = "10.0.0.0/17" + region = var.region + network = google_compute_network.main.self_link + + secondary_ip_range { + range_name = "cft-gke-test-pods-${random_string.suffix.result}" + ip_cidr_range = "192.168.0.0/18" + } + + secondary_ip_range { + range_name = "cft-gke-test-services-${random_string.suffix.result}" + ip_cidr_range = "192.168.64.0/18" + } +} diff --git a/examples/workload_identity/variables.tf b/examples/workload_identity/variables.tf index dab884ab75..6e77ff6f76 100644 --- a/examples/workload_identity/variables.tf +++ b/examples/workload_identity/variables.tf @@ -27,20 +27,3 @@ variable "region" { description = "The region to host the cluster in" default = "us-central1" } - -variable "network" { - description = "The VPC network to host the cluster in" -} - -variable "subnetwork" { - description = "The subnetwork to host the cluster in" -} - -variable "ip_range_pods" { - description = "The secondary ip range to use for pods" -} - -variable "ip_range_services" { - description = "The secondary ip range to use for pods" -} - diff --git a/examples/workload_metadata_config/main.tf b/examples/workload_metadata_config/main.tf index a1443f285f..fceb370de3 100644 --- a/examples/workload_metadata_config/main.tf +++ b/examples/workload_metadata_config/main.tf @@ -39,10 +39,10 @@ module "gke" { regional = false region = var.region zones = var.zones - network = var.network - subnetwork = var.subnetwork - ip_range_pods = var.ip_range_pods - ip_range_services = var.ip_range_services + network = google_compute_network.main.name + subnetwork = google_compute_subnetwork.main.name + ip_range_pods = google_compute_subnetwork.main.secondary_ip_range[0].range_name + ip_range_services = google_compute_subnetwork.main.secondary_ip_range[1].range_name create_service_account = true grant_registry_access = true registry_project_ids = var.registry_project_ids diff --git a/examples/workload_metadata_config/network.tf b/examples/workload_metadata_config/network.tf new file mode 100644 index 0000000000..fd3494411b --- /dev/null +++ b/examples/workload_metadata_config/network.tf @@ -0,0 +1,44 @@ +/** + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +resource "random_string" "suffix" { + length = 4 + special = false + upper = false +} + +resource "google_compute_network" "main" { + name = "cft-gke-test-${random_string.suffix.result}" + auto_create_subnetworks = false + project = var.project_id +} + +resource "google_compute_subnetwork" "main" { + name = "cft-gke-test-${random_string.suffix.result}" + ip_cidr_range = "10.0.0.0/17" + region = var.region + network = google_compute_network.main.self_link + + secondary_ip_range { + range_name = "cft-gke-test-pods-${random_string.suffix.result}" + ip_cidr_range = "192.168.0.0/18" + } + + secondary_ip_range { + range_name = "cft-gke-test-services-${random_string.suffix.result}" + ip_cidr_range = "192.168.64.0/18" + } +} diff --git a/examples/workload_metadata_config/variables.tf b/examples/workload_metadata_config/variables.tf index 603dc4c4fb..84bf0b6caa 100644 --- a/examples/workload_metadata_config/variables.tf +++ b/examples/workload_metadata_config/variables.tf @@ -32,22 +32,6 @@ variable "zones" { description = "The zone to host the cluster in (required if is a zonal cluster)" } -variable "network" { - description = "The VPC network to host the cluster in" -} - -variable "subnetwork" { - description = "The subnetwork to host the cluster in" -} - -variable "ip_range_pods" { - description = "The secondary ip range to use for pods" -} - -variable "ip_range_services" { - description = "The secondary ip range to use for services" -} - variable "registry_project_ids" { description = "Project names for GCR registries" type = list(string) diff --git a/test/fixtures/all_examples/test_outputs.tf b/test/fixtures/all_examples/test_outputs.tf index e64c40e477..27d0f80bc3 100755 --- a/test/fixtures/all_examples/test_outputs.tf +++ b/test/fixtures/all_examples/test_outputs.tf @@ -31,11 +31,11 @@ output "cluster_name" { } output "network" { - value = var.network + value = google_compute_network.main.name } output "subnetwork" { - value = var.subnetwork + value = google_compute_subnetwork.main.name } output "location" { @@ -44,12 +44,12 @@ output "location" { output "ip_range_pods" { description = "The secondary IP range used for pods" - value = var.ip_range_pods + value = google_compute_subnetwork.main.secondary_ip_range[0].range_name } output "ip_range_services" { description = "The secondary IP range used for services" - value = var.ip_range_services + value = google_compute_subnetwork.main.secondary_ip_range[1].range_name } output "zones" { diff --git a/test/fixtures/deploy_service/example.tf b/test/fixtures/deploy_service/example.tf index 60904163a8..ef6ca6a284 100644 --- a/test/fixtures/deploy_service/example.tf +++ b/test/fixtures/deploy_service/example.tf @@ -20,10 +20,6 @@ module "example" { project_id = var.project_ids[0] cluster_name_suffix = "-${random_string.suffix.result}" region = var.region - network = google_compute_network.main.name - subnetwork = google_compute_subnetwork.main.name - ip_range_pods = google_compute_subnetwork.main.secondary_ip_range[0].range_name - ip_range_services = google_compute_subnetwork.main.secondary_ip_range[1].range_name compute_engine_service_account = var.compute_engine_service_accounts[0] } diff --git a/test/fixtures/node_pool/example.tf b/test/fixtures/node_pool/example.tf index c29124b2b7..b2ca76b487 100644 --- a/test/fixtures/node_pool/example.tf +++ b/test/fixtures/node_pool/example.tf @@ -14,6 +14,12 @@ * limitations under the License. */ +resource "random_string" "suffix" { + length = 4 + special = false + upper = false +} + module "example" { source = "../../../examples/node_pool" @@ -21,10 +27,6 @@ module "example" { cluster_name_suffix = "-${random_string.suffix.result}" region = "europe-west4" zones = ["europe-west4-a"] - network = google_compute_network.main.name - subnetwork = google_compute_subnetwork.main.name - ip_range_pods = google_compute_subnetwork.main.secondary_ip_range[0].range_name - ip_range_services = google_compute_subnetwork.main.secondary_ip_range[1].range_name compute_engine_service_account = var.compute_engine_service_accounts[0] cluster_autoscaling = { diff --git a/test/fixtures/node_pool_update_variant/example.tf b/test/fixtures/node_pool_update_variant/example.tf index b7f9c8c390..bc402d15d6 100644 --- a/test/fixtures/node_pool_update_variant/example.tf +++ b/test/fixtures/node_pool_update_variant/example.tf @@ -14,6 +14,12 @@ * limitations under the License. */ +resource "random_string" "suffix" { + length = 4 + special = false + upper = false +} + module "example" { source = "../../../examples/node_pool_update_variant" @@ -21,9 +27,5 @@ module "example" { cluster_name_suffix = "-${random_string.suffix.result}" region = var.region zones = slice(var.zones, 0, 1) - network = google_compute_network.main.name - subnetwork = google_compute_subnetwork.main.name - ip_range_pods = google_compute_subnetwork.main.secondary_ip_range[0].range_name - ip_range_services = google_compute_subnetwork.main.secondary_ip_range[1].range_name compute_engine_service_account = var.compute_engine_service_accounts[0] } diff --git a/test/fixtures/sandbox_enabled/example.tf b/test/fixtures/sandbox_enabled/example.tf index ddd9476880..0ae9963e88 100644 --- a/test/fixtures/sandbox_enabled/example.tf +++ b/test/fixtures/sandbox_enabled/example.tf @@ -20,10 +20,6 @@ module "example" { project_id = var.project_ids[0] cluster_name_suffix = "-${random_string.suffix.result}" region = var.region - network = google_compute_network.main.name - subnetwork = google_compute_subnetwork.main.name - ip_range_pods = google_compute_subnetwork.main.secondary_ip_range[0].range_name - ip_range_services = google_compute_subnetwork.main.secondary_ip_range[1].range_name compute_engine_service_account = var.compute_engine_service_accounts[0] istio = false cloudrun = false diff --git a/test/fixtures/sandbox_enabled/network.tf b/test/fixtures/sandbox_enabled/network.tf deleted file mode 100644 index f170a88fa4..0000000000 --- a/test/fixtures/sandbox_enabled/network.tf +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -resource "random_string" "suffix" { - length = 4 - special = false - upper = false -} - -provider "google" { - project = var.project_ids[0] -} - -resource "google_compute_network" "main" { - name = "cft-gke-test-${random_string.suffix.result}" - auto_create_subnetworks = false -} - -resource "google_compute_subnetwork" "main" { - name = "cft-gke-test-${random_string.suffix.result}" - ip_cidr_range = "10.0.0.0/17" - region = var.region - network = google_compute_network.main.self_link - - secondary_ip_range { - range_name = "cft-gke-test-pods-${random_string.suffix.result}" - ip_cidr_range = "192.168.0.0/18" - } - - secondary_ip_range { - range_name = "cft-gke-test-services-${random_string.suffix.result}" - ip_cidr_range = "192.168.64.0/18" - } -} - diff --git a/test/fixtures/shared/outputs.tf b/test/fixtures/shared/outputs.tf index a62317bf64..65c6a048dd 100644 --- a/test/fixtures/shared/outputs.tf +++ b/test/fixtures/shared/outputs.tf @@ -28,11 +28,11 @@ output "cluster_name" { } output "network" { - value = google_compute_network.main.name + value = module.example.network } output "subnetwork" { - value = google_compute_subnetwork.main.name + value = module.example.subnetwork } output "location" { @@ -41,12 +41,12 @@ output "location" { output "ip_range_pods" { description = "The secondary IP range used for pods" - value = google_compute_subnetwork.main.secondary_ip_range[0].range_name + value = module.example.ip_range_pods } output "ip_range_services" { description = "The secondary IP range used for services" - value = google_compute_subnetwork.main.secondary_ip_range[1].range_name + value = module.example.ip_range_services } output "zones" { diff --git a/test/fixtures/shared_vpc/example.tf b/test/fixtures/shared_vpc/example.tf index a91d50fe85..7b7a458a2f 100644 --- a/test/fixtures/shared_vpc/example.tf +++ b/test/fixtures/shared_vpc/example.tf @@ -20,11 +20,7 @@ module "example" { project_id = var.project_ids[0] cluster_name_suffix = "-${random_string.suffix.result}" region = var.region - network = google_compute_network.main.name network_project_id = var.project_ids[0] - subnetwork = google_compute_subnetwork.main.name - ip_range_pods = google_compute_subnetwork.main.secondary_ip_range[0].range_name - ip_range_services = google_compute_subnetwork.main.secondary_ip_range[1].range_name compute_engine_service_account = var.compute_engine_service_accounts[0] } diff --git a/test/fixtures/simple_regional/example.tf b/test/fixtures/simple_regional/example.tf index cb50faf354..237cec08bf 100644 --- a/test/fixtures/simple_regional/example.tf +++ b/test/fixtures/simple_regional/example.tf @@ -20,10 +20,6 @@ module "example" { project_id = var.project_ids[0] cluster_name_suffix = "-${random_string.suffix.result}" region = var.region - network = google_compute_network.main.name - subnetwork = google_compute_subnetwork.main.name - ip_range_pods = google_compute_subnetwork.main.secondary_ip_range[0].range_name - ip_range_services = google_compute_subnetwork.main.secondary_ip_range[1].range_name compute_engine_service_account = var.compute_engine_service_accounts[0] skip_provisioners = true enable_binary_authorization = true diff --git a/test/fixtures/simple_regional_private/example.tf b/test/fixtures/simple_regional_private/example.tf index e7c71a3c64..4a73a7a830 100644 --- a/test/fixtures/simple_regional_private/example.tf +++ b/test/fixtures/simple_regional_private/example.tf @@ -20,10 +20,6 @@ module "example" { project_id = var.project_ids[1] cluster_name_suffix = "-${random_string.suffix.result}" region = var.region - network = google_compute_network.main.name - subnetwork = google_compute_subnetwork.main.name - ip_range_pods = google_compute_subnetwork.main.secondary_ip_range[0].range_name - ip_range_services = google_compute_subnetwork.main.secondary_ip_range[1].range_name compute_engine_service_account = var.compute_engine_service_accounts[1] } diff --git a/test/fixtures/simple_regional_private/network.tf b/test/fixtures/simple_regional_private/network.tf deleted file mode 100644 index 8d643281e1..0000000000 --- a/test/fixtures/simple_regional_private/network.tf +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Copyright 2018 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -resource "random_string" "suffix" { - length = 4 - special = false - upper = false -} - -resource "google_compute_network" "main" { - project = var.project_ids[1] - name = "cft-gke-test-${random_string.suffix.result}" - auto_create_subnetworks = false -} - -resource "google_compute_subnetwork" "main" { - project = var.project_ids[1] - name = "cft-gke-test-${random_string.suffix.result}" - ip_cidr_range = "10.0.0.0/17" - region = var.region - network = google_compute_network.main.self_link - - secondary_ip_range { - range_name = "cft-gke-test-pods-${random_string.suffix.result}" - ip_cidr_range = "192.168.0.0/18" - } - - secondary_ip_range { - range_name = "cft-gke-test-services-${random_string.suffix.result}" - ip_cidr_range = "192.168.64.0/18" - } -} - diff --git a/test/fixtures/simple_regional_with_kubeconfig/example.tf b/test/fixtures/simple_regional_with_kubeconfig/example.tf index 85af7a5803..1cb54b7ecd 100644 --- a/test/fixtures/simple_regional_with_kubeconfig/example.tf +++ b/test/fixtures/simple_regional_with_kubeconfig/example.tf @@ -20,10 +20,6 @@ module "example" { project_id = var.project_ids[0] cluster_name_suffix = "-${random_string.suffix.result}" region = var.region - network = google_compute_network.main.name - subnetwork = google_compute_subnetwork.main.name - ip_range_pods = google_compute_subnetwork.main.secondary_ip_range[0].range_name - ip_range_services = google_compute_subnetwork.main.secondary_ip_range[1].range_name compute_engine_service_account = var.compute_engine_service_accounts[0] skip_provisioners = true } diff --git a/test/fixtures/simple_zonal_private/example.tf b/test/fixtures/simple_zonal_private/example.tf index 3ccce8ceab..be6832bb60 100644 --- a/test/fixtures/simple_zonal_private/example.tf +++ b/test/fixtures/simple_zonal_private/example.tf @@ -21,10 +21,6 @@ module "example" { cluster_name_suffix = "-${random_string.suffix.result}" region = var.region zones = slice(var.zones, 0, 1) - network = google_compute_network.main.name - subnetwork = google_compute_subnetwork.main.name - ip_range_pods = google_compute_subnetwork.main.secondary_ip_range[0].range_name - ip_range_services = google_compute_subnetwork.main.secondary_ip_range[1].range_name compute_engine_service_account = var.compute_engine_service_accounts[1] } diff --git a/test/fixtures/simple_zonal_private/network.tf b/test/fixtures/simple_zonal_private/network.tf deleted file mode 100644 index fc7de87ab4..0000000000 --- a/test/fixtures/simple_zonal_private/network.tf +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Copyright 2018 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -resource "random_string" "suffix" { - length = 4 - special = false - upper = false -} - - -resource "google_compute_network" "main" { - project = var.project_ids[1] - name = "cft-gke-test-${random_string.suffix.result}" - auto_create_subnetworks = false -} - -resource "google_compute_subnetwork" "main" { - project = var.project_ids[1] - name = "cft-gke-test-${random_string.suffix.result}" - ip_cidr_range = "10.0.0.0/17" - region = var.region - network = google_compute_network.main.self_link - - secondary_ip_range { - range_name = "cft-gke-test-pods-${random_string.suffix.result}" - ip_cidr_range = "192.168.0.0/18" - } - - secondary_ip_range { - range_name = "cft-gke-test-services-${random_string.suffix.result}" - ip_cidr_range = "192.168.64.0/18" - } -} - diff --git a/test/fixtures/simple_zonal_with_asm/example.tf b/test/fixtures/simple_zonal_with_asm/example.tf index 30df325bd1..1ab7a2c6e3 100644 --- a/test/fixtures/simple_zonal_with_asm/example.tf +++ b/test/fixtures/simple_zonal_with_asm/example.tf @@ -25,8 +25,4 @@ module "example" { cluster_name_suffix = "-${random_string.suffix.result}" region = var.region zones = slice(var.zones, 0, 1) - network = google_compute_network.main.name - subnetwork = google_compute_subnetwork.main.name - ip_range_pods = google_compute_subnetwork.main.secondary_ip_range[0].range_name - ip_range_services = google_compute_subnetwork.main.secondary_ip_range[1].range_name } diff --git a/test/fixtures/stub_domains/example.tf b/test/fixtures/stub_domains/example.tf index df31547535..ab929f49bc 100644 --- a/test/fixtures/stub_domains/example.tf +++ b/test/fixtures/stub_domains/example.tf @@ -20,10 +20,6 @@ module "example" { project_id = var.project_ids[1] cluster_name_suffix = "-${random_string.suffix.result}" region = var.region - network = google_compute_network.main.name - subnetwork = google_compute_subnetwork.main.name - ip_range_pods = google_compute_subnetwork.main.secondary_ip_range[0].range_name - ip_range_services = google_compute_subnetwork.main.secondary_ip_range[1].range_name compute_engine_service_account = var.compute_engine_service_accounts[1] } diff --git a/test/fixtures/stub_domains/network.tf b/test/fixtures/stub_domains/network.tf deleted file mode 100644 index a24129ec4f..0000000000 --- a/test/fixtures/stub_domains/network.tf +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Copyright 2018 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -resource "random_string" "suffix" { - length = 4 - special = false - upper = false -} - -provider "google" { - project = var.project_ids[1] -} - -resource "google_compute_network" "main" { - name = "cft-gke-test-${random_string.suffix.result}" - auto_create_subnetworks = false -} - -resource "google_compute_subnetwork" "main" { - name = "cft-gke-test-${random_string.suffix.result}" - ip_cidr_range = "10.0.0.0/17" - region = var.region - network = google_compute_network.main.self_link - - secondary_ip_range { - range_name = "cft-gke-test-pods-${random_string.suffix.result}" - ip_cidr_range = "192.168.0.0/18" - } - - secondary_ip_range { - range_name = "cft-gke-test-services-${random_string.suffix.result}" - ip_cidr_range = "192.168.64.0/18" - } -} - diff --git a/test/fixtures/stub_domains_upstream_nameservers/example.tf b/test/fixtures/stub_domains_upstream_nameservers/example.tf index a6923c0f13..ff1d907f5c 100644 --- a/test/fixtures/stub_domains_upstream_nameservers/example.tf +++ b/test/fixtures/stub_domains_upstream_nameservers/example.tf @@ -20,10 +20,6 @@ module "example" { project_id = var.project_ids[1] cluster_name_suffix = "-${random_string.suffix.result}" region = var.region - network = google_compute_network.main.name - subnetwork = google_compute_subnetwork.main.name - ip_range_pods = google_compute_subnetwork.main.secondary_ip_range[0].range_name - ip_range_services = google_compute_subnetwork.main.secondary_ip_range[1].range_name compute_engine_service_account = var.compute_engine_service_accounts[1] } diff --git a/test/fixtures/stub_domains_upstream_nameservers/network.tf b/test/fixtures/stub_domains_upstream_nameservers/network.tf deleted file mode 100644 index 8ec5389ade..0000000000 --- a/test/fixtures/stub_domains_upstream_nameservers/network.tf +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Copyright 2018 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -resource "random_string" "suffix" { - length = 4 - special = false - upper = false -} - -provider "google" { - project = var.project_ids[1] -} - -resource "google_compute_network" "main" { - name = "cft-gke-test-${random_string.suffix.result}" - auto_create_subnetworks = "false" -} - -resource "google_compute_subnetwork" "main" { - name = "cft-gke-test-${random_string.suffix.result}" - ip_cidr_range = "10.0.0.0/17" - region = var.region - network = google_compute_network.main.self_link - - secondary_ip_range { - range_name = "cft-gke-test-pods-${random_string.suffix.result}" - ip_cidr_range = "192.168.0.0/18" - } - - secondary_ip_range { - range_name = "cft-gke-test-services-${random_string.suffix.result}" - ip_cidr_range = "192.168.64.0/18" - } -} - diff --git a/test/fixtures/upstream_nameservers/example.tf b/test/fixtures/upstream_nameservers/example.tf index 81d60e8559..f7b4e5fb8b 100644 --- a/test/fixtures/upstream_nameservers/example.tf +++ b/test/fixtures/upstream_nameservers/example.tf @@ -20,10 +20,6 @@ module "example" { project_id = var.project_ids[1] cluster_name_suffix = "-${random_string.suffix.result}" region = var.region - network = google_compute_network.main.name - subnetwork = google_compute_subnetwork.main.name - ip_range_pods = google_compute_subnetwork.main.secondary_ip_range[0].range_name - ip_range_services = google_compute_subnetwork.main.secondary_ip_range[1].range_name compute_engine_service_account = var.compute_engine_service_accounts[1] } diff --git a/test/fixtures/upstream_nameservers/network.tf b/test/fixtures/upstream_nameservers/network.tf deleted file mode 100644 index 8ec5389ade..0000000000 --- a/test/fixtures/upstream_nameservers/network.tf +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Copyright 2018 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -resource "random_string" "suffix" { - length = 4 - special = false - upper = false -} - -provider "google" { - project = var.project_ids[1] -} - -resource "google_compute_network" "main" { - name = "cft-gke-test-${random_string.suffix.result}" - auto_create_subnetworks = "false" -} - -resource "google_compute_subnetwork" "main" { - name = "cft-gke-test-${random_string.suffix.result}" - ip_cidr_range = "10.0.0.0/17" - region = var.region - network = google_compute_network.main.self_link - - secondary_ip_range { - range_name = "cft-gke-test-pods-${random_string.suffix.result}" - ip_cidr_range = "192.168.0.0/18" - } - - secondary_ip_range { - range_name = "cft-gke-test-services-${random_string.suffix.result}" - ip_cidr_range = "192.168.64.0/18" - } -} - diff --git a/test/fixtures/workload_identity/example.tf b/test/fixtures/workload_identity/example.tf index 08263a7845..afed658de4 100644 --- a/test/fixtures/workload_identity/example.tf +++ b/test/fixtures/workload_identity/example.tf @@ -20,9 +20,5 @@ module "example" { project_id = var.project_ids[0] cluster_name_suffix = "-${random_string.suffix.result}" region = var.region - network = google_compute_network.main.name - subnetwork = google_compute_subnetwork.main.name - ip_range_pods = google_compute_subnetwork.main.secondary_ip_range[0].range_name - ip_range_services = google_compute_subnetwork.main.secondary_ip_range[1].range_name } diff --git a/test/fixtures/workload_identity/network.tf b/test/fixtures/workload_identity/network.tf deleted file mode 100644 index 94bb29e63c..0000000000 --- a/test/fixtures/workload_identity/network.tf +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Copyright 2018 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -resource "random_string" "suffix" { - length = 4 - special = false - upper = false -} - -provider "google" { - project = var.project_ids[0] -} - -resource "google_compute_network" "main" { - name = "cft-gke-test-${random_string.suffix.result}" - auto_create_subnetworks = false -} - -resource "google_compute_subnetwork" "main" { - name = "cft-gke-test-${random_string.suffix.result}" - ip_cidr_range = "10.0.0.0/17" - region = var.region - network = google_compute_network.main.self_link - - secondary_ip_range { - range_name = "cft-gke-test-pods-${random_string.suffix.result}" - ip_cidr_range = "192.168.0.0/18" - } - - secondary_ip_range { - range_name = "cft-gke-test-services-${random_string.suffix.result}" - ip_cidr_range = "192.168.64.0/18" - } -} - diff --git a/test/fixtures/workload_metadata_config/example.tf b/test/fixtures/workload_metadata_config/example.tf index ef9895c666..b6ddc9fc69 100644 --- a/test/fixtures/workload_metadata_config/example.tf +++ b/test/fixtures/workload_metadata_config/example.tf @@ -21,9 +21,5 @@ module "example" { cluster_name_suffix = "-${random_string.suffix.result}" region = var.region zones = slice(var.zones, 0, 1) - network = google_compute_network.main.name - subnetwork = google_compute_subnetwork.main.name - ip_range_pods = google_compute_subnetwork.main.secondary_ip_range[0].range_name - ip_range_services = google_compute_subnetwork.main.secondary_ip_range[1].range_name registry_project_ids = var.registry_project_ids } diff --git a/test/fixtures/workload_metadata_config/network.tf b/test/fixtures/workload_metadata_config/network.tf deleted file mode 100644 index f8a3322a65..0000000000 --- a/test/fixtures/workload_metadata_config/network.tf +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Copyright 2018 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -resource "random_string" "suffix" { - length = 4 - special = false - upper = false -} - -provider "google-beta" { - project = var.project_ids[1] -} - -resource "google_compute_network" "main" { - project = var.project_ids[1] - name = "cft-gke-test-${random_string.suffix.result}" - auto_create_subnetworks = "false" -} - -resource "google_compute_subnetwork" "main" { - project = var.project_ids[1] - name = "cft-gke-test-${random_string.suffix.result}" - ip_cidr_range = "10.0.0.0/17" - region = var.region - network = google_compute_network.main.self_link - - secondary_ip_range { - range_name = "cft-gke-test-pods-${random_string.suffix.result}" - ip_cidr_range = "192.168.0.0/18" - } - - secondary_ip_range { - range_name = "cft-gke-test-services-${random_string.suffix.result}" - ip_cidr_range = "192.168.64.0/18" - } -}