Choose Block, File or Managed Database Persistence
Three products, three different promises about your data. A block volume is a disk your operating system formats, a file system is a POSIX tree that several hosts can mount, and a managed database is a service that keeps its own redo and backups. Terraform can create all three; only one of them will help you after a bad migration.
Block Volume gives you a device and nothing else. oci_core_volume fixes an availability domain, a size from 50 GB upward and a VPU level, and each attachment binds it to one instance. The guest owns the filesystem, the mount table and the application's write consistency, so the recovery unit is a volume backup in regional Object Storage.
File Storage gives you a namespace, not a disk. A file system is created in one availability domain, reached through an AD-scoped mount target in a subnet, and exported at a path with client options. Snapshots are the recovery unit, and replication ships snapshot deltas to a file system in a second domain.
A managed database is the only one that writes its own recovery log. A DB system, an Autonomous Database or a MySQL DB system owns redo, automated backups and point-in-time recovery; the recovery unit is a new database built from a backup. Terraform creates the container and the first database, and never holds a row.
The flow below asks the two questions that separate them, then hands off to the recovery contract.
%%{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','tertiaryColor':'#c4873b','tertiaryTextColor':'#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','signalColor':'#5a6e82','noteBkgColor':'#c4873b','noteTextColor':'#132440','fontFamily':'DM Sans, sans-serif'}}}%%
flowchart TD
A["Name the five operations
the workload runs"] --> B{"Do several hosts
share one POSIX tree?"}
B -- "yes" --> C["File system
mount target plus export"]
B -- "no" --> D{"Constraints, joins or
point-in-time queries?"}
D -- "yes" --> E["Managed database
DB system, Autonomous or MySQL"]
D -- "no" --> F["Block volume
one host, one device"]
C --> G{"What is the
recovery unit?"}
E --> G
F --> G
G --> H["Write RPO, RTO,
retention and owner"]
H --> I["Restore once before
the first production write"]
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,B,D,G primary;
class C,E,F secondary;
class H ok;
class I warn;
The layers differ by who can rebuild them. The figure separates what an apply can recreate from what only a restore can produce, and marks where a restore has to land.
Recovery is a contract with four numbers and one name. State the recovery point, the recovery time, the retention that supports them, and the person who approves cutover. The product choice follows from those numbers rather than from the engine a team already knows.
| Decision | Block volume | File system | Managed database |
|---|---|---|---|
| Unit Terraform creates | volume plus attachment | file system, mount target, export | DB system or autonomous database |
| Recovery unit | volume backup in Object Storage | snapshot, or replica of the file system | service backup plus redo for a timestamp |
| Where a copy can land | any availability domain in the region | the domain that holds the target file system | a new DB system in the same region |
| Who owns the layout | guest filesystem and application | NFS client and directory tree | engine, schema and migration runner |
| Edit that cannot be undone | losing the last backup or its key | compliance-locked snapshot past cool-off | database edition and enabled TDE |
| Evidence you need | mount a restored volume and checksum it | mount a clone of a snapshot | query a restored database at a timestamp |
Only a few decisions survive contact with data. Changing a volume's availability domain, turning a file system into a replicated pair, or changing a database edition are migrations, not edits. Bring the table to the design review, not to the incident call.
Verify Volume Attachment, Network and Database Prerequisites
Availability domain first, shape second. oci_identity_availability_domains lists what the region actually offers, and every later choice filters through it. A volume must share a domain with its instance, a mount target and a DB system are created in one domain, and only Autonomous Database is regional.
The attachment is a control-plane record, not a mount. A paravirtualized attachment appears as a device; an iSCSI attachment still needs the connect and login commands on the host, with CHAP credentials when they are enabled. A clean apply proves the record exists, not that anything is mounted or consistent.
A mount target needs addresses before bandwidth. It consumes at least three private IPs in its subnet, so a /30 cannot host one, and clients need 2049 open from their NSG to the mount target's NSG. That is a path no route table can repair after the fact.
Every export is a second permission layer. The path is what the client mounts; the export options decide which source addresses may mount it, with what access and which identity squash. Left unspecified, an IPv4 export defaults to every address, read-write, which only the VCN rules then narrow.
A DB system takes a subnet and an NSG, not a listener you tune. oci_database_db_system places the system in the subnet you name, attaches NSGs when you pass them, and builds its listener behind the hostname and domain. It receives a private address there and no public listener, so reaching it from outside the VCN is a separate decision with its own review.
Autonomous Database swaps the host for an endpoint label. It takes the same subnet and NSGs, plus a private endpoint label that becomes the name clients connect to. There is no DB system host to patch, and that label ends up inside every connection string you hand out.
Edition and shape are gated by the domain, not the region. oci_database_db_system_shapes reports what the chosen AD offers, and the edition you select is fixed for the life of the DB system. A shape that exists in the region but not in that AD fails at create, after the network work is already done.
This article targets Terraform 1.17.1 and oracle/oci 9.12.1. In that provider the volume's backup_policy_id is deprecated in favour of a separate assignment resource, so a policy change is its own object with its own lifecycle rather than an attribute edit.
The flow below runs a separate lane per service, ending at the failure branch each one produces.
%%{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','tertiaryColor':'#c4873b','tertiaryTextColor':'#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','signalColor':'#5a6e82','noteBkgColor':'#c4873b','noteTextColor':'#132440','fontFamily':'DM Sans, sans-serif'}}}%%
flowchart TD
A["List availability domains
and the shapes they offer"] --> S{"Which service
is being added?"}
S -- "block volume" --> B{"Volume and instance
in the same AD?"}
S -- "file system" --> E{"Mount target subnet has
three free private IPs?"}
S -- "database" --> G{"Shape and edition offered
in the chosen AD?"}
B -- "no" --> B1["Attachment cannot cross
create the pair together"]
B -- "yes" --> C{"Paravirtualized
or iSCSI?"}
C -- "iSCSI" --> C1["Host runs connect and login
the apply wrote only a record"]
C -- "paravirtualized" --> D["Device appears
mount and fsck on the host"]
E -- "no" --> E1["Pick a larger subnet
a /30 cannot host one"]
E -- "yes" --> F{"Export admits this client
and 2049 is open?"}
F -- "no" --> F1["Mount hangs
no route repairs a rule"]
F -- "yes" --> H["Export path reachable
from the client"]
G -- "no" --> G1["Change AD or shape
before the network work"]
G -- "yes" --> I["Private endpoint, NSG,
listener reachable"]
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,S,B,C,E,F,G primary;
class H,I,D secondary;
class B1,C1,E1,F1,G1 danger;
The branches fail at different layers. A domain mismatch is a configuration error, a missing host login is a runtime error, a subnet with no free address is a capacity error, and an export miss looks like a hung mount. Naming the layer correctly is most of the repair.
Keep Schema and Data Migrations with Their Own Release Owner
Terraform creates a database, not a schema. The DB home block supplies a database name, a character set and an admin password, and then the engine is empty. Tables, indexes, grants and views come from a migration runner that records what it ran in a ledger inside the database.
Three identities should exist, with three lifetimes. The pipeline creates infrastructure, the migration job holds DDL authority, and the application holds reads plus the writes it performs. The DB system resource gives you one admin password and no finer grant, so schema users are created by SQL, not by a resource.
Order the release as infrastructure, then schema, then code. Terraform places the database before the application but cannot insert your migration between them, because the migration is not a node in its graph. Expand, backfill, switch reads, contract — one release each, each compatible with the one before it.
A major version change is a new home, not an attribute edit. The DB home carries the version, so an engine upgrade passes through a new home or a new DB system built on a tested restore point. Patches inside a version are a maintenance window, and they can still change optimizer behaviour.
Moving data between domains is a migration project. Promoting a volume replica, switching a file system replication to its target, or failing over a Data Guard association each carry a freeze window and a named owner. None of them is a Terraform plan you run on a Friday.
The rollback window closes at the read switch. Before that point a code rollback is free because the old shape is still written; after it the old code reads something no longer authoritative. Write the boundary, and the timestamp, into the release record.
Review Admin Secrets and Encryption Dependencies
The admin password is create-time state, not a rotation control. The DB system's admin password is not an update path, so changing it in the block replaces the DB system rather than rotating the credential. Autonomous Database marks the same argument updatable, which is a different contract behind a similar name.
Sensitive redacts output, not storage. A value marked sensitive disappears from the plan summary and still lands in state and in a saved plan file. A secret bundle fetched by a data source is copied into state at read time, so the boundary that matters is the backend and who can read it.
Vault is a dependency with its own lifecycle. A volume, a backup, a file system and a database wallet can all reference one key. Scheduling that key for deletion breaks every copy that still needs it, and the key lives in a state file that is not the one holding the data.
A restored volume does not inherit your key choice. Restores land on an Oracle-managed key unless a key is named at restore time, and a volume group restore cannot name one at all, so re-keying is a second step. An old backup also stays bound to the key it was taken under until the backup itself is re-keyed.
TDE and edition are one-way doors. Enabling transparent data encryption cannot be undone, and the edition chosen at create cannot change later. Both belong in the release record as facts about the database, not as settings someone can revisit.
Retention features are deliberately hard to reverse. A volume backup can carry a retention lock, a prevent-deletion flag or an indefinite hold. A file system snapshot policy can go further: a compliance-mode lock makes the snapshot immutable after its cool-off period, while governance mode leaves an exit.
The figure follows one key deletion through the three restore paths it breaks.
The panels differ by one scheduled action. On the left the key exists and every copy is a candidate; on the right the copies are unchanged and every restore fails. The window between the two is the only place where a drill would have caught this.
Prove Restore for One Selected Stateful Service
A backup you have not restored is a hypothesis. The policy states what the service kept; the drill states whether your team can turn a copy into a reachable, correct object with the right key, export and endpoint. Pick one service and prove that one, instead of asserting three.
The cheapest useful drill is a volume restored into a second availability domain. It tests three claims at once: the backup is regional, the restore creates a new object, and the key choice is explicit. Once that trace passes, the file system and database variants are the same shape with different nouns.
Prove Restore for One Selected Stateful Service
Execution status: design-only. This trace was written against Terraform 1.17.1 and oracle/oci 9.12.1 on 6 November 2026. It was not run against a live tenancy, so every expected result is documented behaviour rather than a measurement, and every identifier is a placeholder you supply.
Prerequisites. A disposable compartment, two availability domains in one region, an instance in each domain, a Vault key you are willing to destroy, and a state bucket you can delete. One 50 GB volume, which is the service minimum, holding one file whose checksum you record.
The change under test. One manual full backup of the volume, restored into the second domain, attached, mounted read-only and compared by checksum. Then one retention lock on a second scratch backup, and one attempted delete.
- Baseline the stack. Apply the root, confirm a second plan is empty, and record the domain, size, VPU level, attachment type and backup policy in one line of the release record.
- Write one known fact. Create a file with a fixed string, sync the filesystem, and record the checksum. A volume with no distinguishable content proves nothing after a restore.
- Take a manual full backup. Manual backups do not expire, unlike policy backups, so the drill copy survives the retention you are about to test.
- Restore into the other domain. The backup is regional even though the volume is not. Expect a new volume rather than a reattached one, and keep the source untouched.
- Attach and mount read-only. Run the connect and login commands on the second instance when the attachment is iSCSI, mount, and compare the checksum before anything writes.
- Restore again without naming a key. Confirm the copy lands on an Oracle-managed key, then restore once more with the Vault key named explicitly. That is the difference between a default and a decision.
- Lock one scratch backup. Enable a retention lock on the disposable copy, attempt to delete it, and record the refusal. This is the irreversible step, so it belongs only on the scratch object.
- Time it and clean up. Measure from the restore request to the first passing checksum, record the duration, destroy the scratch root, and keep the record rather than the credentials.
| Observation | Passing result | Failing result means |
|---|---|---|
| Restored volume location | second availability domain, source untouched | the restore was treated as an in-place move |
| Checksum after mount | identical to the recorded value | the backup predates the write or caught live I/O |
| Restore with no key named | Oracle-managed key on the new volume | a key was hard-coded into the restore path |
| Retention lock on the copy | delete refused for the lock period | the flag was set on the volume, not the backup |
| Database variant | the copy answers a query at the timestamp | the timestamp fell outside the recovery window |
Variants. For File Storage, replace steps 3 to 5 with a snapshot of the file system, a file system cloned from that snapshot, and a new mount target in the second domain. For a DB system, restore to a new DB system at a timestamp inside the recovery window and check one row instead of a checksum.
Cost and evidence. The second instance, the volume and its backups bill for the hours the drill lasts, and retained copies bill past the included allowance. Destroy the scratch stack the same day and keep the timing, the key name, the policy retention and the provider version.
Next in the Series
In OKE and Container Registry: Cluster, Node and Workload Ownership, we'll explore Stage Oracle Kubernetes infrastructure and distinguish principal models before in-cluster changes.