From 019e3a41e1828abd6478fe1022c576573e3d6bc9 Mon Sep 17 00:00:00 2001 From: Mikhail Zholobov Date: Wed, 19 Jan 2022 16:32:10 +0100 Subject: [PATCH] feat: [mig] Add "autoscaling_mode" variable (#224) --- autogen/main.tf.tmpl | 1 + autogen/variables.tf.tmpl | 6 ++++++ modules/mig/README.md | 1 + modules/mig/main.tf | 1 + modules/mig/variables.tf | 6 ++++++ modules/mig_with_percent/README.md | 1 + modules/mig_with_percent/main.tf | 1 + modules/mig_with_percent/variables.tf | 6 ++++++ 8 files changed, 23 insertions(+) diff --git a/autogen/main.tf.tmpl b/autogen/main.tf.tmpl index 3279b442..83f466b0 100644 --- a/autogen/main.tf.tmpl +++ b/autogen/main.tf.tmpl @@ -132,6 +132,7 @@ resource "google_compute_region_autoscaler" "autoscaler" { max_replicas = var.max_replicas min_replicas = var.min_replicas cooldown_period = var.cooldown_period + mode = var.autoscaling_mode dynamic "scale_in_control" { for_each = local.autoscaling_scale_in_enabled ? [var.autoscaling_scale_in_control] : [] content { diff --git a/autogen/variables.tf.tmpl b/autogen/variables.tf.tmpl index d46c837e..f99788c8 100644 --- a/autogen/variables.tf.tmpl +++ b/autogen/variables.tf.tmpl @@ -176,6 +176,12 @@ variable "cooldown_period" { default = 60 } +variable "autoscaling_mode" { + description = "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" + type = string + default = null +} + variable "autoscaling_cpu" { description = "Autoscaling, cpu utilization policy block as single element array. https://www.terraform.io/docs/providers/google/r/compute_autoscaler.html#cpu_utilization" type = list(map(number)) diff --git a/modules/mig/README.md b/modules/mig/README.md index 0cf74879..4dead6de 100644 --- a/modules/mig/README.md +++ b/modules/mig/README.md @@ -23,6 +23,7 @@ The current version is 2.X. The following guides are available to assist with up | autoscaling\_enabled | Creates an autoscaler for the managed instance group | `string` | `"false"` | no | | autoscaling\_lb | Autoscaling, load balancing utilization policy block as single element array. https://www.terraform.io/docs/providers/google/r/compute_autoscaler.html#load_balancing_utilization | `list(map(number))` | `[]` | no | | autoscaling\_metric | Autoscaling, metric policy block as single element array. https://www.terraform.io/docs/providers/google/r/compute_autoscaler.html#metric |
list(object({
name = string
target = number
type = string
}))
| `[]` | no | +| 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.html#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\_zones | The distribution policy, i.e. which zone(s) should instances be create in. Default is all zones in given region. | `list(string)` | `[]` | no | diff --git a/modules/mig/main.tf b/modules/mig/main.tf index dac47a23..0ad424ca 100644 --- a/modules/mig/main.tf +++ b/modules/mig/main.tf @@ -116,6 +116,7 @@ resource "google_compute_region_autoscaler" "autoscaler" { max_replicas = var.max_replicas min_replicas = var.min_replicas cooldown_period = var.cooldown_period + mode = var.autoscaling_mode dynamic "scale_in_control" { for_each = local.autoscaling_scale_in_enabled ? [var.autoscaling_scale_in_control] : [] content { diff --git a/modules/mig/variables.tf b/modules/mig/variables.tf index 627223f5..917fd256 100644 --- a/modules/mig/variables.tf +++ b/modules/mig/variables.tf @@ -161,6 +161,12 @@ variable "cooldown_period" { default = 60 } +variable "autoscaling_mode" { + description = "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" + type = string + default = null +} + variable "autoscaling_cpu" { description = "Autoscaling, cpu utilization policy block as single element array. https://www.terraform.io/docs/providers/google/r/compute_autoscaler.html#cpu_utilization" type = list(map(number)) diff --git a/modules/mig_with_percent/README.md b/modules/mig_with_percent/README.md index 0a9e50b3..4a2fa557 100644 --- a/modules/mig_with_percent/README.md +++ b/modules/mig_with_percent/README.md @@ -22,6 +22,7 @@ The current version is 2.X. The following guides are available to assist with up | autoscaling\_enabled | Creates an autoscaler for the managed instance group | `string` | `"false"` | no | | autoscaling\_lb | Autoscaling, load balancing utilization policy block as single element array. https://www.terraform.io/docs/providers/google/r/compute_autoscaler.html#load_balancing_utilization | `list(map(number))` | `[]` | no | | autoscaling\_metric | Autoscaling, metric policy block as single element array. https://www.terraform.io/docs/providers/google/r/compute_autoscaler.html#metric |
list(object({
name = string
target = number
type = string
}))
| `[]` | no | +| 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.html#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\_zones | The distribution policy, i.e. which zone(s) should instances be create in. Default is all zones in given region. | `list(string)` | `[]` | no | diff --git a/modules/mig_with_percent/main.tf b/modules/mig_with_percent/main.tf index ff0ec6c5..d2305a0b 100644 --- a/modules/mig_with_percent/main.tf +++ b/modules/mig_with_percent/main.tf @@ -125,6 +125,7 @@ resource "google_compute_region_autoscaler" "autoscaler" { max_replicas = var.max_replicas min_replicas = var.min_replicas cooldown_period = var.cooldown_period + mode = var.autoscaling_mode dynamic "scale_in_control" { for_each = local.autoscaling_scale_in_enabled ? [var.autoscaling_scale_in_control] : [] content { diff --git a/modules/mig_with_percent/variables.tf b/modules/mig_with_percent/variables.tf index c14184b7..7cdb15d9 100644 --- a/modules/mig_with_percent/variables.tf +++ b/modules/mig_with_percent/variables.tf @@ -169,6 +169,12 @@ variable "cooldown_period" { default = 60 } +variable "autoscaling_mode" { + description = "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" + type = string + default = null +} + variable "autoscaling_cpu" { description = "Autoscaling, cpu utilization policy block as single element array. https://www.terraform.io/docs/providers/google/r/compute_autoscaler.html#cpu_utilization" type = list(map(number))