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
scaling_schedulesis a list. Your example is incorrectly putting two items in one item.