通常,我如何重构内联资源,并使用单独的卷资源将其作为单独的资源移出外部。
例如,是否有一种方法可以重构block_device
并将其移到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
}
}
答案 0 :(得分: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}"
}