0

通常,如何重构内联资源并使用单独的卷资源将其作为单独的资源移出。

例如,有没有办法重构 ablock_device并将其移到 a 之外openstack_compute_instance_v2,如下所示?

resource "openstack_compute_instance_v2" "instance_sakani_front_end_x" {
  ...
  block_device {
    uuid                  = ""
    volume_size           = 30
    boot_index            = 0
    destination_type      = "volume"
    delete_on_termination = true
  }

}

4

1 回答 1

1

您可以将其block_device拉出到本地地图变量中

   resource "openstack_compute_instance_v2" "instance_sakani_front_end_x" {
      ...
      block_device {
        uuid                  = ""
        volume_size           = 30
        boot_index            = 0
        destination_type      = "volume"
        delete_on_termination = true
      }
    }

像这样

locals {
    my_block_device {
        volume_size           = 30
        boot_index            = 0
        destination_type      = "volume"
        delete_on_termination = true
    }
}   

resource "openstack_compute_instance_v2" "instance_sakani_front_end_x" {
  ...
  block_device = "${local.my_block_device}"
}
于 2018-07-23T17:21:32.790 回答