Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(TF>=1.3)!: make mig health check fields optional #385

Closed
wants to merge 10 commits into from
26 changes: 13 additions & 13 deletions autogen/variables.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -145,19 +145,19 @@ variable "health_check_name" {
variable "health_check" {
description = "Health check to determine whether instances are responsive and able to do work"
type = object({
type = string
initial_delay_sec = number
check_interval_sec = number
healthy_threshold = number
timeout_sec = number
unhealthy_threshold = number
response = string
proxy_header = string
port = number
request = string
request_path = string
host = string
enable_logging = bool
type = optional(string, "")
initial_delay_sec = optional(number, 30)
check_interval_sec = optional(number, 30)
healthy_threshold = optional(number, 1)
timeout_sec = optional(number, 10)
unhealthy_threshold = optional(number, 5)
response = optional(string, "")
proxy_header = optional(string, "NONE")
port = optional(number, 80)
request = optional(string, "")
request_path = optional(string, "/")
host = optional(string, "")
enable_logging = optional(bool, false)
})
default = {
type = ""
Expand Down
6 changes: 3 additions & 3 deletions examples/compute_instance/disk_snapshot/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ data "google_compute_zones" "available" {

module "instance_template" {
source = "terraform-google-modules/vm/google//modules/instance_template"
version = "~> 10.0"
version = "~> 11.0"

region = var.region
project_id = var.project_id
Expand Down Expand Up @@ -59,7 +59,7 @@ module "instance_template" {

module "compute_instance" {
source = "terraform-google-modules/vm/google//modules/compute_instance"
version = "~> 10.0"
version = "~> 11.0"

region = var.region
subnetwork = var.subnetwork
Expand All @@ -70,7 +70,7 @@ module "compute_instance" {

module "disk_snapshots" {
source = "terraform-google-modules/vm/google//modules/compute_disk_snapshot"
version = "~> 10.0"
version = "~> 11.0"

name = "backup-policy-test"
project = var.project_id
Expand Down
4 changes: 2 additions & 2 deletions examples/compute_instance/simple/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

module "instance_template" {
source = "terraform-google-modules/vm/google//modules/instance_template"
version = "~> 10.0"
version = "~> 11.0"

region = var.region
project_id = var.project_id
Expand All @@ -26,7 +26,7 @@ module "instance_template" {

module "compute_instance" {
source = "terraform-google-modules/vm/google//modules/compute_instance"
version = "~> 10.0"
version = "~> 11.0"

region = var.region
zone = var.zone
Expand Down
2 changes: 1 addition & 1 deletion examples/instance_template/additional_disks/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ provider "google" {

module "instance_template" {
source = "terraform-google-modules/vm/google//modules/instance_template"
version = "~> 10.0"
version = "~> 11.0"

project_id = var.project_id
subnetwork = var.subnetwork
Expand Down
2 changes: 1 addition & 1 deletion examples/instance_template/alias_ip_range/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ resource "google_compute_address" "ip_address" {

module "instance_template" {
source = "terraform-google-modules/vm/google//modules/instance_template"
version = "~> 10.0"
version = "~> 11.0"

project_id = var.project_id
subnetwork = var.subnetwork
Expand Down
2 changes: 1 addition & 1 deletion examples/instance_template/encrypted_disks/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ resource "google_kms_crypto_key" "example-key" {

module "instance_template" {
source = "terraform-google-modules/vm/google//modules/instance_template"
version = "~> 10.0"
version = "~> 11.0"

project_id = var.project_id
subnetwork = var.subnetwork
Expand Down
2 changes: 1 addition & 1 deletion examples/instance_template/simple/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ locals {

module "instance_template" {
source = "terraform-google-modules/vm/google//modules/instance_template"
version = "~> 10.0"
version = "~> 11.0"

project_id = var.project_id
subnetwork = var.subnetwork
Expand Down
4 changes: 2 additions & 2 deletions examples/mig/autoscaler/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ provider "google-beta" {

module "instance_template" {
source = "terraform-google-modules/vm/google//modules/instance_template"
version = "~> 10.0"
version = "~> 11.0"

project_id = var.project_id
subnetwork = var.subnetwork
Expand All @@ -37,7 +37,7 @@ module "instance_template" {

module "mig" {
source = "terraform-google-modules/vm/google//modules/mig"
version = "~> 10.0"
version = "~> 11.0"

project_id = var.project_id
region = var.region
Expand Down
4 changes: 2 additions & 2 deletions examples/mig/full/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ provider "google-beta" {

module "instance_template" {
source = "terraform-google-modules/vm/google//modules/instance_template"
version = "~> 10.0"
version = "~> 11.0"

name_prefix = "${var.hostname}-instance-template"
project_id = var.project_id
Expand Down Expand Up @@ -58,7 +58,7 @@ module "instance_template" {

module "mig" {
source = "terraform-google-modules/vm/google//modules/mig"
version = "~> 10.0"
version = "~> 11.0"

project_id = var.project_id
hostname = var.hostname
Expand Down
29 changes: 27 additions & 2 deletions examples/mig/healthcheck/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ resource "google_compute_subnetwork" "main" {

module "instance_template" {
source = "terraform-google-modules/vm/google//modules/instance_template"
version = "~> 10.0"
version = "~> 11.0"

project_id = var.project_id
subnetwork = google_compute_subnetwork.main.name
Expand All @@ -63,7 +63,7 @@ module "instance_template" {

module "mig" {
source = "terraform-google-modules/vm/google//modules/mig"
version = "~> 10.0"
version = "~> 11.0"

project_id = var.project_id
instance_template = module.instance_template.self_link
Expand Down Expand Up @@ -97,3 +97,28 @@ module "mig" {
enable_logging = false
}
}

module "mig_health_check_optional_fields" {
source = "terraform-google-modules/vm/google//modules/mig"
version = "~> 11.0"

project_id = var.project_id
instance_template = module.instance_template.self_link
region = var.region
autoscaling_enabled = true
min_replicas = 1
autoscaler_name = "mig-as-optional-fields"
hostname = "mig-as-optional-fields"

autoscaling_cpu = [
{
target = 0.4
predictive_method = null # use default of NONE
},
]

health_check_name = "mig-http-hc"
health_check = {
type = "http" # use default port 80 and path /
}
}
4 changes: 2 additions & 2 deletions examples/mig/simple/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ provider "google-beta" {

module "instance_template" {
source = "terraform-google-modules/vm/google//modules/instance_template"
version = "~> 10.0"
version = "~> 11.0"

project_id = var.project_id
subnetwork = var.subnetwork
Expand All @@ -36,7 +36,7 @@ module "instance_template" {

module "mig" {
source = "terraform-google-modules/vm/google//modules/mig"
version = "~> 10.0"
version = "~> 11.0"

project_id = var.project_id
region = var.region
Expand Down
4 changes: 2 additions & 2 deletions examples/mig_stateful/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ resource "google_compute_subnetwork" "main" {

module "instance_template" {
source = "terraform-google-modules/vm/google//modules/instance_template"
version = "~> 10.0"
version = "~> 11.0"

project_id = var.project_id
region = var.region
Expand All @@ -55,7 +55,7 @@ module "instance_template" {

module "mig" {
source = "terraform-google-modules/vm/google//modules/mig"
version = "~> 10.0"
version = "~> 11.0"

project_id = var.project_id
region = var.region
Expand Down
4 changes: 2 additions & 2 deletions examples/mig_with_percent/simple/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ provider "google-beta" {

module "preemptible_and_regular_instance_templates" {
source = "terraform-google-modules/vm/google//modules/preemptible_and_regular_instance_templates"
version = "~> 10.0"
version = "~> 11.0"

subnetwork = var.subnetwork
service_account = var.service_account
}

module "mig_with_percent" {
source = "terraform-google-modules/vm/google//modules/mig_with_percent"
version = "~> 10.0"
version = "~> 11.0"

region = var.region
target_size = 4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ provider "google" {

module "preemptible_and_regular_instance_templates" {
source = "terraform-google-modules/vm/google//modules/preemptible_and_regular_instance_templates"
version = "~> 10.0"
version = "~> 11.0"

subnetwork = var.subnetwork
project_id = var.project_id
Expand Down
4 changes: 2 additions & 2 deletions examples/umig/full/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ locals {

module "instance_template" {
source = "terraform-google-modules/vm/google//modules/instance_template"
version = "~> 10.0"
version = "~> 11.0"

name_prefix = "${var.hostname}-instance-template"
machine_type = var.machine_type
Expand Down Expand Up @@ -61,7 +61,7 @@ module "instance_template" {

module "umig" {
source = "terraform-google-modules/vm/google//modules/umig"
version = "~> 10.0"
version = "~> 11.0"

project_id = var.project_id
subnetwork = var.subnetwork
Expand Down
4 changes: 2 additions & 2 deletions examples/umig/named_ports/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ provider "google" {

module "instance_template" {
source = "terraform-google-modules/vm/google//modules/instance_template"
version = "~> 10.0"
version = "~> 11.0"

project_id = var.project_id
subnetwork = var.subnetwork
Expand All @@ -31,7 +31,7 @@ module "instance_template" {

module "umig" {
source = "terraform-google-modules/vm/google//modules/umig"
version = "~> 10.0"
version = "~> 11.0"

project_id = var.project_id
subnetwork = var.subnetwork
Expand Down
4 changes: 2 additions & 2 deletions examples/umig/simple/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ provider "google" {

module "instance_template" {
source = "terraform-google-modules/vm/google//modules/instance_template"
version = "~> 10.0"
version = "~> 11.0"

project_id = var.project_id
subnetwork = var.subnetwork
Expand All @@ -31,7 +31,7 @@ module "instance_template" {

module "umig" {
source = "terraform-google-modules/vm/google//modules/umig"
version = "~> 10.0"
version = "~> 11.0"

project_id = var.project_id
subnetwork = var.subnetwork
Expand Down
4 changes: 2 additions & 2 deletions examples/umig/static_ips/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ provider "google" {

module "instance_template" {
source = "terraform-google-modules/vm/google//modules/instance_template"
version = "~> 10.0"
version = "~> 11.0"

project_id = var.project_id
subnetwork = var.subnetwork
Expand All @@ -31,7 +31,7 @@ module "instance_template" {

module "umig" {
source = "terraform-google-modules/vm/google//modules/umig"
version = "~> 10.0"
version = "~> 11.0"

project_id = var.project_id
subnetwork = var.subnetwork
Expand Down
2 changes: 1 addition & 1 deletion modules/mig/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ The current version is 2.X. The following guides are available to assist with up
| cooldown\_period | The number of seconds that the autoscaler should wait before it starts collecting information from a new instance. | `number` | `60` | no |
| distribution\_policy\_target\_shape | MIG target distribution shape (EVEN, BALANCED, ANY, ANY\_SINGLE\_ZONE) | `string` | `null` | no |
| distribution\_policy\_zones | The distribution policy, i.e. which zone(s) should instances be create in. Default is all zones in given region. | `list(string)` | `[]` | no |
| health\_check | Health check to determine whether instances are responsive and able to do work | <pre>object({<br> type = string<br> initial_delay_sec = number<br> check_interval_sec = number<br> healthy_threshold = number<br> timeout_sec = number<br> unhealthy_threshold = number<br> response = string<br> proxy_header = string<br> port = number<br> request = string<br> request_path = string<br> host = string<br> enable_logging = bool<br> })</pre> | <pre>{<br> "check_interval_sec": 30,<br> "enable_logging": false,<br> "healthy_threshold": 1,<br> "host": "",<br> "initial_delay_sec": 30,<br> "port": 80,<br> "proxy_header": "NONE",<br> "request": "",<br> "request_path": "/",<br> "response": "",<br> "timeout_sec": 10,<br> "type": "",<br> "unhealthy_threshold": 5<br>}</pre> | no |
| health\_check | Health check to determine whether instances are responsive and able to do work | <pre>object({<br> type = optional(string, "")<br> initial_delay_sec = optional(number, 30)<br> check_interval_sec = optional(number, 30)<br> healthy_threshold = optional(number, 1)<br> timeout_sec = optional(number, 10)<br> unhealthy_threshold = optional(number, 5)<br> response = optional(string, "")<br> proxy_header = optional(string, "NONE")<br> port = optional(number, 80)<br> request = optional(string, "")<br> request_path = optional(string, "/")<br> host = optional(string, "")<br> enable_logging = optional(bool, false)<br> })</pre> | <pre>{<br> "check_interval_sec": 30,<br> "enable_logging": false,<br> "healthy_threshold": 1,<br> "host": "",<br> "initial_delay_sec": 30,<br> "port": 80,<br> "proxy_header": "NONE",<br> "request": "",<br> "request_path": "/",<br> "response": "",<br> "timeout_sec": 10,<br> "type": "",<br> "unhealthy_threshold": 5<br>}</pre> | no |
| health\_check\_name | Health check name. When variable is empty, name will be derived from var.hostname. | `string` | `""` | no |
| hostname | Hostname prefix for instances | `string` | `"default"` | no |
| instance\_template | Instance template self\_link used to create compute instances | `string` | n/a | yes |
Expand Down
26 changes: 13 additions & 13 deletions modules/mig/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -133,19 +133,19 @@ spec:
description: Health check to determine whether instances are responsive and able to do work
varType: |-
object({
type = string
initial_delay_sec = number
check_interval_sec = number
healthy_threshold = number
timeout_sec = number
unhealthy_threshold = number
response = string
proxy_header = string
port = number
request = string
request_path = string
host = string
enable_logging = bool
type = optional(string, "")
initial_delay_sec = optional(number, 30)
check_interval_sec = optional(number, 30)
healthy_threshold = optional(number, 1)
timeout_sec = optional(number, 10)
unhealthy_threshold = optional(number, 5)
response = optional(string, "")
proxy_header = optional(string, "NONE")
port = optional(number, 80)
request = optional(string, "")
request_path = optional(string, "/")
host = optional(string, "")
enable_logging = optional(bool, false)
})
defaultValue:
check_interval_sec: 30
Expand Down
Loading