Open brokedba opened 1 year ago
Dear team , please check your tf code next time . I wasted quite a time debugging this .
Problem fixed
You forgot to put the full availability domain conditional expression on 2 of your vm resources (4 vms total).
"web-vms" and "db-vms"
You should add this : ( length(data.oci_identity_availability_domains.ads.availability_domains) == 1 ? data.oci_identity_availability_domains.ads.availability_domains[0].name
like you did for Primary/Secondary FortiGate VM.
resource "oci_core_instance" "web-vms" {
count = 2
availability_domain = (var.availability_domain_name != "" ? var.availability_domain_name : ( length(data.oci_identity_availability_domains.ads.availability_domains) == 1 ? data.oci_identity_availability_domains.ads.availability_domains[0].name : data.oci_identity_availability_domains.ads.availability_domains[count.index + 1].name))
...
I don't even understand the logic of seeking the name of the count.index+1 availability domain . say you want to create 3 vms and your region has 2 Availability domain . count.index+1 = 1 then >> 2 then >>3
The 2nd and 3rd one will always fail because there is only 2 Availability domain hence index list [0,1].
Anyway I can close the issue now I guess
I am running this drg-ha-use-case terraform configuration a region that has only one Availability domain (ca-toronto-1) and the data sourcing of the availability domain is failing the whole execution plan in terraform .
see error below
This makes me think this tf stack was not tested in a Region with unique availability domain. Could you please help with a fix that doesn't imply hardcoding “availability_domain”?
count.index will always be equal 0 on single AD regions .
thank you