Using resource discovery in Resource Manager, re-create existing infrastructure from an existing compartment.
For more information about resource discovery, see Resource Discovery.
The following high-level instructions show how to re-create infrastructure from an existing compartment. To access detailed steps, select the provided links.
-
Create a stack from the compartment that contains the resources you want to re-create.
-
Download the generated Terraform configuration file.
-
Edit the
vars.tf
file (variables in the downloaded Terraform configuration file) to specify the destination compartment_ocid
and region
.
Example:
variable "compartment_ocid" {
default = "ocid1.compartment.oc1..uniqueid"
}
variable "region" {
default = "us-phoenix-1"
}
-
If the destination region has more or fewer availability domains than the source region, then edit the
vars.tf
file to specify the correct number of availability domains.
For example, if you cloned from a region that has 3 availability domains and you want to re-create the infrastructure in a region that has only 1 availability domain, then remove the references to the second and third availability domains.
Example showing 3 availability domains:
data oci_identity_availability_domain export_NzDH-EU-FRANKFURT-1-AD-1 {
compartment_id = var.compartment_ocid
ad_number = "1"
}
data oci_identity_availability_domain export_NzDH-EU-FRANKFURT-1-AD-2 {
compartment_id = var.compartment_ocid
ad_number = "2"
}
data oci_identity_availability_domain export_NzDH-EU-FRANKFURT-1-AD-3 {
compartment_id = var.compartment_ocid
ad_number = "3"
}
Example showing 1 availability domain:
data oci_identity_availability_domain export_NzDH-EU-FRANKFURT-1-AD-1 {
compartment_id = var.compartment_ocid
ad_number = "1"
}
-
Store the edited configuration file in the location that you want to reference when creating the second stack.
-
Create a second stack using the edited configuration file.
- (Optional)
Run a plan job on the new stack.
-
Run an apply job on the new stack.
The resources are cloned in the specified compartment and region.