From 1abd8c72dce62f28efd13159f977343bb2962046 Mon Sep 17 00:00:00 2001 From: Thiago Nache Carvalho Date: Mon, 14 Feb 2022 18:05:38 -0300 Subject: [PATCH] chore: Add service_account variable on examples missing it (#234) * Add service_account variable on examples missing it * Fix indentation. Not sure why it did not run automatically --- examples/compute_instance/disk_snapshot/README.md | 1 + examples/compute_instance/disk_snapshot/main.tf | 2 +- examples/compute_instance/disk_snapshot/variables.tf | 9 ++++++++- examples/mig/healthcheck/README.md | 1 + examples/mig/healthcheck/main.tf | 2 +- examples/mig/healthcheck/variables.tf | 9 +++++++++ test/fixtures/compute_instance/disk_snapshot/main.tf | 9 +++++---- .../fixtures/compute_instance/disk_snapshot/variables.tf | 9 ++++++++- test/fixtures/mig/healthcheck/main.tf | 5 +++-- test/fixtures/mig/healthcheck/variables.tf | 9 +++++++++ 10 files changed, 46 insertions(+), 10 deletions(-) diff --git a/examples/compute_instance/disk_snapshot/README.md b/examples/compute_instance/disk_snapshot/README.md index ad9c7b1a..c402bc49 100644 --- a/examples/compute_instance/disk_snapshot/README.md +++ b/examples/compute_instance/disk_snapshot/README.md @@ -9,6 +9,7 @@ This is a simple example of how to use the compute_disk_snapshot module |------|-------------|------|---------|:--------:| | 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` | `"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({
email = string,
scopes = set(string)
})
| `null` | no | | subnetwork | The subnetwork selflink to host the compute instances in | `any` | n/a | yes | ## Outputs diff --git a/examples/compute_instance/disk_snapshot/main.tf b/examples/compute_instance/disk_snapshot/main.tf index c2f0cbb3..a701801a 100644 --- a/examples/compute_instance/disk_snapshot/main.tf +++ b/examples/compute_instance/disk_snapshot/main.tf @@ -31,7 +31,7 @@ module "instance_template" { project_id = var.project_id subnetwork = var.subnetwork name_prefix = "instance-disk-snapshot" - service_account = null + service_account = var.service_account additional_disks = [ { diff --git a/examples/compute_instance/disk_snapshot/variables.tf b/examples/compute_instance/disk_snapshot/variables.tf index 49f4e015..36432b73 100644 --- a/examples/compute_instance/disk_snapshot/variables.tf +++ b/examples/compute_instance/disk_snapshot/variables.tf @@ -29,4 +29,11 @@ variable "subnetwork" { description = "The subnetwork selflink to host the compute instances in" } - +variable "service_account" { + default = null + type = object({ + email = string, + scopes = set(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/examples/mig/healthcheck/README.md b/examples/mig/healthcheck/README.md index c8c99243..4642454f 100644 --- a/examples/mig/healthcheck/README.md +++ b/examples/mig/healthcheck/README.md @@ -10,6 +10,7 @@ group with an autoscaler. |------|-------------|------|---------|:--------:| | 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` | `"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({
email = string,
scopes = set(string)
})
| `null` | no | ## Outputs diff --git a/examples/mig/healthcheck/main.tf b/examples/mig/healthcheck/main.tf index 946f1e41..7962f80d 100644 --- a/examples/mig/healthcheck/main.tf +++ b/examples/mig/healthcheck/main.tf @@ -54,7 +54,7 @@ module "instance_template" { source = "../../../modules/instance_template" project_id = var.project_id subnetwork = google_compute_subnetwork.main.name - service_account = null + service_account = var.service_account } /** Instance Group within autoscale and health check **/ diff --git a/examples/mig/healthcheck/variables.tf b/examples/mig/healthcheck/variables.tf index a1388426..4b7927f6 100644 --- a/examples/mig/healthcheck/variables.tf +++ b/examples/mig/healthcheck/variables.tf @@ -24,3 +24,12 @@ variable "region" { type = string default = "us-central1" } + +variable "service_account" { + default = null + type = object({ + email = string, + scopes = set(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/compute_instance/disk_snapshot/main.tf b/test/fixtures/compute_instance/disk_snapshot/main.tf index 6fbe6fe7..75a670bc 100644 --- a/test/fixtures/compute_instance/disk_snapshot/main.tf +++ b/test/fixtures/compute_instance/disk_snapshot/main.tf @@ -16,8 +16,9 @@ module "disk_snapshot" { - source = "../../../../examples/compute_instance/disk_snapshot" - project_id = var.project_id - region = "us-central1" - subnetwork = google_compute_subnetwork.main.self_link + source = "../../../../examples/compute_instance/disk_snapshot" + project_id = var.project_id + region = "us-central1" + subnetwork = google_compute_subnetwork.main.self_link + service_account = var.service_account } diff --git a/test/fixtures/compute_instance/disk_snapshot/variables.tf b/test/fixtures/compute_instance/disk_snapshot/variables.tf index 3f93dc40..1adce9a9 100644 --- a/test/fixtures/compute_instance/disk_snapshot/variables.tf +++ b/test/fixtures/compute_instance/disk_snapshot/variables.tf @@ -18,4 +18,11 @@ variable "project_id" { description = "The GCP project to use for integration tests" } - +variable "service_account" { + default = null + type = object({ + email = 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/healthcheck/main.tf b/test/fixtures/mig/healthcheck/main.tf index d5c84cea..701f6156 100644 --- a/test/fixtures/mig/healthcheck/main.tf +++ b/test/fixtures/mig/healthcheck/main.tf @@ -15,6 +15,7 @@ */ module "mig_healthcheck" { - source = "../../../../examples/mig/healthcheck" - project_id = var.project_id + source = "../../../../examples/mig/healthcheck" + project_id = var.project_id + service_account = var.service_account } diff --git a/test/fixtures/mig/healthcheck/variables.tf b/test/fixtures/mig/healthcheck/variables.tf index 0029d2be..1adce9a9 100644 --- a/test/fixtures/mig/healthcheck/variables.tf +++ b/test/fixtures/mig/healthcheck/variables.tf @@ -17,3 +17,12 @@ variable "project_id" { description = "The GCP project to use for integration tests" } + +variable "service_account" { + default = null + type = object({ + email = 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." +}