diff --git a/examples/compute_instance/simple/README.md b/examples/compute_instance/simple/README.md index 6c50f794..e7b47ae0 100644 --- a/examples/compute_instance/simple/README.md +++ b/examples/compute_instance/simple/README.md @@ -7,10 +7,9 @@ This is a simple, minimal example of how to use the compute_instance module | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| -| credentials\_path | The path to the GCP credentials JSON file | string | n/a | yes | | num\_instances | Number of instances to create | string | n/a | yes | | project\_id | The GCP project to use for integration tests | string | n/a | yes | -| region | The GCP region to create and test resources in | string | n/a | yes | +| region | The GCP region to create and test resources in | string | `"us-central1"` | no | | service\_account | Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template.html#service_account. | object | `"null"` | no | | subnetwork | The subnetwork to host the compute instances in | string | n/a | yes | diff --git a/examples/compute_instance/simple/main.tf b/examples/compute_instance/simple/main.tf index 9186dd2e..f02545ae 100644 --- a/examples/compute_instance/simple/main.tf +++ b/examples/compute_instance/simple/main.tf @@ -15,10 +15,10 @@ */ provider "google" { - credentials = file(var.credentials_path) - project = var.project_id - region = var.region - version = "~> 2.7.0" + + project = var.project_id + region = var.region + version = "~> 2.7.0" } module "instance_template" { diff --git a/examples/compute_instance/simple/variables.tf b/examples/compute_instance/simple/variables.tf index 323d586e..c61355eb 100644 --- a/examples/compute_instance/simple/variables.tf +++ b/examples/compute_instance/simple/variables.tf @@ -1,5 +1,5 @@ /** - * Copyright 2018 Google LLC + * 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. @@ -14,16 +14,17 @@ * limitations under the License. */ -variable "credentials_path" { - description = "The path to the GCP credentials JSON file" -} + variable "project_id" { description = "The GCP project to use for integration tests" + type = string } variable "region" { description = "The GCP region to create and test resources in" + type = string + default = "us-central1" } variable "subnetwork" { @@ -34,6 +35,8 @@ variable "num_instances" { description = "Number of instances to create" } + + variable "service_account" { default = null type = object({ diff --git a/examples/instance_template/additional_disks/README.md b/examples/instance_template/additional_disks/README.md index cbf8443a..05ebed3f 100644 --- a/examples/instance_template/additional_disks/README.md +++ b/examples/instance_template/additional_disks/README.md @@ -8,9 +8,8 @@ instance templates with additional persistent disks. | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| -| credentials\_path | The path to the GCP credentials JSON file | string | n/a | yes | | project\_id | The GCP project to use for integration tests | string | n/a | yes | -| region | The GCP region to create and test resources in | string | n/a | yes | +| region | The GCP region to create and test resources in | string | `"us-central1"` | no | | service\_account | Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template.html#service_account. | object | `"null"` | no | | subnetwork | The name of the subnetwork create this instance in. | string | `""` | no | diff --git a/examples/instance_template/additional_disks/main.tf b/examples/instance_template/additional_disks/main.tf index ba1135cb..5b20234d 100644 --- a/examples/instance_template/additional_disks/main.tf +++ b/examples/instance_template/additional_disks/main.tf @@ -15,10 +15,10 @@ */ provider "google" { - credentials = file(var.credentials_path) - project = var.project_id - region = var.region - version = "~> 2.7.0" + + project = var.project_id + region = var.region + version = "~> 2.7.0" } module "instance_template" { diff --git a/examples/instance_template/additional_disks/variables.tf b/examples/instance_template/additional_disks/variables.tf index 7b6c95f2..b9f30007 100644 --- a/examples/instance_template/additional_disks/variables.tf +++ b/examples/instance_template/additional_disks/variables.tf @@ -1,5 +1,5 @@ /** - * Copyright 2018 Google LLC + * 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. @@ -14,16 +14,17 @@ * limitations under the License. */ -variable "credentials_path" { - description = "The path to the GCP credentials JSON file" -} + variable "project_id" { description = "The GCP project to use for integration tests" + type = string } variable "region" { description = "The GCP region to create and test resources in" + type = string + default = "us-central1" } variable "subnetwork" { diff --git a/examples/instance_template/simple/README.md b/examples/instance_template/simple/README.md index ab10f0db..56d19aea 100644 --- a/examples/instance_template/simple/README.md +++ b/examples/instance_template/simple/README.md @@ -7,10 +7,9 @@ This is a simple, minimal example of how to use the instance_template module. | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| -| credentials\_path | The path to the GCP credentials JSON file | string | n/a | yes | | labels | Labels, provided as a map | map(string) | n/a | yes | | project\_id | The GCP project to use for integration tests | string | n/a | yes | -| region | The GCP region to create and test resources in | string | n/a | yes | +| region | The GCP region to create and test resources in | string | `"us-central1"` | no | | service\_account | Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template.html#service_account. | object | `"null"` | no | | subnetwork | The name of the subnetwork create this instance in. | string | `""` | no | | tags | Network tags, provided as a list | list(string) | n/a | yes | diff --git a/examples/instance_template/simple/main.tf b/examples/instance_template/simple/main.tf index cf7d457a..3c3614c8 100644 --- a/examples/instance_template/simple/main.tf +++ b/examples/instance_template/simple/main.tf @@ -15,10 +15,10 @@ */ provider "google" { - credentials = file(var.credentials_path) - project = var.project_id - region = var.region - version = "~> 2.7.0" + + project = var.project_id + region = var.region + version = "~> 2.7.0" } resource "google_compute_address" "ip_address" { diff --git a/examples/instance_template/simple/variables.tf b/examples/instance_template/simple/variables.tf index 9d6526bb..091255a1 100644 --- a/examples/instance_template/simple/variables.tf +++ b/examples/instance_template/simple/variables.tf @@ -1,5 +1,5 @@ /** - * Copyright 2018 Google LLC + * 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. @@ -14,16 +14,17 @@ * limitations under the License. */ -variable "credentials_path" { - description = "The path to the GCP credentials JSON file" -} + variable "project_id" { description = "The GCP project to use for integration tests" + type = string } variable "region" { description = "The GCP region to create and test resources in" + type = string + default = "us-central1" } variable "subnetwork" { diff --git a/examples/mig/autoscaler/README.md b/examples/mig/autoscaler/README.md index c45aecf3..dac2fbd7 100644 --- a/examples/mig/autoscaler/README.md +++ b/examples/mig/autoscaler/README.md @@ -10,10 +10,9 @@ group with an autoscaler. |------|-------------|:----:|:-----:|:-----:| | autoscaling\_cpu | Autoscaling, cpu utilization policy block as single element array. https://www.terraform.io/docs/providers/google/r/compute_autoscaler.html#cpu_utilization | list(map(number)) | n/a | yes | | autoscaling\_enabled | Creates an autoscaler for the managed instance group | string | n/a | yes | -| credentials\_path | The path to the GCP credentials JSON file | string | n/a | yes | | min\_replicas | The minimum number of replicas that the autoscaler can scale down to. This cannot be less than 0. | string | n/a | yes | | project\_id | The GCP project to use for integration tests | string | n/a | yes | -| region | The GCP region to create and test resources in | string | n/a | yes | +| region | The GCP region to create and test resources in | string | `"us-central1"` | no | | service\_account | Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template.html#service_account. | object | `"null"` | no | | subnetwork | The subnetwork to host the compute instances in | string | n/a | yes | @@ -23,5 +22,6 @@ group with an autoscaler. |------|-------------| | instance\_template\_self\_link | Self-link of instance template | | mig\_self\_link | Self-link for managed instance group | +| region | The GCP region to create and test resources in | diff --git a/examples/mig/autoscaler/main.tf b/examples/mig/autoscaler/main.tf index 69ebda89..011ae327 100644 --- a/examples/mig/autoscaler/main.tf +++ b/examples/mig/autoscaler/main.tf @@ -15,17 +15,17 @@ */ provider "google" { - credentials = file(var.credentials_path) - project = var.project_id - region = var.region - version = "~> 2.7.0" + + project = var.project_id + region = var.region + version = "~> 2.7.0" } provider "google-beta" { - credentials = file(var.credentials_path) - project = var.project_id - region = var.region - version = "~> 2.7.0" + + project = var.project_id + region = var.region + version = "~> 2.7.0" } module "instance_template" { diff --git a/examples/mig/autoscaler/outputs.tf b/examples/mig/autoscaler/outputs.tf index e4626393..6527e643 100644 --- a/examples/mig/autoscaler/outputs.tf +++ b/examples/mig/autoscaler/outputs.tf @@ -24,3 +24,7 @@ output "mig_self_link" { value = module.mig.self_link } +output "region" { + description = "The GCP region to create and test resources in" + value = var.region +} diff --git a/examples/mig/autoscaler/variables.tf b/examples/mig/autoscaler/variables.tf index aff98f52..e62f7b80 100644 --- a/examples/mig/autoscaler/variables.tf +++ b/examples/mig/autoscaler/variables.tf @@ -1,5 +1,5 @@ /** - * Copyright 2018 Google LLC + * 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. @@ -14,16 +14,17 @@ * limitations under the License. */ -variable "credentials_path" { - description = "The path to the GCP credentials JSON file" -} + variable "project_id" { description = "The GCP project to use for integration tests" + type = string } variable "region" { description = "The GCP region to create and test resources in" + type = string + default = "us-central1" } variable "subnetwork" { diff --git a/examples/mig/full/main.tf b/examples/mig/full/main.tf index 7135f265..9be5b169 100644 --- a/examples/mig/full/main.tf +++ b/examples/mig/full/main.tf @@ -15,17 +15,17 @@ */ provider "google" { - credentials = file(var.credentials_path) - project = var.project_id - region = var.region - version = "~> 2.7.0" + + project = var.project_id + region = var.region + version = "~> 2.7.0" } provider "google-beta" { - credentials = file(var.credentials_path) - project = var.project_id - region = var.region - version = "~> 2.7.0" + + project = var.project_id + region = var.region + version = "~> 2.7.0" } module "instance_template" { diff --git a/examples/mig/full/variables.tf b/examples/mig/full/variables.tf index f0b2d34e..f8b22759 100644 --- a/examples/mig/full/variables.tf +++ b/examples/mig/full/variables.tf @@ -1,5 +1,5 @@ /** - * Copyright 2018 Google LLC + * 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. @@ -25,6 +25,8 @@ variable "hostname" { variable "region" { description = "The GCP region where instances will be deployed." + type = string + default = "us-central1" } variable "network" { @@ -39,12 +41,10 @@ variable "subnetwork" { variable "project_id" { description = "The GCP project to use for integration tests" + type = string } -variable "credentials_path" { - description = "The path to the GCP credentials JSON file" - default = "" -} + variable "subnetwork_project" { description = "The project that subnetwork belongs to" diff --git a/examples/mig/simple/README.md b/examples/mig/simple/README.md index de7dfd4b..d0250dd7 100644 --- a/examples/mig/simple/README.md +++ b/examples/mig/simple/README.md @@ -8,9 +8,8 @@ managed instance group. | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| -| credentials\_path | The path to the GCP credentials JSON file | string | n/a | yes | | project\_id | The GCP project to use for integration tests | string | n/a | yes | -| region | The GCP region to create and test resources in | string | n/a | yes | +| region | The GCP region to create and test resources in | string | `"us-central1"` | no | | service\_account | Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template.html#service_account. | object | `"null"` | no | | subnetwork | The subnetwork to host the compute instances in | string | n/a | yes | | target\_size | The target number of running instances for this managed instance group. This value should always be explicitly set unless this resource is attached to an autoscaler, in which case it should never be set. | string | n/a | yes | @@ -19,6 +18,7 @@ managed instance group. | Name | Description | |------|-------------| +| region | The GCP region to create and test resources in | | self\_link | Self-link of the managed instance group | diff --git a/examples/mig/simple/main.tf b/examples/mig/simple/main.tf index 84716be1..fbc0bf4d 100644 --- a/examples/mig/simple/main.tf +++ b/examples/mig/simple/main.tf @@ -15,15 +15,15 @@ */ provider "google" { - credentials = file(var.credentials_path) - region = var.region - version = "~> 2.7.0" + + region = var.region + version = "~> 2.7.0" } provider "google-beta" { - credentials = file(var.credentials_path) - region = var.region - version = "~> 2.7.0" + + region = var.region + version = "~> 2.7.0" } module "instance_template" { diff --git a/examples/mig/simple/outputs.tf b/examples/mig/simple/outputs.tf index 23b81662..2107246d 100644 --- a/examples/mig/simple/outputs.tf +++ b/examples/mig/simple/outputs.tf @@ -19,3 +19,7 @@ output "self_link" { value = module.mig.self_link } +output "region" { + description = "The GCP region to create and test resources in" + value = var.region +} diff --git a/examples/mig/simple/variables.tf b/examples/mig/simple/variables.tf index 32589f68..80a7a34b 100644 --- a/examples/mig/simple/variables.tf +++ b/examples/mig/simple/variables.tf @@ -1,5 +1,5 @@ /** - * Copyright 2018 Google LLC + * 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. @@ -14,16 +14,17 @@ * limitations under the License. */ -variable "credentials_path" { - description = "The path to the GCP credentials JSON file" -} + variable "project_id" { description = "The GCP project to use for integration tests" + type = string } variable "region" { description = "The GCP region to create and test resources in" + type = string + default = "us-central1" } variable "subnetwork" { diff --git a/examples/mig_with_percent/simple/README.md b/examples/mig_with_percent/simple/README.md index 518fd922..8752f103 100644 --- a/examples/mig_with_percent/simple/README.md +++ b/examples/mig_with_percent/simple/README.md @@ -8,9 +8,8 @@ managed instance group. | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| -| credentials\_path | The path to the GCP credentials JSON file | string | n/a | yes | | project\_id | The GCP project to use for integration tests | string | n/a | yes | -| region | The GCP region to create and test resources in | string | n/a | yes | +| region | The GCP region to create and test resources in | string | `"us-central1"` | no | | service\_account | Service account email address and scopes | object | `"null"` | no | | subnetwork | The subnetwork to host the compute instances in | string | n/a | yes | @@ -18,6 +17,7 @@ managed instance group. | Name | Description | |------|-------------| +| region | The GCP region to create and test resources in | | self\_link | Self-link of the managed instance group | diff --git a/examples/mig_with_percent/simple/main.tf b/examples/mig_with_percent/simple/main.tf index 00066d0c..1dff631b 100644 --- a/examples/mig_with_percent/simple/main.tf +++ b/examples/mig_with_percent/simple/main.tf @@ -15,17 +15,17 @@ */ provider "google" { - credentials = file(var.credentials_path) - project = var.project_id - region = var.region - version = "~> 2.11" + + project = var.project_id + region = var.region + version = "~> 2.11" } provider "google-beta" { - credentials = file(var.credentials_path) - project = var.project_id - region = var.region - version = "~> 2.11" + + project = var.project_id + region = var.region + version = "~> 2.11" } module "preemptible_and_regular_instance_templates" { diff --git a/examples/mig_with_percent/simple/outputs.tf b/examples/mig_with_percent/simple/outputs.tf index b371fecb..2ae552b3 100644 --- a/examples/mig_with_percent/simple/outputs.tf +++ b/examples/mig_with_percent/simple/outputs.tf @@ -18,3 +18,8 @@ output "self_link" { description = "Self-link of the managed instance group" value = module.mig_with_percent.self_link } + +output "region" { + description = "The GCP region to create and test resources in" + value = var.region +} diff --git a/examples/mig_with_percent/simple/variables.tf b/examples/mig_with_percent/simple/variables.tf index 028a40a3..538a2ac6 100644 --- a/examples/mig_with_percent/simple/variables.tf +++ b/examples/mig_with_percent/simple/variables.tf @@ -1,5 +1,5 @@ /** - * Copyright 2018 Google LLC + * 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. @@ -14,16 +14,17 @@ * limitations under the License. */ -variable "credentials_path" { - description = "The path to the GCP credentials JSON file" -} + variable "project_id" { description = "The GCP project to use for integration tests" + type = string } variable "region" { description = "The GCP region to create and test resources in" + type = string + default = "us-central1" } variable "subnetwork" { diff --git a/examples/preemptible_and_regular_instance_templates/simple/README.md b/examples/preemptible_and_regular_instance_templates/simple/README.md index 4616f565..e57bfa50 100644 --- a/examples/preemptible_and_regular_instance_templates/simple/README.md +++ b/examples/preemptible_and_regular_instance_templates/simple/README.md @@ -7,10 +7,9 @@ This creates instance templates for both preemptible VM and regular VM | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| -| credentials\_path | The path to the GCP credentials JSON file | string | n/a | yes | | labels | Labels, provided as a map | map(string) | n/a | yes | | project\_id | The GCP project to use for integration tests | string | n/a | yes | -| region | The GCP region to create and test resources in | string | n/a | yes | +| region | The GCP region to create and test resources in | string | `"us-central1"` | no | | service\_account | Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template.html#service_account. | object | `"null"` | no | | subnetwork | The name of the subnetwork create this instance in. | string | `""` | no | | tags | Network tags, provided as a list | list(string) | n/a | yes | diff --git a/examples/preemptible_and_regular_instance_templates/simple/main.tf b/examples/preemptible_and_regular_instance_templates/simple/main.tf index b8625939..3645c03f 100644 --- a/examples/preemptible_and_regular_instance_templates/simple/main.tf +++ b/examples/preemptible_and_regular_instance_templates/simple/main.tf @@ -15,10 +15,10 @@ */ provider "google" { - credentials = file(var.credentials_path) - project = var.project_id - region = var.region - version = "~> 2.11" + + project = var.project_id + region = var.region + version = "~> 2.11" } module "preemptible_and_regular_instance_templates" { diff --git a/examples/preemptible_and_regular_instance_templates/simple/variables.tf b/examples/preemptible_and_regular_instance_templates/simple/variables.tf index 1565e71a..ba55c686 100644 --- a/examples/preemptible_and_regular_instance_templates/simple/variables.tf +++ b/examples/preemptible_and_regular_instance_templates/simple/variables.tf @@ -1,5 +1,5 @@ /** - * Copyright 2018 Google LLC + * 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. @@ -14,16 +14,17 @@ * limitations under the License. */ -variable "credentials_path" { - description = "The path to the GCP credentials JSON file" -} + variable "project_id" { description = "The GCP project to use for integration tests" + type = string } variable "region" { description = "The GCP region to create and test resources in" + type = string + default = "us-central1" } variable "subnetwork" { diff --git a/examples/umig/full/main.tf b/examples/umig/full/main.tf index 3f4ce5c7..419523cf 100644 --- a/examples/umig/full/main.tf +++ b/examples/umig/full/main.tf @@ -15,10 +15,10 @@ */ provider "google" { - credentials = file(var.credentials_path) - project = var.project_id - region = var.region - version = "~> 2.7.0" + + project = var.project_id + region = var.region + version = "~> 2.7.0" } module "instance_template" { diff --git a/examples/umig/full/variables.tf b/examples/umig/full/variables.tf index 6fe35323..0330137f 100644 --- a/examples/umig/full/variables.tf +++ b/examples/umig/full/variables.tf @@ -1,5 +1,5 @@ /** - * Copyright 2018 Google LLC + * 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. @@ -20,12 +20,10 @@ variable "project_id" { description = "The GCP project to use for integration tests" + type = string } -variable "credentials_path" { - description = "The path to the GCP credentials JSON file" - default = "" -} + variable "hostname" { description = "Hostname prefix for instances." @@ -34,6 +32,8 @@ variable "hostname" { variable "region" { description = "The GCP region where instances will be deployed." + type = string + default = "us-central1" } variable "network" { diff --git a/examples/umig/named_ports/README.md b/examples/umig/named_ports/README.md index a0c96c4f..9fb0d029 100644 --- a/examples/umig/named_ports/README.md +++ b/examples/umig/named_ports/README.md @@ -8,11 +8,10 @@ groups with named ports | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| -| credentials\_path | The path to the GCP credentials JSON file | string | n/a | yes | | named\_ports | Named name and named port | object | `` | no | | num\_instances | Number of instances to create | string | n/a | yes | | project\_id | The GCP project to use for integration tests | string | n/a | yes | -| region | The GCP region to create and test resources in | string | n/a | yes | +| region | The GCP region to create and test resources in | string | `"us-central1"` | no | | service\_account | Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template.html#service_account. | object | `"null"` | no | | subnetwork | The subnetwork to host the compute instances in | string | n/a | yes | diff --git a/examples/umig/named_ports/main.tf b/examples/umig/named_ports/main.tf index 141a595f..31288fda 100644 --- a/examples/umig/named_ports/main.tf +++ b/examples/umig/named_ports/main.tf @@ -15,10 +15,10 @@ */ provider "google" { - credentials = file(var.credentials_path) - project = var.project_id - region = var.region - version = "~> 2.7.0" + + project = var.project_id + region = var.region + version = "~> 2.7.0" } module "instance_template" { diff --git a/examples/umig/named_ports/variables.tf b/examples/umig/named_ports/variables.tf index 4990cabb..5dca4f0a 100644 --- a/examples/umig/named_ports/variables.tf +++ b/examples/umig/named_ports/variables.tf @@ -1,5 +1,5 @@ /** - * Copyright 2018 Google LLC + * 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. @@ -14,16 +14,17 @@ * limitations under the License. */ -variable "credentials_path" { - description = "The path to the GCP credentials JSON file" -} + variable "project_id" { description = "The GCP project to use for integration tests" + type = string } variable "region" { description = "The GCP region to create and test resources in" + type = string + default = "us-central1" } variable "subnetwork" { diff --git a/examples/umig/simple/README.md b/examples/umig/simple/README.md index 94a18b5d..cced24a6 100644 --- a/examples/umig/simple/README.md +++ b/examples/umig/simple/README.md @@ -7,10 +7,9 @@ This is a simple, minimal example of how to use the UMIG module | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| -| credentials\_path | The path to the GCP credentials JSON file | string | n/a | yes | | num\_instances | Number of instances to create | string | n/a | yes | | project\_id | The GCP project to use for integration tests | string | n/a | yes | -| region | The GCP region to create and test resources in | string | n/a | yes | +| region | The GCP region to create and test resources in | string | `"us-central1"` | no | | service\_account | Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template.html#service_account. | object | `"null"` | no | | subnetwork | The subnetwork to host the compute instances in | string | n/a | yes | diff --git a/examples/umig/simple/main.tf b/examples/umig/simple/main.tf index 6dc15eb7..d742a67c 100644 --- a/examples/umig/simple/main.tf +++ b/examples/umig/simple/main.tf @@ -15,10 +15,10 @@ */ provider "google" { - credentials = file(var.credentials_path) - project = var.project_id - region = var.region - version = "~> 2.7.0" + + project = var.project_id + region = var.region + version = "~> 2.7.0" } module "instance_template" { diff --git a/examples/umig/simple/variables.tf b/examples/umig/simple/variables.tf index a3cffd92..685ec328 100644 --- a/examples/umig/simple/variables.tf +++ b/examples/umig/simple/variables.tf @@ -1,5 +1,5 @@ /** - * Copyright 2018 Google LLC + * 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. @@ -14,16 +14,17 @@ * limitations under the License. */ -variable "credentials_path" { - description = "The path to the GCP credentials JSON file" -} + variable "project_id" { description = "The GCP project to use for integration tests" + type = string } variable "region" { description = "The GCP region to create and test resources in" + type = string + default = "us-central1" } variable "subnetwork" { diff --git a/examples/umig/static_ips/README.md b/examples/umig/static_ips/README.md index 08c54605..d4ea211d 100644 --- a/examples/umig/static_ips/README.md +++ b/examples/umig/static_ips/README.md @@ -8,10 +8,9 @@ instance groups with user-specified static IPs. | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| -| credentials\_path | The path to the GCP credentials JSON file | string | n/a | yes | | num\_instances | Number of instances to create | string | `"1"` | no | | project\_id | The GCP project to use for integration tests | string | n/a | yes | -| region | The GCP region to create and test resources in | string | n/a | yes | +| region | The GCP region to create and test resources in | string | `"us-central1"` | no | | service\_account | Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template.html#service_account. | object | `"null"` | no | | static\_ips | List of static IPs for VM instances | list(string) | n/a | yes | | subnetwork | The subnetwork to host the compute instances in | string | n/a | yes | diff --git a/examples/umig/static_ips/main.tf b/examples/umig/static_ips/main.tf index b4865711..a1b510e8 100644 --- a/examples/umig/static_ips/main.tf +++ b/examples/umig/static_ips/main.tf @@ -15,10 +15,10 @@ */ provider "google" { - credentials = file(var.credentials_path) - project = var.project_id - region = var.region - version = "~> 2.7.0" + + project = var.project_id + region = var.region + version = "~> 2.7.0" } module "instance_template" { diff --git a/examples/umig/static_ips/variables.tf b/examples/umig/static_ips/variables.tf index a8b887e7..6edf8571 100644 --- a/examples/umig/static_ips/variables.tf +++ b/examples/umig/static_ips/variables.tf @@ -1,5 +1,5 @@ /** - * Copyright 2018 Google LLC + * 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. @@ -14,16 +14,17 @@ * limitations under the License. */ -variable "credentials_path" { - description = "The path to the GCP credentials JSON file" -} + variable "project_id" { description = "The GCP project to use for integration tests" + type = string } variable "region" { description = "The GCP region to create and test resources in" + type = string + default = "us-central1" } variable "subnetwork" { diff --git a/helpers/terraform_docs b/helpers/terraform_docs deleted file mode 100755 index 0935b69e..00000000 --- a/helpers/terraform_docs +++ /dev/null @@ -1,694 +0,0 @@ -#!/usr/bin/env bash - -set -e - -main() { - declare argv - argv=$(getopt -o a: --long args: -- "$@") || return - eval "set -- $argv" - - declare args - declare files - - for argv; do - case $argv in - (-a|--args) - shift - args="$1" - shift - ;; - (--) - shift - files="$@" - break - ;; - esac - done - - local hack_terraform_docs=$(terraform version | head -1 | grep -c 0.12) - - if [[ "$hack_terraform_docs" == "1" ]]; then - which awk 2>&1 >/dev/null || ( echo "awk is required for terraform-docs hack to work with Terraform 0.12"; exit 1) - - tmp_file_awk=$(mktemp "${TMPDIR:-/tmp}/terraform-docs-XXXXXXXXXX") - terraform_docs_awk "$tmp_file_awk" - terraform_docs "$tmp_file_awk" "$args" "$files" - rm -f "$tmp_file_awk" - else - terraform_docs "0" "$args" "$files" - fi - -} - -terraform_docs() { - readonly terraform_docs_awk_file="$1" - readonly args="$2" - readonly files="$3" - - declare -a paths - declare -a tfvars_files - - index=0 - - for file_with_path in $files; do - file_with_path="${file_with_path// /__REPLACED__SPACE__}" - - paths[index]=$(dirname "$file_with_path") - - if [[ "$file_with_path" == *".tfvars" ]]; then - tfvars_files+=("$file_with_path") - fi - - ((index+=1)) - done - - readonly tmp_file=$(mktemp) - readonly text_file="README.md" - - for path_uniq in $(echo "${paths[*]}" | tr ' ' '\n' | sort -u); do - path_uniq="${path_uniq//__REPLACED__SPACE__/ }" - - pushd "$path_uniq" > /dev/null - - if [[ ! -f "$text_file" ]]; then - popd > /dev/null - continue - fi - - if [[ "$terraform_docs_awk_file" == "0" ]]; then - terraform-docs $args md ./ > "$tmp_file" - else - # Can't append extension for mktemp, so renaming instead - tmp_file_docs=$(mktemp "${TMPDIR:-/tmp}/terraform-docs-XXXXXXXXXX") - mv "$tmp_file_docs" "$tmp_file_docs.tf" - tmp_file_docs_tf="$tmp_file_docs.tf" - - awk -f "$terraform_docs_awk_file" ./*.tf > "$tmp_file_docs_tf" - terraform-docs $args md "$tmp_file_docs_tf" > "$tmp_file" - rm -f "$tmp_file_docs_tf" - fi - - # Replace content between markers with the placeholder - https://stackoverflow.com/questions/1212799/how-do-i-extract-lines-between-two-line-delimiters-in-perl#1212834 - perl -i -ne 'if (/BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK/../END OF PRE-COMMIT-TERRAFORM DOCS HOOK/) { print $_ if /BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK/; print "I_WANT_TO_BE_REPLACED\n$_" if /END OF PRE-COMMIT-TERRAFORM DOCS HOOK/;} else { print $_ }' "$text_file" - - # Replace placeholder with the content of the file - perl -i -e 'open(F, "'"$tmp_file"'"); $f = join "", ; while(<>){if (/I_WANT_TO_BE_REPLACED/) {print $f} else {print $_};}' "$text_file" - - rm -f "$tmp_file" - - popd > /dev/null - done -} - -terraform_docs_awk() { - readonly output_file=$1 - - cat <<"EOF" > $output_file -# This script converts Terraform 0.12 variables/outputs to something suitable for `terraform-docs` -# As of terraform-docs v0.6.0, HCL2 is not supported. This script is a *dirty hack* to get around it. -# https://github.com/segmentio/terraform-docs/ -# https://github.com/segmentio/terraform-docs/issues/62 - -# Script was originally found here: https://github.com/cloudposse/build-harness/blob/master/bin/terraform-docs.awk - -{ - if ( $0 ~ /\{/ ) { - braceCnt++ - } - - if ( $0 ~ /\}/ ) { - braceCnt-- - } - - # [START] variable or output block started - if ($0 ~ /^[[:space:]]*(variable|output)[[:space:]][[:space:]]*"(.*?)"/) { - # Normalize the braceCnt (should be 1 now) - braceCnt = 1 - # [CLOSE] "default" block - if (blockDefCnt > 0) { - blockDefCnt = 0 - } - blockCnt++ - print $0 - } - - # [START] multiline default statement started - if (blockCnt > 0) { - if ($0 ~ /^[[:space:]][[:space:]]*(default)[[:space:]][[:space:]]*=/) { - if ($3 ~ "null") { - print " default = \"null\"" - } else { - print $0 - blockDefCnt++ - blockDefStart=1 - } - } - } - - # [PRINT] single line "description" - if (blockCnt > 0) { - if (blockDefCnt == 0) { - if ($0 ~ /^[[:space:]][[:space:]]*description[[:space:]][[:space:]]*=/) { - # [CLOSE] "default" block - if (blockDefCnt > 0) { - blockDefCnt = 0 - } - print $0 - } - } - } - - # [PRINT] single line "type" - if (blockCnt > 0) { - if ($0 ~ /^[[:space:]][[:space:]]*type[[:space:]][[:space:]]*=/ ) { - # [CLOSE] "default" block - if (blockDefCnt > 0) { - blockDefCnt = 0 - } - type=$3 - if (type ~ "object") { - print " type = \"object\"" - } else { - # legacy quoted types: "string", "list", and "map" - if ($3 ~ /^[[:space:]]*"(.*?)"[[:space:]]*$/) { - print " type = " $3 - } else { - print " type = \"" $3 "\"" - } - } - } - } - - # [CLOSE] variable/output block - if (blockCnt > 0) { - if (braceCnt == 0 && blockCnt > 0) { - blockCnt-- - print $0 - } - } - - # [PRINT] Multiline "default" statement - if (blockCnt > 0 && blockDefCnt > 0) { - if (blockDefStart == 1) { - blockDefStart = 0 - } else { - print $0 - } - } -} -EOF - -} - -getopt() { - # pure-getopt, a drop-in replacement for GNU getopt in pure Bash. - # version 1.4.3 - # - # Copyright 2012-2018 Aron Griffis - # - # Permission is hereby granted, free of charge, to any person obtaining - # a copy of this software and associated documentation files (the - # "Software"), to deal in the Software without restriction, including - # without limitation the rights to use, copy, modify, merge, publish, - # distribute, sublicense, and/or sell copies of the Software, and to - # permit persons to whom the Software is furnished to do so, subject to - # the following conditions: - # - # The above copyright notice and this permission notice shall be included - # in all copies or substantial portions of the Software. - # - # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - _getopt_main() { - # Returns one of the following statuses: - # 0 success - # 1 error parsing parameters - # 2 error in getopt invocation - # 3 internal error - # 4 reserved for -T - # - # For statuses 0 and 1, generates normalized and shell-quoted - # "options -- parameters" on stdout. - - declare parsed status - declare short long name flags - declare have_short=false - - # Synopsis from getopt man-page: - # - # getopt optstring parameters - # getopt [options] [--] optstring parameters - # getopt [options] -o|--options optstring [options] [--] parameters - # - # The first form can be normalized to the third form which - # _getopt_parse() understands. The second form can be recognized after - # first parse when $short hasn't been set. - - if [[ -n ${GETOPT_COMPATIBLE+isset} || $1 == [^-]* ]]; then - # Enable compatibility mode - flags=c$flags - # Normalize first to third synopsis form - set -- -o "$1" -- "${@:2}" - fi - - # First parse always uses flags=p since getopt always parses its own - # arguments effectively in this mode. - parsed=$(_getopt_parse getopt ahl:n:o:qQs:TuV \ - alternative,help,longoptions:,name:,options:,quiet,quiet-output,shell:,test,version \ - p "$@") - status=$? - if [[ $status != 0 ]]; then - if [[ $status == 1 ]]; then - echo "Try \`getopt --help' for more information." >&2 - # Since this is the first parse, convert status 1 to 2 - status=2 - fi - return $status - fi - eval "set -- $parsed" - - while [[ $# -gt 0 ]]; do - case $1 in - (-a|--alternative) - flags=a$flags ;; - - (-h|--help) - _getopt_help - return 2 # as does GNU getopt - ;; - - (-l|--longoptions) - long="$long${long:+,}$2" - shift ;; - - (-n|--name) - name=$2 - shift ;; - - (-o|--options) - short=$2 - have_short=true - shift ;; - - (-q|--quiet) - flags=q$flags ;; - - (-Q|--quiet-output) - flags=Q$flags ;; - - (-s|--shell) - case $2 in - (sh|bash) - flags=${flags//t/} ;; - (csh|tcsh) - flags=t$flags ;; - (*) - echo 'getopt: unknown shell after -s or --shell argument' >&2 - echo "Try \`getopt --help' for more information." >&2 - return 2 ;; - esac - shift ;; - - (-u|--unquoted) - flags=u$flags ;; - - (-T|--test) - return 4 ;; - - (-V|--version) - echo "pure-getopt 1.4.3" - return 0 ;; - - (--) - shift - break ;; - esac - - shift - done - - if ! $have_short; then - # $short was declared but never set, not even to an empty string. - # This implies the second form in the synopsis. - if [[ $# == 0 ]]; then - echo 'getopt: missing optstring argument' >&2 - echo "Try \`getopt --help' for more information." >&2 - return 2 - fi - short=$1 - have_short=true - shift - fi - - if [[ $short == -* ]]; then - # Leading dash means generate output in place rather than reordering, - # unless we're already in compatibility mode. - [[ $flags == *c* ]] || flags=i$flags - short=${short#?} - elif [[ $short == +* ]]; then - # Leading plus means POSIXLY_CORRECT, unless we're already in - # compatibility mode. - [[ $flags == *c* ]] || flags=p$flags - short=${short#?} - fi - - # This should fire if POSIXLY_CORRECT is in the environment, even if - # it's an empty string. That's the difference between :+ and + - flags=${POSIXLY_CORRECT+p}$flags - - _getopt_parse "${name:-getopt}" "$short" "$long" "$flags" "$@" - } - - _getopt_parse() { - # Inner getopt parser, used for both first parse and second parse. - # Returns 0 for success, 1 for error parsing, 3 for internal error. - # In the case of status 1, still generates stdout with whatever could - # be parsed. - # - # $flags is a string of characters with the following meanings: - # a - alternative parsing mode - # c - GETOPT_COMPATIBLE - # i - generate output in place rather than reordering - # p - POSIXLY_CORRECT - # q - disable error reporting - # Q - disable normal output - # t - quote for csh/tcsh - # u - unquoted output - - declare name="$1" short="$2" long="$3" flags="$4" - shift 4 - - # Split $long on commas, prepend double-dashes, strip colons; - # for use with _getopt_resolve_abbrev - declare -a longarr - _getopt_split longarr "$long" - longarr=( "${longarr[@]/#/--}" ) - longarr=( "${longarr[@]%:}" ) - longarr=( "${longarr[@]%:}" ) - - # Parse and collect options and parameters - declare -a opts params - declare o alt_recycled=false error=0 - - while [[ $# -gt 0 ]]; do - case $1 in - (--) - params=( "${params[@]}" "${@:2}" ) - break ;; - - (--*=*) - o=${1%%=*} - if ! o=$(_getopt_resolve_abbrev "$o" "${longarr[@]}"); then - error=1 - elif [[ ,"$long", == *,"${o#--}"::,* ]]; then - opts=( "${opts[@]}" "$o" "${1#*=}" ) - elif [[ ,"$long", == *,"${o#--}":,* ]]; then - opts=( "${opts[@]}" "$o" "${1#*=}" ) - elif [[ ,"$long", == *,"${o#--}",* ]]; then - if $alt_recycled; then o=${o#-}; fi - _getopt_err "$name: option '$o' doesn't allow an argument" - error=1 - else - echo "getopt: assertion failed (1)" >&2 - return 3 - fi - alt_recycled=false - ;; - - (--?*) - o=$1 - if ! o=$(_getopt_resolve_abbrev "$o" "${longarr[@]}"); then - error=1 - elif [[ ,"$long", == *,"${o#--}",* ]]; then - opts=( "${opts[@]}" "$o" ) - elif [[ ,"$long", == *,"${o#--}::",* ]]; then - opts=( "${opts[@]}" "$o" '' ) - elif [[ ,"$long", == *,"${o#--}:",* ]]; then - if [[ $# -ge 2 ]]; then - shift - opts=( "${opts[@]}" "$o" "$1" ) - else - if $alt_recycled; then o=${o#-}; fi - _getopt_err "$name: option '$o' requires an argument" - error=1 - fi - else - echo "getopt: assertion failed (2)" >&2 - return 3 - fi - alt_recycled=false - ;; - - (-*) - if [[ $flags == *a* ]]; then - # Alternative parsing mode! - # Try to handle as a long option if any of the following apply: - # 1. There's an equals sign in the mix -x=3 or -xy=3 - # 2. There's 2+ letters and an abbreviated long match -xy - # 3. There's a single letter and an exact long match - # 4. There's a single letter and no short match - o=${1::2} # temp for testing #4 - if [[ $1 == *=* || $1 == -?? || \ - ,$long, == *,"${1#-}"[:,]* || \ - ,$short, != *,"${o#-}"[:,]* ]]; then - o=$(_getopt_resolve_abbrev "${1%%=*}" "${longarr[@]}" 2>/dev/null) - case $? in - (0) - # Unambiguous match. Let the long options parser handle - # it, with a flag to get the right error message. - set -- "-$1" "${@:2}" - alt_recycled=true - continue ;; - (1) - # Ambiguous match, generate error and continue. - _getopt_resolve_abbrev "${1%%=*}" "${longarr[@]}" >/dev/null - error=1 - shift - continue ;; - (2) - # No match, fall through to single-character check. - true ;; - (*) - echo "getopt: assertion failed (3)" >&2 - return 3 ;; - esac - fi - fi - - o=${1::2} - if [[ "$short" == *"${o#-}"::* ]]; then - if [[ ${#1} -gt 2 ]]; then - opts=( "${opts[@]}" "$o" "${1:2}" ) - else - opts=( "${opts[@]}" "$o" '' ) - fi - elif [[ "$short" == *"${o#-}":* ]]; then - if [[ ${#1} -gt 2 ]]; then - opts=( "${opts[@]}" "$o" "${1:2}" ) - elif [[ $# -ge 2 ]]; then - shift - opts=( "${opts[@]}" "$o" "$1" ) - else - _getopt_err "$name: option requires an argument -- '${o#-}'" - error=1 - fi - elif [[ "$short" == *"${o#-}"* ]]; then - opts=( "${opts[@]}" "$o" ) - if [[ ${#1} -gt 2 ]]; then - set -- "$o" "-${1:2}" "${@:2}" - fi - else - if [[ $flags == *a* ]]; then - # Alternative parsing mode! Report on the entire failed - # option. GNU includes =value but we omit it for sanity with - # very long values. - _getopt_err "$name: unrecognized option '${1%%=*}'" - else - _getopt_err "$name: invalid option -- '${o#-}'" - if [[ ${#1} -gt 2 ]]; then - set -- "$o" "-${1:2}" "${@:2}" - fi - fi - error=1 - fi ;; - - (*) - # GNU getopt in-place mode (leading dash on short options) - # overrides POSIXLY_CORRECT - if [[ $flags == *i* ]]; then - opts=( "${opts[@]}" "$1" ) - elif [[ $flags == *p* ]]; then - params=( "${params[@]}" "$@" ) - break - else - params=( "${params[@]}" "$1" ) - fi - esac - - shift - done - - if [[ $flags == *Q* ]]; then - true # generate no output - else - echo -n ' ' - if [[ $flags == *[cu]* ]]; then - printf '%s -- %s' "${opts[*]}" "${params[*]}" - else - if [[ $flags == *t* ]]; then - _getopt_quote_csh "${opts[@]}" -- "${params[@]}" - else - _getopt_quote "${opts[@]}" -- "${params[@]}" - fi - fi - echo - fi - - return $error - } - - _getopt_err() { - if [[ $flags != *q* ]]; then - printf '%s\n' "$1" >&2 - fi - } - - _getopt_resolve_abbrev() { - # Resolves an abbrevation from a list of possibilities. - # If the abbreviation is unambiguous, echoes the expansion on stdout - # and returns 0. If the abbreviation is ambiguous, prints a message on - # stderr and returns 1. (For first parse this should convert to exit - # status 2.) If there is no match at all, prints a message on stderr - # and returns 2. - declare a q="$1" - declare -a matches - shift - for a; do - if [[ $q == "$a" ]]; then - # Exact match. Squash any other partial matches. - matches=( "$a" ) - break - elif [[ $flags == *a* && $q == -[^-]* && $a == -"$q" ]]; then - # Exact alternative match. Squash any other partial matches. - matches=( "$a" ) - break - elif [[ $a == "$q"* ]]; then - # Abbreviated match. - matches=( "${matches[@]}" "$a" ) - elif [[ $flags == *a* && $q == -[^-]* && $a == -"$q"* ]]; then - # Abbreviated alternative match. - matches=( "${matches[@]}" "${a#-}" ) - fi - done - case ${#matches[@]} in - (0) - [[ $flags == *q* ]] || \ - printf "$name: unrecognized option %s\\n" >&2 \ - "$(_getopt_quote "$q")" - return 2 ;; - (1) - printf '%s' "${matches[0]}"; return 0 ;; - (*) - [[ $flags == *q* ]] || \ - printf "$name: option %s is ambiguous; possibilities: %s\\n" >&2 \ - "$(_getopt_quote "$q")" "$(_getopt_quote "${matches[@]}")" - return 1 ;; - esac - } - - _getopt_split() { - # Splits $2 at commas to build array specified by $1 - declare IFS=, - eval "$1=( \$2 )" - } - - _getopt_quote() { - # Quotes arguments with single quotes, escaping inner single quotes - declare s space q=\' - for s; do - printf "$space'%s'" "${s//$q/$q\\$q$q}" - space=' ' - done - } - - _getopt_quote_csh() { - # Quotes arguments with single quotes, escaping inner single quotes, - # bangs, backslashes and newlines - declare s i c space - for s; do - echo -n "$space'" - for ((i=0; i<${#s}; i++)); do - c=${s:i:1} - case $c in - (\\|\'|!) - echo -n "'\\$c'" ;; - ($'\n') - echo -n "\\$c" ;; - (*) - echo -n "$c" ;; - esac - done - echo -n \' - space=' ' - done - } - - _getopt_help() { - cat <<-EOT >&2 - - Usage: - getopt - getopt [options] [--] - getopt [options] -o|--options [options] [--] - - Parse command options. - - Options: - -a, --alternative allow long options starting with single - - -l, --longoptions the long options to be recognized - -n, --name the name under which errors are reported - -o, --options the short options to be recognized - -q, --quiet disable error reporting by getopt(3) - -Q, --quiet-output no normal output - -s, --shell set quoting conventions to those of - -T, --test test for getopt(1) version - -u, --unquoted do not quote the output - - -h, --help display this help and exit - -V, --version output version information and exit - - For more details see getopt(1). - EOT - } - - _getopt_version_check() { - if [[ -z $BASH_VERSION ]]; then - echo "getopt: unknown version of bash might not be compatible" >&2 - return 1 - fi - - # This is a lexical comparison that should be sufficient forever. - if [[ $BASH_VERSION < 2.05b ]]; then - echo "getopt: bash $BASH_VERSION might not be compatible" >&2 - return 1 - fi - - return 0 - } - - _getopt_version_check - _getopt_main "$@" - declare status=$? - unset -f _getopt_main _getopt_err _getopt_parse _getopt_quote \ - _getopt_quote_csh _getopt_resolve_abbrev _getopt_split _getopt_help \ - _getopt_version_check - return $status -} - -[[ $BASH_SOURCE != "$0" ]] || main "$@" diff --git a/helpers/terraform_validate b/helpers/terraform_validate deleted file mode 100755 index 7f609827..00000000 --- a/helpers/terraform_validate +++ /dev/null @@ -1,23 +0,0 @@ -#! /bin/bash -# -# Copyright 2019 Google LLC. This software is provided as-is, without warranty -# or representation for any use or purpose. Your use of it is subject to your -# agreement with Google. -# -# This script initializes modules so that terraform validate as of 0.12 behaves -# as expected and does not issue errors such as: -# -# Error: Module not installed -# -# on test/fixtures/shared_vpc_no_subnets/main.tf line 37: -# 37: module "project-factory" { -# -# This module is not yet installed. Run "terraform init" to install all modules -# required by this configuration. - -# The first and only argument to this script is the directory containing *.tf -# files to validate. This directory is assumed to be a root module. - -cd "$1" -terraform init -backend=false -terraform validate diff --git a/test/fixtures/compute_instance/simple/main.tf b/test/fixtures/compute_instance/simple/main.tf index b3148c77..56355033 100644 --- a/test/fixtures/compute_instance/simple/main.tf +++ b/test/fixtures/compute_instance/simple/main.tf @@ -14,16 +14,12 @@ * limitations under the License. */ -locals { - credentials_path = "${path.module}/${var.credentials_path_relative}" -} module "instance_simple" { - source = "../../../../examples/compute_instance/simple" - credentials_path = local.credentials_path - project_id = var.project_id - region = "us-central1" - subnetwork = google_compute_subnetwork.main.name - num_instances = 4 - service_account = var.service_account + source = "../../../../examples/compute_instance/simple" + project_id = var.project_id + region = "us-central1" + subnetwork = google_compute_subnetwork.main.name + num_instances = 4 + service_account = var.service_account } diff --git a/test/fixtures/compute_instance/simple/outputs.tf b/test/fixtures/compute_instance/simple/outputs.tf index 12a4dc8d..70f4b07b 100644 --- a/test/fixtures/compute_instance/simple/outputs.tf +++ b/test/fixtures/compute_instance/simple/outputs.tf @@ -24,8 +24,5 @@ output "project_id" { value = var.project_id } -output "credentials_path" { - description = "The path to the GCP credentials JSON file" - value = local.credentials_path -} + diff --git a/test/fixtures/compute_instance/simple/variables.tf b/test/fixtures/compute_instance/simple/variables.tf index a87f8ff0..841f41e2 100644 --- a/test/fixtures/compute_instance/simple/variables.tf +++ b/test/fixtures/compute_instance/simple/variables.tf @@ -18,10 +18,6 @@ variable "project_id" { description = "The GCP project to use for integration tests" } -variable "credentials_path_relative" { - description = "The relative path from the fixture directory to the GCP credentials file that will run Terraform tests" -} - variable "service_account" { default = null type = object({ diff --git a/test/fixtures/instance_template/additional_disks/main.tf b/test/fixtures/instance_template/additional_disks/main.tf index cb54648d..9598d6ab 100644 --- a/test/fixtures/instance_template/additional_disks/main.tf +++ b/test/fixtures/instance_template/additional_disks/main.tf @@ -14,16 +14,10 @@ * limitations under the License. */ -locals { - credentials_path = "${path.module}/${var.credentials_path_relative}" -} - module "instance_template_additional_disks" { - source = "../../../../examples/instance_template/additional_disks" - credentials_path = local.credentials_path - project_id = var.project_id - region = var.region - subnetwork = google_compute_subnetwork.main.name - service_account = var.service_account + source = "../../../../examples/instance_template/additional_disks" + project_id = var.project_id + subnetwork = google_compute_subnetwork.main.name + service_account = var.service_account } diff --git a/test/fixtures/instance_template/additional_disks/outputs.tf b/test/fixtures/instance_template/additional_disks/outputs.tf index ec354ec8..ce86f4ce 100644 --- a/test/fixtures/instance_template/additional_disks/outputs.tf +++ b/test/fixtures/instance_template/additional_disks/outputs.tf @@ -29,8 +29,5 @@ output "project_id" { value = var.project_id } -output "credentials_path" { - description = "The path to the GCP credentials JSON file" - value = local.credentials_path -} + diff --git a/test/fixtures/instance_template/additional_disks/variables.tf b/test/fixtures/instance_template/additional_disks/variables.tf index 49c6e021..eada6b91 100644 --- a/test/fixtures/instance_template/additional_disks/variables.tf +++ b/test/fixtures/instance_template/additional_disks/variables.tf @@ -18,19 +18,13 @@ variable "project_id" { description = "The GCP project to use for integration tests" } -variable "region" { - description = "The GCP region to create and test resources in" -} -variable "credentials_path_relative" { - description = "The relative path from the fixture directory to the GCP credentials file that will run Terraform tests" -} variable "service_account" { default = null type = object({ email = string - scopes = set(string) + scopes = list(string) }) description = "Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template.html#service_account." } diff --git a/test/fixtures/instance_template/simple/main.tf b/test/fixtures/instance_template/simple/main.tf index 8c249199..a6f13c9d 100644 --- a/test/fixtures/instance_template/simple/main.tf +++ b/test/fixtures/instance_template/simple/main.tf @@ -14,18 +14,12 @@ * limitations under the License. */ -locals { - credentials_path = "${path.module}/${var.credentials_path_relative}" -} - module "instance_template_simple" { - source = "../../../../examples/instance_template/simple" - credentials_path = local.credentials_path - project_id = var.project_id - region = var.region - subnetwork = google_compute_subnetwork.main.name - service_account = var.service_account - tags = ["foo", "bar"] + source = "../../../../examples/instance_template/simple" + project_id = var.project_id + subnetwork = google_compute_subnetwork.main.name + service_account = var.service_account + tags = ["foo", "bar"] labels = { environment = "dev" diff --git a/test/fixtures/instance_template/simple/outputs.tf b/test/fixtures/instance_template/simple/outputs.tf index fa8e0db1..60d102c8 100644 --- a/test/fixtures/instance_template/simple/outputs.tf +++ b/test/fixtures/instance_template/simple/outputs.tf @@ -29,8 +29,5 @@ output "project_id" { value = var.project_id } -output "credentials_path" { - description = "The path to the GCP credentials JSON file" - value = local.credentials_path -} + diff --git a/test/fixtures/instance_template/simple/variables.tf b/test/fixtures/instance_template/simple/variables.tf index 5043c27a..554ed38c 100644 --- a/test/fixtures/instance_template/simple/variables.tf +++ b/test/fixtures/instance_template/simple/variables.tf @@ -18,13 +18,7 @@ variable "project_id" { description = "The GCP project to use for integration tests" } -variable "region" { - description = "The GCP region to create and test resources in" -} -variable "credentials_path_relative" { - description = "The relative path from the fixture directory to the GCP credentials file that will run Terraform tests" -} variable "service_account" { default = null diff --git a/test/fixtures/mig/autoscaler/main.tf b/test/fixtures/mig/autoscaler/main.tf index 520be8d2..aa91aa26 100644 --- a/test/fixtures/mig/autoscaler/main.tf +++ b/test/fixtures/mig/autoscaler/main.tf @@ -14,15 +14,9 @@ * limitations under the License. */ -locals { - credentials_path = "${path.module}/${var.credentials_path_relative}" -} - module "mig_autoscaler" { source = "../../../../examples/mig/autoscaler" - credentials_path = local.credentials_path project_id = var.project_id - region = var.region subnetwork = google_compute_subnetwork.main.name service_account = var.service_account autoscaling_enabled = "true" diff --git a/test/fixtures/mig/autoscaler/outputs.tf b/test/fixtures/mig/autoscaler/outputs.tf index 03bf6a41..37a57ff7 100644 --- a/test/fixtures/mig/autoscaler/outputs.tf +++ b/test/fixtures/mig/autoscaler/outputs.tf @@ -21,11 +21,8 @@ output "project_id" { output "region" { description = "The GCP region to create and test resources in" - value = var.region + value = module.mig_autoscaler.region } -output "credentials_path" { - description = "The path to the GCP credentials JSON file" - value = local.credentials_path -} + diff --git a/test/fixtures/mig/autoscaler/variables.tf b/test/fixtures/mig/autoscaler/variables.tf index 49c6e021..841f41e2 100644 --- a/test/fixtures/mig/autoscaler/variables.tf +++ b/test/fixtures/mig/autoscaler/variables.tf @@ -18,19 +18,11 @@ variable "project_id" { description = "The GCP project to use for integration tests" } -variable "region" { - description = "The GCP region to create and test resources in" -} - -variable "credentials_path_relative" { - description = "The relative path from the fixture directory to the GCP credentials file that will run Terraform tests" -} - variable "service_account" { default = null type = object({ email = string - scopes = set(string) + scopes = list(string) }) description = "Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template.html#service_account." } diff --git a/test/fixtures/mig/simple/main.tf b/test/fixtures/mig/simple/main.tf index a76dedc2..d832f40e 100644 --- a/test/fixtures/mig/simple/main.tf +++ b/test/fixtures/mig/simple/main.tf @@ -14,17 +14,11 @@ * limitations under the License. */ -locals { - credentials_path = "${path.module}/${var.credentials_path_relative}" -} - module "mig_simple" { - source = "../../../../examples/mig/simple" - credentials_path = local.credentials_path - project_id = var.project_id - region = var.region - subnetwork = google_compute_subnetwork.main.name - target_size = 4 - service_account = var.service_account + source = "../../../../examples/mig/simple" + project_id = var.project_id + subnetwork = google_compute_subnetwork.main.name + target_size = 4 + service_account = var.service_account } diff --git a/test/fixtures/mig/simple/outputs.tf b/test/fixtures/mig/simple/outputs.tf index 7f9b0ef5..7fe349e4 100644 --- a/test/fixtures/mig/simple/outputs.tf +++ b/test/fixtures/mig/simple/outputs.tf @@ -26,11 +26,8 @@ output "project_id" { output "region" { description = "The GCP region to create and test resources in" - value = var.region + value = module.mig_simple.region } -output "credentials_path" { - description = "The path to the GCP credentials JSON file" - value = local.credentials_path -} + diff --git a/test/fixtures/mig/simple/variables.tf b/test/fixtures/mig/simple/variables.tf index 49c6e021..eada6b91 100644 --- a/test/fixtures/mig/simple/variables.tf +++ b/test/fixtures/mig/simple/variables.tf @@ -18,19 +18,13 @@ variable "project_id" { description = "The GCP project to use for integration tests" } -variable "region" { - description = "The GCP region to create and test resources in" -} -variable "credentials_path_relative" { - description = "The relative path from the fixture directory to the GCP credentials file that will run Terraform tests" -} variable "service_account" { default = null type = object({ email = string - scopes = set(string) + scopes = list(string) }) description = "Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template.html#service_account." } diff --git a/test/fixtures/mig_with_percent/simple/main.tf b/test/fixtures/mig_with_percent/simple/main.tf index 4b6030fa..c40b1119 100644 --- a/test/fixtures/mig_with_percent/simple/main.tf +++ b/test/fixtures/mig_with_percent/simple/main.tf @@ -14,15 +14,9 @@ * limitations under the License. */ -locals { - credentials_path = "${path.module}/${var.credentials_path_relative}" -} - module "mig_with_percent_simple" { - source = "../../../../examples/mig_with_percent/simple" - credentials_path = local.credentials_path - project_id = var.project_id - region = var.region - subnetwork = google_compute_subnetwork.main.name - service_account = var.service_account + source = "../../../../examples/mig_with_percent/simple" + project_id = var.project_id + subnetwork = google_compute_subnetwork.main.name + service_account = var.service_account } diff --git a/test/fixtures/mig_with_percent/simple/outputs.tf b/test/fixtures/mig_with_percent/simple/outputs.tf index 10626724..1ea513ef 100644 --- a/test/fixtures/mig_with_percent/simple/outputs.tf +++ b/test/fixtures/mig_with_percent/simple/outputs.tf @@ -24,13 +24,8 @@ output "project_id" { value = var.project_id } -output "credentials_path" { - description = "The path to the GCP credentials JSON file" - value = local.credentials_path -} - output "region" { description = "The GCP region to create and test resources in" - value = var.region + value = module.mig_with_percent_simple.region } diff --git a/test/fixtures/mig_with_percent/simple/variables.tf b/test/fixtures/mig_with_percent/simple/variables.tf index dbc1030c..8182dbf4 100644 --- a/test/fixtures/mig_with_percent/simple/variables.tf +++ b/test/fixtures/mig_with_percent/simple/variables.tf @@ -18,19 +18,13 @@ variable "project_id" { description = "The GCP project to use for integration tests" } -variable "region" { - description = "The GCP region to create and test resources in" -} -variable "credentials_path_relative" { - description = "The relative path from the fixture directory to the GCP credentials file that will run Terraform tests" -} variable "service_account" { default = null type = object({ email = string - scopes = set(string) + scopes = list(string) }) description = "Service account email address and scopes" } diff --git a/test/fixtures/preemptible_and_regular_instance_templates/simple/main.tf b/test/fixtures/preemptible_and_regular_instance_templates/simple/main.tf index 1e6b3255..bc7389d0 100644 --- a/test/fixtures/preemptible_and_regular_instance_templates/simple/main.tf +++ b/test/fixtures/preemptible_and_regular_instance_templates/simple/main.tf @@ -14,18 +14,12 @@ * limitations under the License. */ -locals { - credentials_path = "${path.module}/${var.credentials_path_relative}" -} - module "preemptible_and_regular_instance_templates" { - source = "../../../../examples/preemptible_and_regular_instance_templates/simple" - credentials_path = local.credentials_path - project_id = var.project_id - region = var.region - subnetwork = google_compute_subnetwork.main.name - service_account = var.service_account - tags = ["foo", "bar"] + source = "../../../../examples/preemptible_and_regular_instance_templates/simple" + project_id = var.project_id + subnetwork = google_compute_subnetwork.main.name + service_account = var.service_account + tags = ["foo", "bar"] labels = { environment = "dev" diff --git a/test/fixtures/preemptible_and_regular_instance_templates/simple/outputs.tf b/test/fixtures/preemptible_and_regular_instance_templates/simple/outputs.tf index ddcf8ed8..66c4d601 100644 --- a/test/fixtures/preemptible_and_regular_instance_templates/simple/outputs.tf +++ b/test/fixtures/preemptible_and_regular_instance_templates/simple/outputs.tf @@ -29,7 +29,4 @@ output "project_id" { value = var.project_id } -output "credentials_path" { - description = "The path to the GCP credentials JSON file" - value = local.credentials_path -} + diff --git a/test/fixtures/preemptible_and_regular_instance_templates/simple/variables.tf b/test/fixtures/preemptible_and_regular_instance_templates/simple/variables.tf index b12bd9a3..0bbfafe9 100644 --- a/test/fixtures/preemptible_and_regular_instance_templates/simple/variables.tf +++ b/test/fixtures/preemptible_and_regular_instance_templates/simple/variables.tf @@ -18,13 +18,7 @@ variable "project_id" { description = "The GCP project to use for integration tests" } -variable "region" { - description = "The GCP region to create and test resources in" -} -variable "credentials_path_relative" { - description = "The relative path from the fixture directory to the GCP credentials file that will run Terraform tests" -} variable "service_account" { default = null diff --git a/test/fixtures/shared/terraform.tfvars.example b/test/fixtures/shared/terraform.tfvars.example index b73ffa71..92103f64 100644 --- a/test/fixtures/shared/terraform.tfvars.example +++ b/test/fixtures/shared/terraform.tfvars.example @@ -1,7 +1,5 @@ project_id = "" -credentials_path_relative = "../../../../credentials.json" - region = "us-central1" service_account = { diff --git a/test/fixtures/umig/named_ports/main.tf b/test/fixtures/umig/named_ports/main.tf index 67a7fb97..e86b2f34 100644 --- a/test/fixtures/umig/named_ports/main.tf +++ b/test/fixtures/umig/named_ports/main.tf @@ -14,18 +14,13 @@ * limitations under the License. */ -locals { - credentials_path = "${path.module}/${var.credentials_path_relative}" -} - module "umig_named_ports" { - source = "../../../../examples/umig/named_ports" - credentials_path = local.credentials_path - project_id = var.project_id - region = "us-central1" - subnetwork = google_compute_subnetwork.main.name - num_instances = 4 - service_account = var.service_account + source = "../../../../examples/umig/named_ports" + project_id = var.project_id + region = "us-central1" + subnetwork = google_compute_subnetwork.main.name + num_instances = 4 + service_account = var.service_account named_ports = [ { diff --git a/test/fixtures/umig/named_ports/outputs.tf b/test/fixtures/umig/named_ports/outputs.tf index b0771ecd..df40537d 100644 --- a/test/fixtures/umig/named_ports/outputs.tf +++ b/test/fixtures/umig/named_ports/outputs.tf @@ -29,8 +29,5 @@ output "project_id" { value = var.project_id } -output "credentials_path" { - description = "The path to the GCP credentials JSON file" - value = local.credentials_path -} + diff --git a/test/fixtures/umig/named_ports/variables.tf b/test/fixtures/umig/named_ports/variables.tf index 73aa9f93..841f41e2 100644 --- a/test/fixtures/umig/named_ports/variables.tf +++ b/test/fixtures/umig/named_ports/variables.tf @@ -18,15 +18,11 @@ variable "project_id" { description = "The GCP project to use for integration tests" } -variable "credentials_path_relative" { - description = "The relative path from the fixture directory to the GCP credentials file that will run Terraform tests" -} - variable "service_account" { default = null type = object({ email = string - scopes = set(string) + scopes = list(string) }) description = "Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template.html#service_account." } diff --git a/test/fixtures/umig/simple/main.tf b/test/fixtures/umig/simple/main.tf index a4cb2074..0296b3b2 100644 --- a/test/fixtures/umig/simple/main.tf +++ b/test/fixtures/umig/simple/main.tf @@ -14,17 +14,12 @@ * limitations under the License. */ -locals { - credentials_path = "${path.module}/${var.credentials_path_relative}" -} - module "umig_simple" { - source = "../../../../examples/umig/simple" - credentials_path = local.credentials_path - project_id = var.project_id - region = "us-central1" - subnetwork = google_compute_subnetwork.main.name - num_instances = 4 - service_account = var.service_account + source = "../../../../examples/umig/simple" + project_id = var.project_id + region = "us-central1" + subnetwork = google_compute_subnetwork.main.name + num_instances = 4 + service_account = var.service_account } diff --git a/test/fixtures/umig/simple/outputs.tf b/test/fixtures/umig/simple/outputs.tf index b4597339..06061ee8 100644 --- a/test/fixtures/umig/simple/outputs.tf +++ b/test/fixtures/umig/simple/outputs.tf @@ -29,8 +29,5 @@ output "project_id" { value = var.project_id } -output "credentials_path" { - description = "The path to the GCP credentials JSON file" - value = local.credentials_path -} + diff --git a/test/fixtures/umig/simple/variables.tf b/test/fixtures/umig/simple/variables.tf index abce96e8..1adce9a9 100644 --- a/test/fixtures/umig/simple/variables.tf +++ b/test/fixtures/umig/simple/variables.tf @@ -18,15 +18,11 @@ variable "project_id" { description = "The GCP project to use for integration tests" } -variable "credentials_path_relative" { - description = "The relative path from the fixture directory to the GCP credentials file that will run Terraform tests" -} - variable "service_account" { default = null type = object({ email = string - scopes = set(string) + scopes = list(string) }) description = "Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template.html#service_account." } diff --git a/test/fixtures/umig/static_ips/main.tf b/test/fixtures/umig/static_ips/main.tf index 20bdceac..94f73296 100644 --- a/test/fixtures/umig/static_ips/main.tf +++ b/test/fixtures/umig/static_ips/main.tf @@ -14,16 +14,11 @@ * limitations under the License. */ -locals { - credentials_path = "${path.module}/${var.credentials_path_relative}" -} - module "umig_static_ips" { - source = "../../../../examples/umig/static_ips" - credentials_path = local.credentials_path - project_id = var.project_id - region = "us-central1" - subnetwork = google_compute_subnetwork.main.name + source = "../../../../examples/umig/static_ips" + project_id = var.project_id + region = "us-central1" + subnetwork = google_compute_subnetwork.main.name static_ips = [ "10.128.0.10", diff --git a/test/fixtures/umig/static_ips/outputs.tf b/test/fixtures/umig/static_ips/outputs.tf index 8036660a..e574099c 100644 --- a/test/fixtures/umig/static_ips/outputs.tf +++ b/test/fixtures/umig/static_ips/outputs.tf @@ -29,8 +29,5 @@ output "project_id" { value = var.project_id } -output "credentials_path" { - description = "The path to the GCP credentials JSON file" - value = local.credentials_path -} + diff --git a/test/fixtures/umig/static_ips/variables.tf b/test/fixtures/umig/static_ips/variables.tf index 73aa9f93..841f41e2 100644 --- a/test/fixtures/umig/static_ips/variables.tf +++ b/test/fixtures/umig/static_ips/variables.tf @@ -18,15 +18,11 @@ variable "project_id" { description = "The GCP project to use for integration tests" } -variable "credentials_path_relative" { - description = "The relative path from the fixture directory to the GCP credentials file that will run Terraform tests" -} - variable "service_account" { default = null type = object({ email = string - scopes = set(string) + scopes = list(string) }) description = "Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template.html#service_account." } diff --git a/test/integration/instance_simple/controls/instance_simple.rb b/test/integration/instance_simple/controls/instance_simple.rb index f2a37279..8b6a8956 100644 --- a/test/integration/instance_simple/controls/instance_simple.rb +++ b/test/integration/instance_simple/controls/instance_simple.rb @@ -13,11 +13,6 @@ # limitations under the License. project_id = attribute('project_id') -credentials_path = attribute('credentials_path') - -ENV['CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE'] = File.absolute_path( - credentials_path, - File.join(__dir__, "../../../fixtures/compute_instance/simple")) expected_instances = 4 diff --git a/test/integration/instance_simple/inspec.yml b/test/integration/instance_simple/inspec.yml index 8e46f9b0..26899928 100644 --- a/test/integration/instance_simple/inspec.yml +++ b/test/integration/instance_simple/inspec.yml @@ -18,6 +18,3 @@ attributes: - name: project_id required: true type: string - - name: credentials_path - required: true - type: string diff --git a/test/integration/it_additional_disks/controls/it_additional_disks.rb b/test/integration/it_additional_disks/controls/it_additional_disks.rb index 37db5380..a583c38e 100644 --- a/test/integration/it_additional_disks/controls/it_additional_disks.rb +++ b/test/integration/it_additional_disks/controls/it_additional_disks.rb @@ -13,11 +13,6 @@ # limitations under the License. project_id = attribute('project_id') -credentials_path = attribute('credentials_path') - -ENV['CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE'] = File.absolute_path( - credentials_path, - File.join(__dir__, "../../../fixtures/instance_template/additional_disks")) expected_templates = 1 expected_disks = 4 diff --git a/test/integration/it_additional_disks/inspec.yml b/test/integration/it_additional_disks/inspec.yml index 2456039e..88099aac 100644 --- a/test/integration/it_additional_disks/inspec.yml +++ b/test/integration/it_additional_disks/inspec.yml @@ -18,6 +18,3 @@ attributes: - name: project_id required: true type: string - - name: credentials_path - required: true - type: string diff --git a/test/integration/it_simple/controls/it_simple.rb b/test/integration/it_simple/controls/it_simple.rb index 842aba2b..4af03d8d 100644 --- a/test/integration/it_simple/controls/it_simple.rb +++ b/test/integration/it_simple/controls/it_simple.rb @@ -13,11 +13,6 @@ # limitations under the License. project_id = attribute('project_id') -credentials_path = attribute('credentials_path') - -ENV['CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE'] = File.absolute_path( - credentials_path, - File.join(__dir__, "../../../fixtures/instance_template/simple")) expected_templates = 1 expected_disks = 1 diff --git a/test/integration/it_simple/inspec.yml b/test/integration/it_simple/inspec.yml index 67ee6d7a..7afe6780 100644 --- a/test/integration/it_simple/inspec.yml +++ b/test/integration/it_simple/inspec.yml @@ -18,6 +18,3 @@ attributes: - name: project_id required: true type: string - - name: credentials_path - required: true - type: string diff --git a/test/integration/mig_autoscaler/controls/mig_autoscaler.rb b/test/integration/mig_autoscaler/controls/mig_autoscaler.rb index 5ec87817..7db59be5 100644 --- a/test/integration/mig_autoscaler/controls/mig_autoscaler.rb +++ b/test/integration/mig_autoscaler/controls/mig_autoscaler.rb @@ -13,13 +13,8 @@ # limitations under the License. project_id = attribute('project_id') -credentials_path = attribute('credentials_path') region = attribute('region') -ENV['CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE'] = File.absolute_path( - credentials_path, - File.join(__dir__, "../../../fixtures/mig/autoscaler")) - expected_instances = 4 expected_instance_groups = 1 diff --git a/test/integration/mig_autoscaler/inspec.yml b/test/integration/mig_autoscaler/inspec.yml index 3ea8c742..f4d2e845 100644 --- a/test/integration/mig_autoscaler/inspec.yml +++ b/test/integration/mig_autoscaler/inspec.yml @@ -18,9 +18,6 @@ attributes: - name: project_id required: true type: string - - name: credentials_path - required: true - type: string - name: region required: true type: string diff --git a/test/integration/mig_simple/controls/mig_simple.rb b/test/integration/mig_simple/controls/mig_simple.rb index 3189899d..13c4d9d7 100644 --- a/test/integration/mig_simple/controls/mig_simple.rb +++ b/test/integration/mig_simple/controls/mig_simple.rb @@ -13,13 +13,8 @@ # limitations under the License. project_id = attribute('project_id') -credentials_path = attribute('credentials_path') region = attribute('region') -ENV['CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE'] = File.absolute_path( - credentials_path, - File.join(__dir__, "../../../fixtures/mig/simple")) - expected_instances = 4 expected_instance_groups = 1 diff --git a/test/integration/mig_simple/inspec.yml b/test/integration/mig_simple/inspec.yml index bca189bb..f0a7adc1 100644 --- a/test/integration/mig_simple/inspec.yml +++ b/test/integration/mig_simple/inspec.yml @@ -18,9 +18,6 @@ attributes: - name: project_id required: true type: string - - name: credentials_path - required: true - type: string - name: region required: true type: string diff --git a/test/integration/mig_with_percent_simple/controls/mig_with_percent_simple.rb b/test/integration/mig_with_percent_simple/controls/mig_with_percent_simple.rb index cb2295e1..08ef7496 100644 --- a/test/integration/mig_with_percent_simple/controls/mig_with_percent_simple.rb +++ b/test/integration/mig_with_percent_simple/controls/mig_with_percent_simple.rb @@ -13,13 +13,8 @@ # limitations under the License. project_id = attribute('project_id') -credentials_path = attribute('credentials_path') region = attribute('region') -ENV['CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE'] = File.absolute_path( - credentials_path, - File.join(__dir__, "../../../fixtures/mig_with_percent/simple")) - expected_instances = 4 expected_instance_groups = 1 diff --git a/test/integration/mig_with_percent_simple/inspec.yml b/test/integration/mig_with_percent_simple/inspec.yml index cb5f0d83..2d62e9ae 100644 --- a/test/integration/mig_with_percent_simple/inspec.yml +++ b/test/integration/mig_with_percent_simple/inspec.yml @@ -18,9 +18,6 @@ attributes: - name: project_id required: true type: string - - name: credentials_path - required: true - type: string - name: region required: true type: string diff --git a/test/integration/preemptible_and_regular_instance_templates_simple/controls/simple.rb b/test/integration/preemptible_and_regular_instance_templates_simple/controls/simple.rb index 64843649..8cff4921 100644 --- a/test/integration/preemptible_and_regular_instance_templates_simple/controls/simple.rb +++ b/test/integration/preemptible_and_regular_instance_templates_simple/controls/simple.rb @@ -13,11 +13,6 @@ # limitations under the License. project_id = attribute('project_id') -credentials_path = attribute('credentials_path') - -ENV['CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE'] = File.absolute_path( - credentials_path, - File.join(__dir__, "../../../fixtures/preemptible_and_regular_instance_templates/simple")) expected_templates = 1 expected_disks = 1 diff --git a/test/integration/preemptible_and_regular_instance_templates_simple/inspec.yml b/test/integration/preemptible_and_regular_instance_templates_simple/inspec.yml index 65117ceb..a34d1ed3 100644 --- a/test/integration/preemptible_and_regular_instance_templates_simple/inspec.yml +++ b/test/integration/preemptible_and_regular_instance_templates_simple/inspec.yml @@ -18,6 +18,3 @@ attributes: - name: project_id required: true type: string - - name: credentials_path - required: true - type: string diff --git a/test/integration/umig_named_ports/controls/umig_named_ports.rb b/test/integration/umig_named_ports/controls/umig_named_ports.rb index e5147788..71c52bf3 100644 --- a/test/integration/umig_named_ports/controls/umig_named_ports.rb +++ b/test/integration/umig_named_ports/controls/umig_named_ports.rb @@ -13,11 +13,6 @@ # limitations under the License. project_id = attribute('project_id') -credentials_path = attribute('credentials_path') - -ENV['CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE'] = File.absolute_path( - credentials_path, - File.join(__dir__, "../../../fixtures/umig/named_ports")) expected_instances = 4 expected_instance_groups = 4 diff --git a/test/integration/umig_named_ports/inspec.yml b/test/integration/umig_named_ports/inspec.yml index 06b3774b..62305759 100644 --- a/test/integration/umig_named_ports/inspec.yml +++ b/test/integration/umig_named_ports/inspec.yml @@ -18,6 +18,3 @@ attributes: - name: project_id required: true type: string - - name: credentials_path - required: true - type: string diff --git a/test/integration/umig_simple/controls/umig_simple.rb b/test/integration/umig_simple/controls/umig_simple.rb index b146cd00..15749542 100644 --- a/test/integration/umig_simple/controls/umig_simple.rb +++ b/test/integration/umig_simple/controls/umig_simple.rb @@ -13,11 +13,6 @@ # limitations under the License. project_id = attribute('project_id') -credentials_path = attribute('credentials_path') - -ENV['CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE'] = File.absolute_path( - credentials_path, - File.join(__dir__, "../../../fixtures/umig/simple")) expected_instances = 4 expected_instance_groups = 4 diff --git a/test/integration/umig_simple/inspec.yml b/test/integration/umig_simple/inspec.yml index 6345d52e..8e090a47 100644 --- a/test/integration/umig_simple/inspec.yml +++ b/test/integration/umig_simple/inspec.yml @@ -18,6 +18,3 @@ attributes: - name: project_id required: true type: string - - name: credentials_path - required: true - type: string diff --git a/test/integration/umig_static_ips/controls/umig_static_ips.rb b/test/integration/umig_static_ips/controls/umig_static_ips.rb index 0de3d278..bcb6c297 100644 --- a/test/integration/umig_static_ips/controls/umig_static_ips.rb +++ b/test/integration/umig_static_ips/controls/umig_static_ips.rb @@ -13,11 +13,6 @@ # limitations under the License. project_id = attribute('project_id') -credentials_path = attribute('credentials_path') - -ENV['CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE'] = File.absolute_path( - credentials_path, - File.join(__dir__, "../../../fixtures/umig/umig_static_ips")) expected_instances = 4 expected_instance_groups = 4 diff --git a/test/integration/umig_static_ips/inspec.yml b/test/integration/umig_static_ips/inspec.yml index c9266338..aa2f1b4a 100644 --- a/test/integration/umig_static_ips/inspec.yml +++ b/test/integration/umig_static_ips/inspec.yml @@ -18,6 +18,3 @@ attributes: - name: project_id required: true type: string - - name: credentials_path - required: true - type: string diff --git a/test/setup/make_source.sh b/test/setup/make_source.sh deleted file mode 100755 index 81c44d7f..00000000 --- a/test/setup/make_source.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env bash - -# 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. - -echo "#!/usr/bin/env bash" > ../source.sh - -region="us-central1" -echo "export TF_VAR_region='$region'" >> ../source.sh -project_id=$(terraform output project_id) -echo "export TF_VAR_project_id='$project_id'" >> ../source.sh -sa_json=$(terraform output sa_key) -# shellcheck disable=SC2086 -echo "export SERVICE_ACCOUNT_JSON='$(echo $sa_json | base64 --decode)'" >> ../source.sh -echo "$sa_json" | base64 --decode > ../fixtures/shared/credentials.json -credentials_path_relative="../../shared/credentials.json" -echo "export TF_VAR_credentials_path_relative='$credentials_path_relative'" >> ../source.sh -sa_email=$(terraform output sa_email) -echo "export TF_VAR_service_account='{email=\"$sa_email\", scopes = [\"cloud-platform\"]}'" >> ../source.sh - diff --git a/test/setup/outputs.tf b/test/setup/outputs.tf index 71f3a27b..ba4fed08 100644 --- a/test/setup/outputs.tf +++ b/test/setup/outputs.tf @@ -23,6 +23,9 @@ output "sa_key" { sensitive = true } -output "sa_email" { - value = google_service_account.ci_vm_account.email +output "service_account" { + value = { + email = google_service_account.ci_vm_account.email + scopes = ["cloud-platform"] + } }