diff --git a/autogen/main.tf.tmpl b/autogen/main.tf.tmpl index b1ddb2c0..2c1619f6 100644 --- a/autogen/main.tf.tmpl +++ b/autogen/main.tf.tmpl @@ -146,7 +146,8 @@ resource "google_compute_region_autoscaler" "autoscaler" { dynamic "cpu_utilization" { for_each = var.autoscaling_cpu content { - target = lookup(cpu_utilization.value, "target", null) + target = lookup(cpu_utilization.value, "target", null) + predictive_method = lookup(cpu_utilization.value, "predictive_method", null) } } dynamic "metric" { diff --git a/autogen/variables.tf.tmpl b/autogen/variables.tf.tmpl index e03cc009..4521e77f 100644 --- a/autogen/variables.tf.tmpl +++ b/autogen/variables.tf.tmpl @@ -184,7 +184,10 @@ variable "autoscaling_mode" { 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)) + type = list(object({ + target = number + predictive_method = string + })) default = [] } diff --git a/examples/mig/autoscaler/README.md b/examples/mig/autoscaler/README.md index d37dad7f..5d52287c 100644 --- a/examples/mig/autoscaler/README.md +++ b/examples/mig/autoscaler/README.md @@ -8,7 +8,7 @@ group with an autoscaler. | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| -| autoscaling\_cpu | Autoscaling, cpu utilization policy block as single element array. https://www.terraform.io/docs/providers/google/r/compute_autoscaler.html#cpu_utilization | `list(map(number))` | n/a | yes | +| autoscaling\_cpu | Autoscaling, cpu utilization policy block as single element array. https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_autoscaler#cpu_utilization |
list(object({
target = number
predictive_method = string
}))
| n/a | yes | | autoscaling\_enabled | Creates an autoscaler for the managed instance group | `any` | n/a | yes | | min\_replicas | The minimum number of replicas that the autoscaler can scale down to. This cannot be less than 0. | `any` | n/a | yes | | project\_id | The GCP project to use for integration tests | `string` | n/a | yes | diff --git a/examples/mig/autoscaler/variables.tf b/examples/mig/autoscaler/variables.tf index e62f7b80..31f0b0f5 100644 --- a/examples/mig/autoscaler/variables.tf +++ b/examples/mig/autoscaler/variables.tf @@ -51,7 +51,10 @@ variable "min_replicas" { 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)) + description = "Autoscaling, cpu utilization policy block as single element array. https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_autoscaler#cpu_utilization" + type = list(object({ + target = number + predictive_method = string + })) } diff --git a/examples/mig/healthcheck/main.tf b/examples/mig/healthcheck/main.tf index 7962f80d..9450901f 100644 --- a/examples/mig/healthcheck/main.tf +++ b/examples/mig/healthcheck/main.tf @@ -71,7 +71,8 @@ module "mig" { autoscaling_cpu = [ { - target = 0.4 + target = 0.4 + predictive_method = null # use default of NONE }, ] diff --git a/modules/mig/README.md b/modules/mig/README.md index 5c0f6c2f..3dd9d36e 100644 --- a/modules/mig/README.md +++ b/modules/mig/README.md @@ -19,7 +19,7 @@ The current version is 2.X. The following guides are available to assist with up | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| | autoscaler\_name | Autoscaler name. When variable is empty, name will be derived from var.hostname. | `string` | `""` | no | -| autoscaling\_cpu | Autoscaling, cpu utilization policy block as single element array. https://www.terraform.io/docs/providers/google/r/compute_autoscaler.html#cpu_utilization | `list(map(number))` | `[]` | no | +| autoscaling\_cpu | Autoscaling, cpu utilization policy block as single element array. https://www.terraform.io/docs/providers/google/r/compute_autoscaler.html#cpu_utilization |
list(object({
target = number
predictive_method = string
}))
| `[]` | no | | 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 | diff --git a/modules/mig/main.tf b/modules/mig/main.tf index e7c9d3c1..76fc9194 100644 --- a/modules/mig/main.tf +++ b/modules/mig/main.tf @@ -130,7 +130,8 @@ resource "google_compute_region_autoscaler" "autoscaler" { dynamic "cpu_utilization" { for_each = var.autoscaling_cpu content { - target = lookup(cpu_utilization.value, "target", null) + target = lookup(cpu_utilization.value, "target", null) + predictive_method = lookup(cpu_utilization.value, "predictive_method", null) } } dynamic "metric" { diff --git a/modules/mig/variables.tf b/modules/mig/variables.tf index 591ed769..2c1ae7ff 100644 --- a/modules/mig/variables.tf +++ b/modules/mig/variables.tf @@ -169,8 +169,11 @@ variable "autoscaling_mode" { 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)) - default = [] + type = list(object({ + target = number + predictive_method = string + })) + default = [] } variable "autoscaling_metric" { diff --git a/modules/mig_with_percent/README.md b/modules/mig_with_percent/README.md index 9eb794be..0e7624b4 100644 --- a/modules/mig_with_percent/README.md +++ b/modules/mig_with_percent/README.md @@ -18,7 +18,7 @@ The current version is 2.X. The following guides are available to assist with up | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| | autoscaler\_name | Autoscaler name. When variable is empty, name will be derived from var.hostname. | `string` | `""` | no | -| autoscaling\_cpu | Autoscaling, cpu utilization policy block as single element array. https://www.terraform.io/docs/providers/google/r/compute_autoscaler.html#cpu_utilization | `list(map(number))` | `[]` | no | +| autoscaling\_cpu | Autoscaling, cpu utilization policy block as single element array. https://www.terraform.io/docs/providers/google/r/compute_autoscaler.html#cpu_utilization |
list(object({
target = number
predictive_method = string
}))
| `[]` | no | | 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 | diff --git a/modules/mig_with_percent/main.tf b/modules/mig_with_percent/main.tf index bd04a446..3ad4ec2a 100644 --- a/modules/mig_with_percent/main.tf +++ b/modules/mig_with_percent/main.tf @@ -139,7 +139,8 @@ resource "google_compute_region_autoscaler" "autoscaler" { dynamic "cpu_utilization" { for_each = var.autoscaling_cpu content { - target = lookup(cpu_utilization.value, "target", null) + target = lookup(cpu_utilization.value, "target", null) + predictive_method = lookup(cpu_utilization.value, "predictive_method", null) } } dynamic "metric" { diff --git a/modules/mig_with_percent/variables.tf b/modules/mig_with_percent/variables.tf index 33ef6cd3..1614b92b 100644 --- a/modules/mig_with_percent/variables.tf +++ b/modules/mig_with_percent/variables.tf @@ -177,8 +177,11 @@ variable "autoscaling_mode" { 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)) - default = [] + type = list(object({ + target = number + predictive_method = string + })) + default = [] } variable "autoscaling_metric" { diff --git a/test/fixtures/mig/autoscaler/main.tf b/test/fixtures/mig/autoscaler/main.tf index aa91aa26..6df78ba9 100644 --- a/test/fixtures/mig/autoscaler/main.tf +++ b/test/fixtures/mig/autoscaler/main.tf @@ -24,7 +24,8 @@ module "mig_autoscaler" { autoscaling_cpu = [ { - target = 0.6 + target = 0.6, + predictive_method = null, }, ] }