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
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,20 @@ This is a collection of opinionated submodules that can be used as building bloc
* [Unmanaged instance group](modules/umig)

## Compatibility
This module is meant for use with Terraform 0.13+ and tested using Terraform 1.0+. If you find incompatibilities using Terraform >=0.13, please open an issue.
If you haven't
[upgraded](https://www.terraform.io/upgrade-guides/0-13.html) and need a Terraform
This module is meant for use with Terraform 1.3+ and tested using Terraform 1.3+. If you find incompatibilities using Terraform >=1.3, please open an issue.

If you haven't [upgraded](https://www.terraform.io/upgrade-guides/0-13.html) and need a Terraform
0.12.x-compatible version of this module, the last released version
intended for Terraform 0.12.x is [v5.1.0](https://registry.terraform.io/modules/terraform-google-modules/-vm/google/v5.1.0).

Terraform compatibility:

| Module Version | Terraform Version Required |
|-----------------------|----------------------------|
| >= 12.0.0 | >= 1.3.0 |
| >= 6.0.0 and < 12.0.0 | 0.13 or greater |
| <= 5.1.0 | 0.12 |

## Examples

Examples of how to use these modules can be found in the [examples](examples) folder.
Expand Down
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
2 changes: 1 addition & 1 deletion autogen/versions.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

terraform {
required_version = ">=0.13.0"
required_version = ">=1.3.0"
required_providers {
google = {
source = "hashicorp/google"
Expand Down
25 changes: 25 additions & 0 deletions examples/mig/healthcheck/main.tf
Original file line number Diff line number Diff line change
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 = 2
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 /
}
}
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
28 changes: 14 additions & 14 deletions modules/mig/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ spec:
version: 11.1.0
actuationTool:
flavor: Terraform
version: ">=0.13.0"
version: ">=1.3.0"
description: {}
content:
examples:
Expand Down 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
26 changes: 13 additions & 13 deletions modules/mig/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -127,19 +127,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
2 changes: 1 addition & 1 deletion modules/mig/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

terraform {
required_version = ">=0.13.0"
required_version = ">=1.3.0"
required_providers {
google = {
source = "hashicorp/google"
Expand Down
2 changes: 1 addition & 1 deletion modules/mig_with_percent/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,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\_initial\_version | Instance template self\_link used to create compute instances for the initial version | `string` | n/a | yes |
Expand Down
28 changes: 14 additions & 14 deletions modules/mig_with_percent/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ spec:
version: 11.1.0
actuationTool:
flavor: Terraform
version: ">=0.13.0"
version: ">=1.3.0"
description: {}
content:
examples:
Expand Down 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
26 changes: 13 additions & 13 deletions modules/mig_with_percent/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -137,19 +137,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
2 changes: 1 addition & 1 deletion modules/mig_with_percent/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

terraform {
required_version = ">=0.13.0"
required_version = ">=1.3.0"
required_providers {
google = {
source = "hashicorp/google"
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/mig/healthcheck/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
*/

terraform {
required_version = ">=0.12.6"
required_version = ">=1.3.0"
}
Loading