无法使用 terraform 在 GCP VM 中添加多个缩放计划

问题描述 投票:0回答:0

下面是地形代码:

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
    }
  }
}

当我查看https://github.com/terraform-google-modules/terraform-google-vm/blob/master/modules/mig/variables.tf时,下面是变量格式:

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 = []
}

当我运行 terraform init 时,出现以下错误-> 参数“名称”已设置 ../../modules_mig/main.tf:192.7-11。每个参数只能设置一次

当我们尝试使用 gcloud 实用程序添加多个计划时,我们能够添加但是当我们使用 terraform 添加时它会出错

google-cloud-platform terraform-provider-gcp
© www.soinside.com 2019 - 2024. All rights reserved.