Back to Terraform

OCI Discovery Deep Dive: Exported Configuration Is Not a Migration

November 6, 2026 Wasil Zafar 22 min read

Verify the current supported-resource list and authentication paths through a controlled provider-specific rehearsal

Table of Contents

  1. Separate Discovery Support from Provider Runtime Support
  2. Scope the Compartment and Existing State Owners
  3. Review Generated IDs, Dependencies and Sensitive Values
  4. Import a Bounded Set and Reach a No-Change Baseline
  5. Accept Adoption with a Recovery and Exclusion Record

Separate Discovery Support from Provider Runtime Support

Discovery answers a narrower question than the provider does. Resource discovery enumerates a compartment and writes HCL plus a state file. The provider's job is to plan, import and apply a declared object. A type can appear on one list and be missing from the other.

Two discovery surfaces exist, and they do not share a build. Resource Manager's stack-from-compartment runs the service-side exporter. The provider CLI export runs the exporter shipped with the provider binary. Check the supported list for the surface you will actually use.

The supported list is per service and per resource. A service can be supported while one of its resources is not, and the list belongs to a specific build. The provider CLI can print both lists with list_export_services and list_export_resources, which is the only honest comparison with what you run.

Authentication is not one path either. The provider CLI export supports API key and instance principal. A Resource Manager job is authorized through IAM for the caller and for every resource the job reads. Neither path grants the write access that the later apply needs.

Runtime support is a schema plus a pinned build. Terraform 1.17.1 with oracle/oci 9.12.1 can manage types that discovery never emits, and it can reject HCL generated for an older schema. Pin both before you judge an export.

The adoptable set is an intersection. On the export list, readable by the discovery principal, and manageable by the pinned provider. Everything outside it is either absent and must be recorded, or present and must not be owned.

The export is a snapshot, and the runtime build moves. Discovery reads at one moment with one build; your provider is upgraded on a different schedule. An object that was manageable at export time can gain a required argument or a new computed field before your import runs. The import plan, not the export, is the compatibility test.

Scope changes the answer at the root. A non-root compartment export stays at compartment level. The root compartment raises scope to the tenancy, where identity objects appear and need a different reviewer.

Separate Discovery Support from Provider Runtime Support
%%{init: {'theme':'base','themeCSS':'.edgeLabel .label text, .edgeLabel text, .edgeLabel span { fill:#132440 !important; color:#132440 !important; }','themeVariables': {'primaryColor':'#16476A','primaryTextColor':'#ffffff','primaryBorderColor':'#132440','secondaryColor':'#3B9797','secondaryTextColor':'#ffffff','secondaryBorderColor':'#132440','tertiaryColor':'#c4873b','tertiaryTextColor':'#132440','tertiaryBorderColor':'#132440','lineColor':'#5a6e82','textColor':'#132440','titleColor':'#132440','mainBkg':'#16476A','nodeBorder':'#132440','clusterBkg':'#eef3f7','clusterBorder':'#132440','edgeLabelBackground':'#ffffff','actorBkg':'#16476A','actorTextColor':'#ffffff','actorBorder':'#132440','activationBkgColor':'#3B9797','activationBorderColor':'#132440','signalColor':'#5a6e82','signalTextColor':'#132440','noteBkgColor':'#c4873b','noteTextColor':'#132440','noteBorderColor':'#132440','labelBoxBkgColor':'#a8dede','labelBoxBorderColor':'#132440','labelTextColor':'#132440','loopTextColor':'#132440','altBackground':'#f8f9fa','fontFamily':'DM Sans, sans-serif'}}}%%
flowchart TD
    A["Compartment snapshot"] --> B{"Which discovery surface?"}
    B -->|"Resource Manager stack"| C["Service-side exporter"]
    B -->|"provider CLI export"| D["Provider binary exporter"]
    C --> E["Generated HCL and state"]
    D --> E
    E --> F{"Type on that build's
export list?"} F -->|"no"| F1["Absent: record the omission"] F -->|"yes"| G{"Readable by the
discovery principal?"} G -->|"no"| G1["Absent or job failure
record the cause"] G -->|"yes"| H["Object present in state"] H --> I{"Pinned provider
can manage it?"} I -->|"no"| I1["Stop: upgrade or leave external"] I -->|"yes"| J["Eligible for adoption review"] F1 --> K["Exclusion record"] G1 --> K I1 --> K J --> L["Bounded import plan"] classDef primary fill:#132440,color:#ffffff,stroke:#0b172b; classDef secondary fill:#16476A,color:#ffffff,stroke:#0f314a; classDef ok fill:#3B9797,color:#ffffff,stroke:#2a6f6f; classDef danger fill:#BF092F,color:#ffffff,stroke:#7a0420; classDef warn fill:#c4873b,color:#132440,stroke:#8a5a1f; class A,E,L primary; class B,F,G,I secondary; class C,D,H,J ok; class F1,G1,I1 danger; class K warn;

Figure 1 orders the gates. A failure at the first one is not a provider problem, and installing a newer provider will not fix it.

Discovery support, generated artifacts and runtime support as three gates Three columns. A navy discovery column holds the Resource Manager exporter or the provider CLI exporter, a supported services list, one compartment and the caller's read grants. A blue artifacts column holds generated HCL with literals and placeholders, and a generated state with every discovered object. A teal runtime column holds Terraform 1.17.1 and oracle/oci 9.12.1. A crimson band says an omission from the export list cannot be recovered by a newer provider, and a teal band says only the intersection is adoptable. One compartment, three gates Discovery support, readability and runtime support are separate contracts. 1 · DISCOVERY BUILD Resource Manager exporter or the provider CLI exporter supported services list one compartment, not children caller identity and read grants Each surface ships its own build. Check the list you will run. 2 · GENERATED ARTIFACTS HCL literals, placeholders, ignore rules State every discovered object, one snapshot Both are generated from the same read. 3 · RUNTIME BUILD Terraform 1.17.1 oracle/oci 9.12.1 pinned plan, import, apply schema validators Runtime support is wider. It cannot recover an omission. Missing from the export list is absent from the state, whatever provider you install. Adopt only the intersection: exported, readable, manageable.

The table separates the two contracts that people merge in conversation.

QuestionDiscovery exportProvider runtime
Readerservice or CLI exporter, one compartmentprovider refresh, one declared object
Supported setper-service export list for that buildprovider schema and resource docs
Version anchorexporter build and target syntaxTerraform 1.17.1 and oracle/oci 9.12.1
AuthenticationAPI key or instance principal; IAM for a jobAPI key, security token, instance or resource principal
OutputHCL and a generated state fileplan, apply and refreshed state
Provesthe object exists and is readablethe object can be imported and changed
Typical failureomission or a failed jobschema error, not found, conflict

Scope the Compartment and Existing State Owners

The compartment is the discovery boundary, not the ownership boundary. A stack created from a compartment covers its supported resources at that scope. Child compartments are not walked, so a parent export is not an inventory of everything beneath it.

Every candidate OCID needs a negative check against every existing state. An import block does not consult other state files. Importing an object that another root already records succeeds and creates a second declarer; the duplicate stays invisible until one apply reverses the other.

Shared infrastructure is the first exclusion class. A VCN, subnet, route table, NSG, DRG, vault key, policy or compartment usually outlives one workload. Adopting it hands the workload root the power to change or delete a boundary other teams depend on.

Identity and guardrails are the second. A root-compartment export can contain users, groups, policies and dynamic groups. A workload root that owns them can rewrite its own access, which is a larger change than the workload it was meant to manage.

Data-bearing resources are the third. A volume, file system, database or bucket can be imported safely, but a later replacement destroys data. Adopt only with a restore rehearsal and prevent_destroy, or keep it external.

An owner outside Terraform still owns the object. A console-created bucket or a script-maintained policy has an owner even when no state records it. The ledger must name that person or team and get a decision, because importing the object transfers the ability to change it without asking.

Generated state claims more than the HCL you keep. The state records every discovered object, so deleting unwanted blocks does not shrink the claim. If the stack is retained, its state still declares the whole compartment.

Write the ledger before the import. One row per OCID: final address, type, compartment, current owner, decision, reason and reviewer. An object without a row is not approved, and an owner who cannot be found is a stop rather than a free object.

Scope the Compartment and Existing State Owners
%%{init: {'theme':'base','themeCSS':'.edgeLabel .label text, .edgeLabel text, .edgeLabel span { fill:#132440 !important; color:#132440 !important; }','themeVariables': {'primaryColor':'#16476A','primaryTextColor':'#ffffff','primaryBorderColor':'#132440','secondaryColor':'#3B9797','secondaryTextColor':'#ffffff','secondaryBorderColor':'#132440','tertiaryColor':'#c4873b','tertiaryTextColor':'#132440','tertiaryBorderColor':'#132440','lineColor':'#5a6e82','textColor':'#132440','titleColor':'#132440','mainBkg':'#16476A','nodeBorder':'#132440','clusterBkg':'#eef3f7','clusterBorder':'#132440','edgeLabelBackground':'#ffffff','actorBkg':'#16476A','actorTextColor':'#ffffff','actorBorder':'#132440','activationBkgColor':'#3B9797','activationBorderColor':'#132440','signalColor':'#5a6e82','signalTextColor':'#132440','noteBkgColor':'#c4873b','noteTextColor':'#132440','noteBorderColor':'#132440','labelBoxBkgColor':'#a8dede','labelBoxBorderColor':'#132440','labelTextColor':'#132440','loopTextColor':'#132440','altBackground':'#f8f9fa','fontFamily':'DM Sans, sans-serif'}}}%%
flowchart TD
    A["One compartment export"] --> B{"Child compartments
in scope?"} B -->|"yes"| B1["Parent export is incomplete
one pass per child"] --> C B -->|"no"| C["Candidate OCIDs
from the export"] C --> D{"OCID in any
existing state?"} D -->|"yes"| D1["Exclude: already owned"] --> L D -->|"not checked"| D2["Query every root first"] --> D D -->|"no"| E{"Shared boundary?
VCN, subnet, key, policy"} E -->|"yes"| E1["Exclude: reference by
data source or variable"] --> L E -->|"no"| F{"Identity or guardrail?"} F -->|"yes"| F1["Exclude: separate
identity root"] --> L F -->|"no"| G{"Data-bearing?"} G -->|"yes"| G1["Adopt only with restore
proof and prevent_destroy"] --> H G -->|"no"| H["Bounded candidate set"] H --> I{"Owner signs the ledger?"} I -->|"no"| I1["Stop: no adoption"] --> L I -->|"yes"| J["Freeze addresses
and exclusions"] L["Exclusion record
reason and owner"] --> J classDef primary fill:#132440,color:#ffffff,stroke:#0b172b; classDef secondary fill:#16476A,color:#ffffff,stroke:#0f314a; classDef ok fill:#3B9797,color:#ffffff,stroke:#2a6f6f; classDef danger fill:#BF092F,color:#ffffff,stroke:#7a0420; classDef warn fill:#c4873b,color:#132440,stroke:#8a5a1f; class A,J primary; class B,C,D,E,F,G,I secondary; class H ok; class D1,E1,F1,I1 danger; class B1,D2,G1,L warn;

Figure 2 shows the exclusion branches. Each one ends in a written record rather than a verbal exception.

Review Generated IDs, Dependencies and Sensitive Values

Generated HCL is a transcript of API values, not a design. Names follow display names, identifiers are literals, blocks are inline, and relationships are written as OCID strings. The file is readable; it is not yet maintainable.

A literal OCID is not a reference. Terraform cannot order a graph or cascade a replacement through a string. If a subnet and its VCN are both adopted but linked by literals, a replace or destroy can run in the wrong order.

Open the availability-domain file too. Boot volumes, file systems, mount targets and snapshots are generated separately. A reviewer who reads only the main file approves a resource set that is not the one on disk.

Computed values belong to the service. OCIDs, timestamps, lifecycle states, etags, default route table and security list IDs, and system tags are read-only. Copying one from state into configuration produces a schema error or a permanent diff; leave it out.

Defaulted values are a decision inherited by accident. The API returns the effective value of an unset optional field, and the exporter writes it as a literal. Keeping it pins today's default; dropping it returns the choice to the service. Record which one you made.

A create-only argument needs a replacement review. Some values are accepted only at creation and read back afterwards, and the exporter writes the read-back value into configuration. If the provider marks that argument as create-only, a later edit proposes a replacement rather than an update. Check the replacement rule for every field you keep.

Placeholders are explicit debt. When a required attribute cannot be discovered, the export writes a placeholder and adds the field to ignore_changes so the first plan passes. That rule also hides every later change; replace the value or record the exclusion, then remove the rule.

Secrets are the part that cannot be exported. Passwords, private keys and tokens are masked or omitted, so the file may carry a placeholder instead. The state is plaintext JSON, and job-read permission exposes it; treat the download as a credential.

Rebuild dependencies rather than trusting them. Rewrite internal literals as references, keep external ones as variables or data sources, and add explicit ordering only where no reference exists. The next plan then shows a cascade before it runs.

Generated HCL, generated state and the reviewed configuration as three different artifacts Three panels. The blue generated HCL holds literal OCIDs, inline blocks, placeholder values, generated ignore_changes rules and omitted secrets. The amber generated state holds every discovered object, exporter-chosen addresses, the schema at scan time and plaintext attributes. The teal reviewed configuration holds references between owned objects, variables for external identifiers, no computed fields, named exclusions and prevent_destroy where data matters. A crimson band lists fields that must never be owned, and amber and teal bands separate a defaulted value from a computed one. Three artifacts, one ownership decision The export describes the API. Your configuration has to describe the decision. GENERATED HCL literal OCIDs, no references inline blocks and display names placeholder values generated ignore_changes secrets omitted or masked Readable, not maintainable. Every literal is a boundary. GENERATED STATE every discovered object exporter-chosen addresses schema at scan time plaintext attributes no ownership review The claim is the expensive part. Pruning HCL does not prune it. REVIEWED CONFIG references between owned objects variables for external IDs no computed fields named exclusions prevent_destroy where data matters One owner per address. Every rule is a decision. Never own: id, time_created, lifecycle_state, etag, default route table, default security list, system tags. These are read-only or service-defined. A copied value becomes a permanent diff. Defaulted is not computed A literal pins today's default. Dropping it returns the choice to OCI. Record the decision either way The next reviewer should not have to infer it from a diff.

Figure 3 separates what the export contains from what your configuration may own. The gap between the two panels is the review.

Import a Bounded Set and Reach a No-Change Baseline

The import unit is one reviewed address, not a compartment. Ten to twenty objects, one owner, no data-bearing resource whose replacement loses state, and a reviewer who can read the whole plan. A larger set produces a plan nobody reads and a rollback nobody can run.

Write the final address before the block. The module path and resource name decide the address, and changing either later is a state move. Put the OCID in the import block only after that address is frozen.

The first plan has two jobs. It must prove the import and prove no mutation. Terraform can import an object and then apply an update in the same run when the configuration differs, so read the plan for an update or replacement on the same address.

A create for an object you expected to import is a stop signal. The address, region or provider build is wrong. Importing at the wrong address does not fail; it records the right object under the wrong name, and a later apply can create a duplicate.

Apply the reviewed plan, then remove the import block. The import writes state and changes nothing on the OCI side. The next plan, after the block is gone, is the baseline; it should be empty except for named exclusions.

Prove the duplicate claim outside Terraform. For each adopted OCID, check every other root and the API inventory. The count for that resource family should equal the union of all roots' addresses plus the recorded external set.

A duplicate import succeeds, which is why the check cannot be a Terraform command. Terraform has no registry of other state files, so a second root can import the same OCID and both plans will look valid. Run the negative test in a throwaway root: import one adopted OCID, observe the success, then remove it. The guard has to be the ledger and the sweep, not the tool.

The baseline is bounded by the addresses you adopted. Objects left in the compartment stay unmanaged and will not appear in the plan at all. That is the intended result, not an omission: the exclusion record is the only place they are visible, and a later discovery run is how you check that the set has not drifted.

Freeze the evidence with coordinates. Plan job identifier, commit, state serial, provider version, Terraform version and object count. A clean plan without those coordinates is a screenshot, not an adoption record.

Generated export, bounded import and no-change baseline with three failure paths Three panels. The blue generated export holds every discovered object at exporter-chosen addresses with no reviewer. The amber bounded import holds eight to twelve final addresses, import blocks and one owner. The teal baseline holds an empty plan, named exclusions and frozen evidence. A crimson band lists three stop signals: an update on the imported address is a real API change, a create for an expected object means a wrong address or region, and a replacement after import means an immutable field disagreement. A footer says import writes state while the update beside it does not. One plan, three possible verdicts Only an import with no mutation on the same address reaches the baseline. GENERATED EXPORT every discovered object exporter-chosen addresses no capacity bound no owner sign-off A description, not a decision. Keep it as evidence. BOUNDED IMPORT eight to twelve addresses import block per OCID no update or replace one owner, one reviewer The only step that writes state. It changes nothing in OCI. BASELINE empty plan after block removal named exclusions only one state per OCID frozen evidence set A baseline, not a migration. Re-plan after any edit. Stop signals in the first plan Update on the imported address: the import is real, but the update is a separate API change. Create for an expected object: wrong address, wrong region or a different provider build. Replace after import: the configuration and the live object disagree about an immutable field. Import writes state. The update beside it does not. Read both before applying.

Figure 4 shows the three outcomes of the first plan. Only one of them is an import, and only that one is safe to apply.

Accept Adoption with a Recovery and Exclusion Record

Acceptance is a signed record, not an empty plan. The empty plan proves configuration matches reality at one moment. The record names the owner of each address, the objects left external, and the way back.

Recovery is asymmetric. A bad import is reversible by removing the address from state, because no API call changed the object. A bad apply is not; it may have changed or destroyed the object, and recovery is a restore or a recreate.

The recovery record is written before the first apply, not after the failure. It names the state address, the exact object, the last known backup or snapshot, and the identity that can restore it. Without that, removing an address from state is advice rather than a procedure.

The exclusion record stops the next discovery from reopening the same argument. Each external object gets a reason, an owner and the reference the configuration uses. Unsupported, shared, identity, data-bearing and already-owned cover the usual cases.

Do not call the result a migration. Discovery does not move a resource, change a region, rewrite an application endpoint or copy data. It produces a description; adoption is a state decision; migration is a separate project with a cutover.

The record has a review date. Exports age as objects change and the provider moves. Re-run discovery to compare with the record, not to overwrite the adopted root.

Lab

Accept Adoption with a Recovery and Exclusion Record

Status: design-only. This trace was written against Terraform 1.17.1 and oracle/oci 9.12.1 on 6 November 2026. No tenancy was queried and no resource was imported, so every expected result below is documented behaviour rather than a measurement.

Prerequisites. One sandbox compartment with a VCN, two subnets, one instance and one bucket, a Resource Manager stack created from that compartment, a separate read principal for discovery and a write principal for adoption, and an empty new root with a remote backend. Keep every identifier as a placeholder.

  1. Freeze the sandbox, record the inventory, and pin Terraform 1.17.1 with oracle/oci 9.12.1 in the new root.
  2. Create the discovery stack, download the HCL and state, checksum both, and record the job identifier.
  3. Match the address count to the inventory. Write one line for every omission, including the child compartment you deliberately left out.
  4. Select eight to twelve objects. Exclude one shared subnet and one identity policy on purpose, and write both reasons in the ledger.
  5. Write canonical configuration at the final addresses. Replace internal literals with references, external IDs with variables, and list every ignore_changes you keep.
  6. Add import blocks and plan. Expect an import with no update or replacement on those addresses; a create means the address or region is wrong.
  7. Apply the reviewed plan job, remove the import blocks, and plan again. Expect an empty baseline apart from the named exclusions.
  8. Sweep every other root for the adopted OCIDs. Each OCID must appear once, and the API count must equal the union of all roots plus the exclusions.
  9. Destroy through the new root, confirm the plan is empty, release any public IP, delete the test stack, and keep the evidence set.
CheckPassing resultFailing result means
Export countevery expected object has a rowunsupported, unreadable, inactive or nested
Address freezeone final address per OCIDtwo roots can claim the object
Import planimport only, no update or replaceconfiguration disagrees with reality
Baseline planempty except named exclusionsownership or dependency gap
Duplicate sweepone state record per OCIDa second declarer exists

Expected observation. Step 3 produces a short classified list rather than a wall of creates. Step 6 imports without changing the objects, and step 7 leaves only the exclusions. Step 8 returns one record for every adopted OCID, and step 9 removes the sandbox without touching a shared boundary.

Failure check. If step 6 shows an update on the same address, stop: applying it would change the live object and the import would no longer be state-only. If step 7 proposes a create, the state and configuration use different addresses. If step 8 finds the same OCID twice, one root must give it up before either applies.

Cost and cleanup. The lab bills for the instance, the bucket and any reserved public IP until step 9. Destroy through the root, confirm the plan is empty, then delete the discovery stack and its generated state copy. Deleting a stack does not delete resources, so destroy first.

Evidence to keep. The export checksum, the omission list, the ledger, the import plan, the baseline plan, the duplicate sweep and the destroy confirmation. Sanitize OCIDs, IP addresses and any secret before sharing.

Sources. Discovery scope, placeholders and the availability-domain file follow Oracle's Resource Discovery guide. Export flags and the supported-resource lists follow the oracle/oci resource discovery guide.