Open ashokk453 opened 2 years ago
not sure which script you are referring to, but the instance resource has a fault_domain attribute that controls in which FD the instance will be created.
The following gives you the list of Fault Domain in the first Availability Domain of a region (region would be controlled you your OCI provider config)
variable "env_ad" {
description = "The availability domain number for this environment"
default = 0
}
variable "env_fd" {
description = "The fault domain number for this environment"
default = 0
}
data "oci_identity_availability_domains" "ADs" {
compartment_id = var.tenancy_ocid
}
// get the fault domains for choosen AD
data "oci_identity_fault_domains" "FDs" {
compartment_id = var.tenancy_ocid
availability_domain = data.oci_identity_availability_domains.ADs.availability_domains[var.env_ad]["name"]
}
When creating your instance, you can set the availability_domain and fault_domain :
availability_domain = data.oci_identity_availability_domains.ADs.availability_domains[var.env_ad]["name"]
fault_domain = data.oci_identity_fault_domains.FDs.fault_domains[var.env_fd]["name"]
So, by changing the value for var.env_fd (eg via modulo on count attribute) you can distribute your instances over the fault domains.
If you also want to distribute over multiple ADs you probably need to rework to code to construct a map of FDs per AD via a locals construct.
Was looking at OCI compute instance creation example. How does the script ensures that each instance is deployed in different FD of AD. Lets say I select Ashburn which has 3 ADs and each AD has 3 FDs . I'm planning to deploy 9 instances, what changes we have to make under resource creation step to 9 instances are deployed in such a way that 3 in each AD and in turn within AD 1 in each FD
This Github template is intended for questions regarding the Terraform Oracle Cloud Infrastructure provider.
Before using this template, check whether your question is already answered in one of the following guides:
If you have a support request related to Oracle Cloud Infrastructure services, please contact Oracle support
If you have a support request or question related to core Terraform functionality, please submit them to one of these resources: