oracle-terraform-modules / terraform-oci-compute-instance

Terraform Module for creating Oracle Cloud Infrastructure compute instances
https://registry.terraform.io/modules/oracle-terraform-modules/compute-instance/oci/latest
Other
46 stars 62 forks source link

instances are not distributed on ADs with using var.instance_count #93

Closed kral2 closed 2 years ago

kral2 commented 2 years ago

PR #88 introduce a bug when var.ad_number == null data.oci_core_shapes.current_ad cannot be created anymore as local.ADs[(var.ad_number - 1)] generates an error when trying to do an arithmetic operation using null.

We currently rely on var.ad_number == null to provision instances in each AD in a round robin manner when var.instance_count is used.

I propose to restore the old behavior for when var.ad_number is set to null and keep the new behavior (checking shapes on the actual requested AD) when an AD number is specified:

data "oci_core_shapes" "current_ad" {
  compartment_id      = var.compartment_ocid
  availability_domain  = var.ad_number == null ? element(local.ADs, 0) : element(local.ADs, var.ad_number - 1)
}

In the current state, the repo's HEAD is breaking a feature that we rely uppon and cannot be released.

Originally posted by @kral2 in https://github.com/oracle-terraform-modules/terraform-oci-compute-instance/issues/88#issuecomment-1024835569