diff --git a/cluster_regional.tf b/cluster_regional.tf index 006a132159..baca766e7f 100644 --- a/cluster_regional.tf +++ b/cluster_regional.tf @@ -143,7 +143,7 @@ resource "null_resource" "wait_for_regional_cluster" { } provisioner "local-exec" { - when = "destroy" + when = "destroy" command = "${path.module}/scripts/wait-for-cluster.sh ${var.project_id} ${var.name}" } diff --git a/cluster_zonal.tf b/cluster_zonal.tf index 041664152f..7d55e8a9a7 100644 --- a/cluster_zonal.tf +++ b/cluster_zonal.tf @@ -143,7 +143,7 @@ resource "null_resource" "wait_for_zonal_cluster" { } provisioner "local-exec" { - when = "destroy" + when = "destroy" command = "${path.module}/scripts/wait-for-cluster.sh ${var.project_id} ${var.name}" } diff --git a/examples/deploy_service/main.tf b/examples/deploy_service/main.tf index cd1ddcacae..09d9c8bf35 100644 --- a/examples/deploy_service/main.tf +++ b/examples/deploy_service/main.tf @@ -33,14 +33,14 @@ provider "kubernetes" { data "google_client_config" "default" {} module "gke" { - source = "../../" - project_id = "${var.project_id}" - name = "${local.cluster_type}-cluster" - 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" + region = "${var.region}" + network = "${var.network}" + subnetwork = "${var.subnetwork}" + ip_range_pods = "${var.ip_range_pods}" + ip_range_services = "${var.ip_range_services}" kubernetes_version = "1.11.5-gke.4" service_account = "${var.compute_engine_service_account}" } diff --git a/examples/deploy_service/outputs.tf b/examples/deploy_service/outputs.tf index f08062730c..b48cab862e 100644 --- a/examples/deploy_service/outputs.tf +++ b/examples/deploy_service/outputs.tf @@ -25,5 +25,5 @@ output "client_token" { } output "ca_certificate" { - value = "${module.gke.ca_certificate}" + value = "${module.gke.ca_certificate}" } diff --git a/examples/node_pool/main.tf b/examples/node_pool/main.tf index da7ad50a3d..e02ec9f4b9 100644 --- a/examples/node_pool/main.tf +++ b/examples/node_pool/main.tf @@ -24,21 +24,21 @@ provider "google" { } module "gke" { - source = "../../" - project_id = "${var.project_id}" - name = "${local.cluster_type}-cluster" - 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" + region = "${var.region}" + network = "${var.network}" + subnetwork = "${var.subnetwork}" + ip_range_pods = "${var.ip_range_pods}" + ip_range_services = "${var.ip_range_services}" kubernetes_version = "1.11.5-gke.4" - node_version = "1.11.5-gke.4" + node_version = "1.11.5-gke.4" node_pools = [ { - name = "pool-01" - min_count = 4 + name = "pool-01" + min_count = 4 service_account = "${var.compute_engine_service_account}" }, { diff --git a/examples/node_pool/outputs.tf b/examples/node_pool/outputs.tf index f08062730c..b48cab862e 100644 --- a/examples/node_pool/outputs.tf +++ b/examples/node_pool/outputs.tf @@ -25,5 +25,5 @@ output "client_token" { } output "ca_certificate" { - value = "${module.gke.ca_certificate}" + value = "${module.gke.ca_certificate}" } diff --git a/examples/simple_regional/main.tf b/examples/simple_regional/main.tf index d468360ed3..23e3678c79 100644 --- a/examples/simple_regional/main.tf +++ b/examples/simple_regional/main.tf @@ -24,17 +24,17 @@ provider "google" { } module "gke" { - source = "../../" - project_id = "${var.project_id}" - name = "${local.cluster_type}-cluster" - 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}" + source = "../../" + project_id = "${var.project_id}" + name = "${local.cluster_type}-cluster" + 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}" kubernetes_version = "1.11.5-gke.4" - node_version = "1.11.5-gke.4" + node_version = "1.11.5-gke.4" service_account = "${var.compute_engine_service_account}" } diff --git a/examples/simple_regional/outputs.tf b/examples/simple_regional/outputs.tf index f08062730c..b48cab862e 100644 --- a/examples/simple_regional/outputs.tf +++ b/examples/simple_regional/outputs.tf @@ -25,5 +25,5 @@ output "client_token" { } output "ca_certificate" { - value = "${module.gke.ca_certificate}" + value = "${module.gke.ca_certificate}" } diff --git a/examples/simple_zonal/main.tf b/examples/simple_zonal/main.tf index 63cd0d4f4b..d5059dc8e7 100644 --- a/examples/simple_zonal/main.tf +++ b/examples/simple_zonal/main.tf @@ -24,18 +24,18 @@ provider "google" { } module "gke" { - source = "../../" - project_id = "${var.project_id}" - name = "${local.cluster_type}-cluster" - 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}" + source = "../../" + project_id = "${var.project_id}" + name = "${local.cluster_type}-cluster" + 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}" kubernetes_version = "1.11.4-gke.8" - node_version = "1.11.4-gke.8" + node_version = "1.11.4-gke.8" service_account = "${var.compute_engine_service_account}" } diff --git a/examples/simple_zonal/outputs.tf b/examples/simple_zonal/outputs.tf index f08062730c..b48cab862e 100644 --- a/examples/simple_zonal/outputs.tf +++ b/examples/simple_zonal/outputs.tf @@ -25,5 +25,5 @@ output "client_token" { } output "ca_certificate" { - value = "${module.gke.ca_certificate}" + value = "${module.gke.ca_certificate}" } diff --git a/examples/stub_domains/main.tf b/examples/stub_domains/main.tf index 57265702bb..d5b8fbe1a0 100644 --- a/examples/stub_domains/main.tf +++ b/examples/stub_domains/main.tf @@ -24,17 +24,17 @@ provider "google" { } module "gke" { - source = "../../" - project_id = "${var.project_id}" - name = "${local.cluster_type}-cluster" - region = "${var.region}" - network = "${var.network}" - subnetwork = "${var.subnetwork}" - ip_range_pods = "${var.ip_range_pods}" - ip_range_services = "${var.ip_range_services}" - network_policy = true + source = "../../" + project_id = "${var.project_id}" + name = "${local.cluster_type}-cluster" + region = "${var.region}" + network = "${var.network}" + subnetwork = "${var.subnetwork}" + ip_range_pods = "${var.ip_range_pods}" + ip_range_services = "${var.ip_range_services}" + network_policy = true kubernetes_version = "1.11.5-gke.4" - node_version = "1.11.5-gke.4" + node_version = "1.11.5-gke.4" service_account = "${var.compute_engine_service_account}" stub_domains { diff --git a/examples/stub_domains/outputs.tf b/examples/stub_domains/outputs.tf index f08062730c..b48cab862e 100644 --- a/examples/stub_domains/outputs.tf +++ b/examples/stub_domains/outputs.tf @@ -25,5 +25,5 @@ output "client_token" { } output "ca_certificate" { - value = "${module.gke.ca_certificate}" + value = "${module.gke.ca_certificate}" } diff --git a/main.tf b/main.tf index 74b93940fe..c9107d18ec 100644 --- a/main.tf +++ b/main.tf @@ -23,7 +23,7 @@ data "google_compute_zones" "available" { } resource "random_shuffle" "available_zones" { - input = ["${data.google_compute_zones.available.names}"] + input = ["${data.google_compute_zones.available.names}"] result_count = 3 } diff --git a/test/fixtures/deploy_service/example.tf b/test/fixtures/deploy_service/example.tf index 3cc994a768..5b9fe4a56b 100644 --- a/test/fixtures/deploy_service/example.tf +++ b/test/fixtures/deploy_service/example.tf @@ -17,12 +17,12 @@ module "example" { source = "../../../examples/deploy_service" - project_id = "${var.project_id}" - credentials_path = "${local.credentials_path}" - 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}" + project_id = "${var.project_id}" + credentials_path = "${local.credentials_path}" + 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_account}" } diff --git a/test/fixtures/deploy_service/network.tf b/test/fixtures/deploy_service/network.tf index 6a6325ab2d..64dfbf8aeb 100644 --- a/test/fixtures/deploy_service/network.tf +++ b/test/fixtures/deploy_service/network.tf @@ -19,32 +19,34 @@ locals { } resource "random_string" "suffix" { - length = 4 + length = 4 special = false - upper = false + upper = false } provider "google" { credentials = "${file(local.credentials_path)}" - project = "${var.project_id}" + project = "${var.project_id}" } resource "google_compute_network" "main" { - name = "cft-gke-test-${random_string.suffix.result}" + 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}" + 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}" + region = "${var.region}" + network = "${google_compute_network.main.self_link}" + secondary_ip_range { - range_name = "cft-gke-test-pods-${random_string.suffix.result}" + 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}" + range_name = "cft-gke-test-services-${random_string.suffix.result}" ip_cidr_range = "192.168.64.0/18" } } diff --git a/test/fixtures/node_pool/example.tf b/test/fixtures/node_pool/example.tf index 3e7b1ea609..84c47fa3af 100644 --- a/test/fixtures/node_pool/example.tf +++ b/test/fixtures/node_pool/example.tf @@ -17,12 +17,12 @@ module "example" { source = "../../../examples/node_pool" - project_id = "${var.project_id}" - credentials_path = "${local.credentials_path}" - 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}" + project_id = "${var.project_id}" + credentials_path = "${local.credentials_path}" + 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_account}" } diff --git a/test/fixtures/node_pool/network.tf b/test/fixtures/node_pool/network.tf index 6a6325ab2d..64dfbf8aeb 100644 --- a/test/fixtures/node_pool/network.tf +++ b/test/fixtures/node_pool/network.tf @@ -19,32 +19,34 @@ locals { } resource "random_string" "suffix" { - length = 4 + length = 4 special = false - upper = false + upper = false } provider "google" { credentials = "${file(local.credentials_path)}" - project = "${var.project_id}" + project = "${var.project_id}" } resource "google_compute_network" "main" { - name = "cft-gke-test-${random_string.suffix.result}" + 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}" + 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}" + region = "${var.region}" + network = "${google_compute_network.main.self_link}" + secondary_ip_range { - range_name = "cft-gke-test-pods-${random_string.suffix.result}" + 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}" + 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 5cfbc3e106..3af8e16983 100644 --- a/test/fixtures/shared/outputs.tf +++ b/test/fixtures/shared/outputs.tf @@ -75,5 +75,5 @@ output "client_token" { output "ca_certificate" { description = "The cluster CA certificate" - value = "${module.example.ca_certificate}" + value = "${module.example.ca_certificate}" } diff --git a/test/fixtures/shared/variables.tf b/test/fixtures/shared/variables.tf index 8f4e02b783..1a4da7a2b7 100644 --- a/test/fixtures/shared/variables.tf +++ b/test/fixtures/shared/variables.tf @@ -14,23 +14,15 @@ * limitations under the License. */ -variable "project_id" { +variable "project_id" {} -} - -variable "credentials_path_relative" { - -} +variable "credentials_path_relative" {} -variable "region" { - -} +variable "region" {} variable "zones" { - type = "list" + type = "list" default = [] } -variable "compute_engine_service_account" { - -} +variable "compute_engine_service_account" {} diff --git a/test/fixtures/simple_regional/example.tf b/test/fixtures/simple_regional/example.tf index 797ba2e303..72a197218f 100644 --- a/test/fixtures/simple_regional/example.tf +++ b/test/fixtures/simple_regional/example.tf @@ -17,12 +17,12 @@ module "example" { source = "../../../examples/simple_regional" - project_id = "${var.project_id}" - credentials_path = "${local.credentials_path}" - 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}" + project_id = "${var.project_id}" + credentials_path = "${local.credentials_path}" + 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_account}" } diff --git a/test/fixtures/simple_regional/network.tf b/test/fixtures/simple_regional/network.tf index 6a6325ab2d..64dfbf8aeb 100644 --- a/test/fixtures/simple_regional/network.tf +++ b/test/fixtures/simple_regional/network.tf @@ -19,32 +19,34 @@ locals { } resource "random_string" "suffix" { - length = 4 + length = 4 special = false - upper = false + upper = false } provider "google" { credentials = "${file(local.credentials_path)}" - project = "${var.project_id}" + project = "${var.project_id}" } resource "google_compute_network" "main" { - name = "cft-gke-test-${random_string.suffix.result}" + 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}" + 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}" + region = "${var.region}" + network = "${google_compute_network.main.self_link}" + secondary_ip_range { - range_name = "cft-gke-test-pods-${random_string.suffix.result}" + 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}" + 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/example.tf b/test/fixtures/simple_zonal/example.tf index 3115dbab5d..c962c555e0 100644 --- a/test/fixtures/simple_zonal/example.tf +++ b/test/fixtures/simple_zonal/example.tf @@ -17,13 +17,13 @@ module "example" { source = "../../../examples/simple_zonal" - project_id = "${var.project_id}" - credentials_path = "${local.credentials_path}" - region = "${var.region}" - zones = ["${var.zones}"] - 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}" + project_id = "${var.project_id}" + credentials_path = "${local.credentials_path}" + region = "${var.region}" + zones = ["${var.zones}"] + 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_account}" } diff --git a/test/fixtures/simple_zonal/network.tf b/test/fixtures/simple_zonal/network.tf index 6a6325ab2d..64dfbf8aeb 100644 --- a/test/fixtures/simple_zonal/network.tf +++ b/test/fixtures/simple_zonal/network.tf @@ -19,32 +19,34 @@ locals { } resource "random_string" "suffix" { - length = 4 + length = 4 special = false - upper = false + upper = false } provider "google" { credentials = "${file(local.credentials_path)}" - project = "${var.project_id}" + project = "${var.project_id}" } resource "google_compute_network" "main" { - name = "cft-gke-test-${random_string.suffix.result}" + 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}" + 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}" + region = "${var.region}" + network = "${google_compute_network.main.self_link}" + secondary_ip_range { - range_name = "cft-gke-test-pods-${random_string.suffix.result}" + 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}" + 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/example.tf b/test/fixtures/stub_domains/example.tf index a010556342..bcc0a440f8 100644 --- a/test/fixtures/stub_domains/example.tf +++ b/test/fixtures/stub_domains/example.tf @@ -17,12 +17,12 @@ module "example" { source = "../../../examples/stub_domains" - project_id = "${var.project_id}" - credentials_path = "${local.credentials_path}" - 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}" + project_id = "${var.project_id}" + credentials_path = "${local.credentials_path}" + 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_account}" } diff --git a/test/fixtures/stub_domains/network.tf b/test/fixtures/stub_domains/network.tf index 6a6325ab2d..64dfbf8aeb 100644 --- a/test/fixtures/stub_domains/network.tf +++ b/test/fixtures/stub_domains/network.tf @@ -19,32 +19,34 @@ locals { } resource "random_string" "suffix" { - length = 4 + length = 4 special = false - upper = false + upper = false } provider "google" { credentials = "${file(local.credentials_path)}" - project = "${var.project_id}" + project = "${var.project_id}" } resource "google_compute_network" "main" { - name = "cft-gke-test-${random_string.suffix.result}" + 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}" + 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}" + region = "${var.region}" + network = "${google_compute_network.main.self_link}" + secondary_ip_range { - range_name = "cft-gke-test-pods-${random_string.suffix.result}" + 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}" + range_name = "cft-gke-test-services-${random_string.suffix.result}" ip_cidr_range = "192.168.64.0/18" } } diff --git a/test/make.sh b/test/make.sh index 6976b26497..9f640bcf74 100755 --- a/test/make.sh +++ b/test/make.sh @@ -49,6 +49,8 @@ function check_terraform() { echo "Running terraform validate" #shellcheck disable=SC2156 find . -name "*.tf" -not -path "./test/fixtures/shared/*" -not -path "./test/fixtures/all_examples/*" -exec bash -c 'terraform validate --check-variables=false $(dirname "{}")' \; + echo "Running terraform fmt" + terraform fmt -check=true -write=false } # This function runs 'go fmt' and 'go vet' on every file diff --git a/variables.tf b/variables.tf index 6a9931e29b..c0d6a0a977 100644 --- a/variables.tf +++ b/variables.tf @@ -192,5 +192,5 @@ variable "monitoring_service" { variable "service_account" { description = "The service account to default running nodes as if not overridden in `node_pools`. Defaults to the compute engine default service account" - default = "" + default = "" }