Resource Discovery

Discover already deployed Oracle Cloud Infrastructure resources using Resource Manager.

You can use Oracle Cloud Infrastructure (OCI) Resource Manager to search for deployed resources in your compartment and export them to Terraform configuration and state files.

Resource discovery simplifies the move from manually managed infrastructure to Terraform-managed infrastructure. With a single command, you can generate a file that captures your existing compartment's baseline configuration and state.

Important

Resource discovery is not a migration tool. When cloning or migrating resources, configurations generated by resource discovery are a starting point. They may require changes.

Common uses cases for your new Terraform configuration and state files include:

  • Learn how Terraform uses HashiCorp Configuration Language (HCL) syntax to represent Oracle Cloud Infrastructure resources.
  • Duplication or rebuild of your existing infrastructure architecture in a new tenancy or region.
  • Detection of state drift. Run reports to see if the state of your Terraform-managed resources has changed and differs from your base configuration.

A stack created from a compartment represents all supported resources in the entire compartment, at the appropriate scope. If you select the root compartment for your tenancy, then the scope is the tenancy level, such as users and groups. If you select a non-root compartment, then the scope is compartment level, such as compute instances.

Stack creation is supported from a single compartment only. Stacks can't be created from nested compartments.

Output File Contents

Note

Attributes are missing from some supported resources captured using resource discovery. For more information, see Missing attributes in some discovered resources.

Resource discovery discovers resources that are in an active or usable state. Resources that have been terminated or otherwise made inactive are generally excluded from the generated configuration.

By default, the Terraform names of the discovered resources share the same name as the display name for that resource, if one exists.

The attributes of the resources are populated with the values that are returned by the OCI services.

In some cases, a required or optional attribute may not be discoverable from the OCI services and may be omitted from the generated Terraform configuration. This omission may be expected behavior from the service, which may prevent discovery of certain sensitive attributes or secrets. In such cases, a placeholder value will be set along with a comment like this:

example-attribute = "<placeholder for missing required attribute>" #Required attribute not found in discovery, placeholder value set to avoid plan failure

The missing required attributes are also added to lifecycle ignore_changes. This addition is done to avoid Terraform plan failure when moving manually-managed infrastructure to Terraform-managed infrastructure. Any changes made to such fields are not reflected in the Terraform plan. If you want to update these fields, remove them from ignore_changes.

Resources that are dependent on availability domains will be generated under availability_domain.tf file. These include:

  • oci_core_boot_volume
  • oci_file_storage_file_system
  • oci_file_storage_mount_target
  • oci_file_storage_snapshot

Supported Resources

Each supported service has one or more discoverable resources.

Was this article helpful?