【问题标题】:How to add a snapshot schedule to GCP boot_disk via terraform如何通过 terraform 将快照计划添加到 GCP boot_disk
【发布时间】:2021-09-03 04:52:09
【问题描述】:

我正在尝试将快照计划添加到 vm_instance 的启动磁盘。

provider "google" {
  project = "xxxxxx"
}
resource "google_compute_instance" "xxxxxx" {
  name         = "xxxxxx"
  machine_type = "xxxxxx"
  zone         = "xxxxxx"

  boot_disk {
    initialize_params {
      image = "???"
    }
  }
  metadata_startup_script = ";;"
  network_interface {
    network = "default"
   }
}      

我知道如何将计划添加到外部磁盘: https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_disk_resource_policy_attachment

但是您如何使用 vm_instance 磁盘执行此操作?

谢谢

【问题讨论】:

    标签: google-cloud-platform terraform disk terraform-provider-gcp


    【解决方案1】:

    要在启动磁盘上创建快照调度程序,请修改“google_compute_disk_resource_policy_attachment”资源中“disk”字段的值,使其指向启动磁盘与虚拟机名称同名,默认为“Standard Persistent disk”类型。 因此,使用创建的 VM 的名称,即“google_compute_instance..name”将允许您将快照调度程序指向 VM 的启动磁盘。

    Argument Reference 了解更多信息。

    参考下面的示例配置:

    示例.tf

    resource "google_compute_disk_resource_policy_attachment" "attachment" {
      name = google_compute_resource_policy.policy.name
      disk = google_compute_instance.<reference-name>.name
      zone = "<zone-name>"
    }
    

    参考:google_compute_disk_resource_policy_attachment

    【讨论】:

      猜你喜欢
      • 2020-07-28
      • 2019-06-13
      • 1970-01-01
      • 2020-02-19
      • 1970-01-01
      • 2022-01-05
      • 2017-06-05
      • 1970-01-01
      • 2018-09-04
      相关资源
      最近更新 更多