0

Below is the terraform code:

resource "google_compute_autoscaler" "default" {
  provider = google-beta
  name     = "my-autoscaler"
  zone     = "us-central1-f"
  target   = google_compute_instance_group_manager.default.id
  autoscaling_policy {
    max_replicas    = 5
    min_replicas    = 1
    cooldown_period = 60

    scaling_schedules {
      name                  = "every-weekday-morning-1"
      description           = "Increase to 2 every weekday at 7AM for 1 hour."
      min_required_replicas = 2
      schedule              = "0 7 * * MON-FRI"
      time_zone             = "America/New_York"
      duration_sec          = 3600,
      name                  = "every-weekday-morning-2"
      description           = "Increase to 2 every weekday at 8AM for 1 hour."
      min_required_replicas = 3
      schedule              = "0 8 * * MON-FRI"
      time_zone             = "America/New_York"
      duration_sec          = 3600
    }
  }
}

When I look into https://github.com/terraform-google-modules/terraform-google-vm/blob/master/modules/mig/variables.tf, below is variable format:

variable "scaling_schedules" {
  description = "Autoscaling, scaling schedule block"
  type = list(object({
    disabled              = bool
    duration_sec          = number
    min_required_replicas = number
    name                  = string
    schedule              = string
    time_zone             = string
  }))
  default = []
}

When I run terraform init, I get below error->

The argument "name" was already set ../../modules_mig/main.tf:192.7-11. Each argument may be set only once

when we try adding multiple schedules using gcloud utility, we are able to add but it gives error when we add using terraform

2
  • scaling_schedules is a list. Your example is incorrectly putting two items in one item. Commented May 19, 2023 at 16:26
  • I even tried in below format.scaling_schedules [{scaling schedule 1st configuration},{scaling 2nd configuration}] this format gives me error Commented May 21, 2023 at 15:22

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.