Open kral2 opened 3 years ago
var.block_storage_sizes_in_gbs is a list of numbers where one BV is created for each element, with BV size is equal to the passed number.
var.block_storage_sizes_in_gbs
Having a list is problematic when we need an update:
The example below will create 3 volumes named xxx_volume0,xxx_volume1,xxx_volume2.
resource "oci_core_volume" "this" { count = var.instance_count * length(var.block_storage_sizes_in_gbs) availability_domain = oci_core_instance.this[count.index % var.instance_count].availability_domain compartment_id = var.compartment_ocid display_name = "${oci_core_instance.this[count.index % var.instance_count].display_name}_volume${floor(count.index / var.instance_count)}" size_in_gbs = element( var.block_storage_sizes_in_gbs, floor(count.index / var.instance_count), ) freeform_tags = local.merged_freeform_tags defined_tags = var.defined_tags } variable "block_storage_sizes_in_gbs" { description = "Sizes of volumes to create and attach to each instance." type = list(number) default = [50,55,56] }
If var.block_storage_sizes_in_gbs is edited, removing 55 from the list for example:
55
xxx_volume1
xxx_volume2
xxx_volume0
To have a consistent behavior, the logic behind var.block_storage_sizes_in_gbs needs to be rewritten using a for_each implementation.
var.block_storage_sizes_in_gbs
is a list of numbers where one BV is created for each element, with BV size is equal to the passed number.Having a list is problematic when we need an update:
The example below will create 3 volumes named xxx_volume0,xxx_volume1,xxx_volume2.
If
var.block_storage_sizes_in_gbs
is edited, removing55
from the list for example:xxx_volume1
removed, Terraform will removexxx_volume2
and update size ofxxx_volume1
(when possible),xxx_volume1
but not touchxxx_volume0
andxxx_volume2
.To have a consistent behavior, the logic behind
var.block_storage_sizes_in_gbs
needs to be rewritten using a for_each implementation.