terraform-google-modules/terraform-google-vm

[MIG] Allow configuring autoscaling schedules

BapRx opened this issue · 2 comments

BapRx commented

TL;DR

Allow configuring scaling_schedules under autoscaling_policy in the mig module:

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # module.mig.google_compute_region_autoscaler.autoscaler[0] will be updated in-place
  ~ resource "google_compute_region_autoscaler" "autoscaler" {
        id                 = "projects/redacted/regions/europe-west1/autoscalers/redacted-mig"
        name               = "redacted-mig"
        # (5 unchanged attributes hidden)

      ~ autoscaling_policy {
            # (4 unchanged attributes hidden)


          - scaling_schedules {
              - disabled              = false -> null
              - duration_sec          = 12600 -> null
              - min_required_replicas = 3 -> null
              - name                  = "redacted-18-05-2022" -> null
              - schedule              = "45 15 18 5 * 2022" -> null
              - time_zone             = "Europe/Paris" -> null
            }
            # (1 unchanged block hidden)
        }
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Terraform Resources

module: terraform-google-modules/vm/google//modules/mig

Detailed design

I would like to provide the following object to the module to configure autoscaling schedules:
autoscaling_schedules = [
  {
    disabled              = false
    duration_sec          = 12600, # 3h30
    min_required_replicas = 3,
    name                  = "redacted-18-05-2022",
    schedule              = "45 15 18 5 * 2022",
    timezone              = "Europe/Paris",
  },
]

That variable would be used in a dynamic bloc inside the module to construct the following block:
scaling_schedules {
    disabled              = false
    duration_sec          = 12600
    min_required_replicas = 3
    name                  = "redacted-18-05-2022"
    schedule              = "45 15 18 5 * 2022"
    time_zone             = "Europe/Paris"
}

Additional information

No response

BapRx commented

Hey, I created this PR to add the functionality I was looking for: #247

image

BapRx commented

#247 merged