From 1c8f7759262c0a24f83268fcb7561bb7e01e7d8b Mon Sep 17 00:00:00 2001 From: Tom Downes Date: Wed, 19 Jul 2023 10:38:43 -0500 Subject: [PATCH] feat: expose distribution_policy_target_shape setting for MIGs (#327) --- autogen/main.tf.tmpl | 3 ++- autogen/variables.tf.tmpl | 6 ++++++ modules/mig/README.md | 1 + modules/mig/main.tf | 3 ++- modules/mig/variables.tf | 6 ++++++ modules/mig_with_percent/README.md | 1 + modules/mig_with_percent/main.tf | 3 ++- modules/mig_with_percent/variables.tf | 6 ++++++ 8 files changed, 26 insertions(+), 3 deletions(-) diff --git a/autogen/main.tf.tmpl b/autogen/main.tf.tmpl index e4649836..00be3ede 100644 --- a/autogen/main.tf.tmpl +++ b/autogen/main.tf.tmpl @@ -103,7 +103,8 @@ resource "google_compute_region_instance_group_manager" "{{ module_name }}" { } } - distribution_policy_zones = local.distribution_policy_zones + distribution_policy_target_shape = var.distribution_policy_target_shape + distribution_policy_zones = local.distribution_policy_zones dynamic "update_policy" { for_each = var.update_policy content { diff --git a/autogen/variables.tf.tmpl b/autogen/variables.tf.tmpl index 3ee18c11..6363798b 100644 --- a/autogen/variables.tf.tmpl +++ b/autogen/variables.tf.tmpl @@ -74,6 +74,12 @@ variable "target_pools" { default = [] } +variable "distribution_policy_target_shape" { + description = "MIG target distribution shape (EVEN, BALANCED, ANY, ANY_SINGLE_ZONE)" + type = string + default = null +} + variable "distribution_policy_zones" { description = "The distribution policy, i.e. which zone(s) should instances be create in. Default is all zones in given region." type = list(string) diff --git a/modules/mig/README.md b/modules/mig/README.md index 732d0d0c..4d5aeab9 100644 --- a/modules/mig/README.md +++ b/modules/mig/README.md @@ -26,6 +26,7 @@ The current version is 2.X. The following guides are available to assist with up | autoscaling\_mode | Operating mode of the autoscaling policy. If omitted, the default value is ON. https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_autoscaler#mode | `string` | `null` | no | | autoscaling\_scale\_in\_control | Autoscaling, scale-in control block. https://www.terraform.io/docs/providers/google/r/compute_autoscaler#scale_in_control |
object({
fixed_replicas = number
percent_replicas = number
time_window_sec = number
})
|
{
"fixed_replicas": null,
"percent_replicas": null,
"time_window_sec": null
}
| no | | 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 |
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
})
|
{
"check_interval_sec": 30,
"enable_logging": false,
"healthy_threshold": 1,
"host": "",
"initial_delay_sec": 30,
"port": 80,
"proxy_header": "NONE",
"request": "",
"request_path": "/",
"response": "",
"timeout_sec": 10,
"type": "",
"unhealthy_threshold": 5
}
| no | | health\_check\_name | Health check name. When variable is empty, name will be derived from var.hostname. | `string` | `""` | no | diff --git a/modules/mig/main.tf b/modules/mig/main.tf index 3fc7ff6e..8bb7223b 100644 --- a/modules/mig/main.tf +++ b/modules/mig/main.tf @@ -87,7 +87,8 @@ resource "google_compute_region_instance_group_manager" "mig" { } } - distribution_policy_zones = local.distribution_policy_zones + distribution_policy_target_shape = var.distribution_policy_target_shape + distribution_policy_zones = local.distribution_policy_zones dynamic "update_policy" { for_each = var.update_policy content { diff --git a/modules/mig/variables.tf b/modules/mig/variables.tf index 38391ed2..767bb51f 100644 --- a/modules/mig/variables.tf +++ b/modules/mig/variables.tf @@ -56,6 +56,12 @@ variable "target_pools" { default = [] } +variable "distribution_policy_target_shape" { + description = "MIG target distribution shape (EVEN, BALANCED, ANY, ANY_SINGLE_ZONE)" + type = string + default = null +} + variable "distribution_policy_zones" { description = "The distribution policy, i.e. which zone(s) should instances be create in. Default is all zones in given region." type = list(string) diff --git a/modules/mig_with_percent/README.md b/modules/mig_with_percent/README.md index b9c74f01..08ba215f 100644 --- a/modules/mig_with_percent/README.md +++ b/modules/mig_with_percent/README.md @@ -25,6 +25,7 @@ The current version is 2.X. The following guides are available to assist with up | autoscaling\_mode | Operating mode of the autoscaling policy. If omitted, the default value is ON. https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_autoscaler#mode | `string` | `null` | no | | autoscaling\_scale\_in\_control | Autoscaling, scale-in control block. https://www.terraform.io/docs/providers/google/r/compute_autoscaler#scale_in_control |
object({
fixed_replicas = number
percent_replicas = number
time_window_sec = number
})
|
{
"fixed_replicas": null,
"percent_replicas": null,
"time_window_sec": null
}
| no | | 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 |
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
})
|
{
"check_interval_sec": 30,
"enable_logging": false,
"healthy_threshold": 1,
"host": "",
"initial_delay_sec": 30,
"port": 80,
"proxy_header": "NONE",
"request": "",
"request_path": "/",
"response": "",
"timeout_sec": 10,
"type": "",
"unhealthy_threshold": 5
}
| no | | health\_check\_name | Health check name. When variable is empty, name will be derived from var.hostname. | `string` | `""` | no | diff --git a/modules/mig_with_percent/main.tf b/modules/mig_with_percent/main.tf index 3d34a4ce..2f16e631 100644 --- a/modules/mig_with_percent/main.tf +++ b/modules/mig_with_percent/main.tf @@ -96,7 +96,8 @@ resource "google_compute_region_instance_group_manager" "mig_with_percent" { } } - distribution_policy_zones = local.distribution_policy_zones + distribution_policy_target_shape = var.distribution_policy_target_shape + distribution_policy_zones = local.distribution_policy_zones dynamic "update_policy" { for_each = var.update_policy content { diff --git a/modules/mig_with_percent/variables.tf b/modules/mig_with_percent/variables.tf index dc5a48ac..e6f6268d 100644 --- a/modules/mig_with_percent/variables.tf +++ b/modules/mig_with_percent/variables.tf @@ -66,6 +66,12 @@ variable "target_pools" { default = [] } +variable "distribution_policy_target_shape" { + description = "MIG target distribution shape (EVEN, BALANCED, ANY, ANY_SINGLE_ZONE)" + type = string + default = null +} + variable "distribution_policy_zones" { description = "The distribution policy, i.e. which zone(s) should instances be create in. Default is all zones in given region." type = list(string)