Define Who Creates, Reads and Rotates Each Value
Four objects sit behind one credential, and each has a different owner. The vault is the HSM container, the key is the master encryption key, the secret is a named container, and the secret version is the value. Merging them into one owner produces a policy that can list a secret but not read it, or delete a key that secrets depend on.
The vault is isolation and capacity, not authorization. vault_type is fixed at creation: a default vault shares an HSM partition, while a virtual private vault takes a dedicated one. Only the private type supports vault backup, key replication and automatic key rotation, so the type is a lifecycle decision before it is a performance one.
Vault type is fixed at creation
A default vault shares an HSM partition; a virtual private vault takes a dedicated one and is the only type that supports backup, key replication and automatic rotation. Choose from the recovery contract, because the type cannot be changed later.
The key is the cryptographic boundary. A key owns an algorithm, a protection mode and a list of versions. HSM protection keeps material inside a FIPS 140-2 Level 3 module; software protection keeps it on a server wrapped by an HSM root key, which is cheaper and exportable but a weaker guarantee. Neither mode can be changed after creation.
A secret is bound to one symmetric key in the same vault. Asymmetric keys cannot encrypt a secret, and the secret's versions are base64-encoded, encrypted by that key, and kept outside the HSM. Disabling the key leaves the secret listed and its versions visible while every read fails.
Rotation describes two different events. Key rotation adds a key version: new writes use it, old ciphertext still decrypts, and the key OCID does not change. Secret rotation adds a secret version and updates the target system, which is what an application notices.
Deletion is a schedule, not an action. A vault or key waits 7 to 30 days, while a secret waits 1 to 30 days. A key in Pending Deletion makes its secrets unreadable immediately, before the window ends. A prevent_destroy rule stops a plan in the same root, but only the service window stops a console delete.
Give each step a named owner. The security team creates the vault and key and writes the policy; the application team owns the secret name, schedule and target; the rotation function writes versions; the runtime reads bundles. When one root does all four, the pipeline holds create, rotate, read and delete.
%%{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','signalColor':'#5a6e82','noteBkgColor':'#c4873b','noteTextColor':'#132440','fontFamily':'DM Sans, sans-serif'}}}%%
flowchart TD
V["Vault
HSM partition, one region"] --> K["Key
algorithm and protection mode"]
K --> KV["Key version
new material, same key OCID"]
K -->|"encrypts versions"| S["Secret
name, key binding, schedule"]
S --> SV["Secret version
value plus stage labels"]
SO["Security team
vault and key owner"] --> V
SO -->|"writes policy"| P["IAM policy
verbs on resource types"]
P -.->|"governs access"| S
AO["Application team
secret owner"] --> S
RF["Rotation function
resource principal"] -->|"adds version"| SV
IP["Runtime instance
instance principal"] -->|"reads bundle"| SV
TF["Terraform root"] -.->|"writes value"| SV
TF -.-> X["State and plan copy
outlives rotation"]
W["Workload with a broad grant"] -.->|"can delete"| X2["Pending deletion
secrets go dark"]
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 V,K,S primary;
class KV,SV,P secondary;
class SO,AO,RF,IP ok;
class TF,W warn;
class X,X2 danger;
Figure 1 separates the container from the value. The vault and key are security-owned infrastructure, the secret is an application-owned container, and the version is what a reader touches. The dashed path is the one to remove: a Terraform root writing the value where rotation cannot reach it.
Figure 2 is an ownership chart, not a data flow. The arrows carry dependency, not permission. Inside Vault, the only place the value exists is the version, and the only principal that should touch it is the one that needs the credential at runtime.
| Object | What it owns | Who may create | Who may read or use | Failure when merged |
|---|---|---|---|---|
| Vault | HSM partition, region, endpoints | manage vaults | use vaults as the container permission | a vault admin can delete every key |
| Key | algorithm, protection mode, versions | manage keys plus use vaults | use keys for crypto, manage keys to rotate | key rotation is mistaken for secret rotation |
| Key version | cryptographic material for one key | manage keys by rotating the key | read keys for metadata only | deleting it removes decrypt for old data |
| Secret | name, key binding, schedule, versions | manage secrets plus use keys and use vaults | read secret-bundles for the value | a metadata reader is mistaken for a value reader |
| Secret version | one value and its stage labels | use secrets by updating content | read secret-bundles | the old value stays readable after rotation |
| IAM policy | who may use which verb, where | manage policies at the attachment | not applicable | a workload can grant itself delete |
The table is a delegation checklist, not a naming guide. An owner can be unable to read the secret; a reader can be unable to rotate it. Put the five columns into the access review.
Connect Principal Policies to Vault and Key Operations
OCI policies only allow. There is no deny statement that subtracts from a broader grant, so a workload with manage secret-family in the compartment can delete the secret no matter what a second statement says. The correction is to remove the broad grant, not to add a narrower one.
Every caller resolves to a principal first. A user is a group member; an instance is matched by a dynamic group rule; a function is matched as a resource principal. The policy names the group, and the compartment in the statement decides where the verb applies.
Membership is not authorization. A matching rule only makes the principal visible to IAM. The first read fails with 404 NotAuthorizedOrNotFound until a statement names the group and grants the verb in the right compartment. That error deliberately hides whether the secret exists, so it cannot distinguish a typo from a missing grant.
404 is not always not-found
OCI returns NotAuthorizedOrNotFound for a read the caller may not perform, hiding existence on purpose. Before hunting a missing secret, confirm the dynamic-group rule, the group name in the policy and the compartment scope.
Verbs are cumulative and resource-specific. A grant of read secret-bundles adds the bundle read and list, and nothing on the key. Reading a value needs that verb alone, because Vault decrypts on the service side.
The key verbs do two different jobs. use keys adds encrypt, decrypt, sign and verify; managing the key adds rotate, delete and import. A consumer that only reads bundles needs neither.
Creating a secret touches three resource types. The caller needs secret create, key encrypt and decrypt, and the vault's create-secret permission. Managing secrets supplies the first, using keys the second and using vaults the third; drop any one and the call fails before a value is stored.
Rotating content is cheaper than creating a secret. use secrets covers the content update and the rotate call without key encrypt. Deleting an old version also needs manage secret-versions, so a rotation function usually cannot clean up after itself.
key-delegate is for integrated services. Object Storage, Block Volume, OKE and Streaming use it to let the service call a key without giving the caller the key. It is not a shortcut for a workload that reads a secret, and it does not replace use keys for a caller doing its own crypto.
Scope the grant to the secret, not the compartment. A statement can add a target.secret.id condition, so one policy covers many workloads without letting each read the others' values. The condition is evaluated on the request, so an OCID copied from another compartment still fails.
Put the vault, key and secret under one policy attachment. IAM evaluates the verb at the resource's compartment, and three attachments mean three reviews. A dedicated secrets compartment keeps the reader grant narrow and the delete grant out of the application root.
Expect a delay after a rule change. A dynamic group rule update takes about an hour to propagate, so a new instance can fail immediately after the fix. Do not widen the policy to clear an error that time will clear.
The dangerous grants are the convenient ones. manage secret-family lets a workload create versions with arbitrary values, change the schedule and delete the secret. manage keys lets it rotate or schedule deletion of the key that protects every secret in the vault. Neither belongs in an application pipeline.
%%{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','signalColor':'#5a6e82','noteBkgColor':'#c4873b','noteTextColor':'#132440','fontFamily':'DM Sans, sans-serif'}}}%%
flowchart TD
C["Caller
user, instance or function"] --> M{"Dynamic group
rule matches?"}
M -->|"no"| D1["404 NotAuthorizedOrNotFound
principal unknown to policy"]
M -->|"yes"| OP{"Which operation?"}
OP -->|"read value"| RB{"read secret-bundles
on the secret?"}
OP -->|"create secret"| CR{"manage secrets, use keys
and use vaults?"}
OP -->|"rotate content"| RT{"use secrets
on the secret?"}
OP -->|"delete"| DL{"manage secrets
or manage keys?"}
RB -->|"no"| D2["Metadata may still read
bundle returns 404"]
RB -->|"yes"| OK["Bundle returned
GetSecretBundle in audit"]
CR -->|"no"| D3["CreateSecret denied
three resource types"]
CR -->|"yes"| OK2["Secret created
key encrypts the versions"]
RT -->|"no"| D4["UpdateSecret denied
no new version"]
RT -->|"yes"| OK3["New version
old becomes PREVIOUS"]
DL -->|"no"| D5["Delete denied
the safe default"]
DL -->|"yes"| OK4["Pending deletion
the cancel window starts"]
KD["use key-delegate
integrated services only"] -.->|"does not read a secret"| D2
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 C,M,OP,RB,CR,RT,DL primary;
class KD warn;
class OK,OK2,OK3 ok;
class D1,D2,D3,D4,D5 danger;
class OK4 secondary;
Figure 3 follows the operation, not the person. The same principal passes one check for a bundle read and a different check for a create. The red branches look like authentication failures but are missing verbs, a missing vault permission, or a condition that no longer matches.
Verify the Network Path and Selected Provider Secret Schema
A private subnet reaches Vault through a service gateway, not a private IP. Vault has no VNIC in your subnet, and none of its three APIs offers Private Service Access. The route sends the regional service CIDR to the gateway, the request still targets the public endpoint, and security rules must allow outbound 443.
A virtual private vault does not change the network path. The word private describes an HSM partition, not a subnet placement. Both vault types are reached through the same service gateway route, and neither appears in a subnet's address list.
Key operations use a per-vault endpoint; secret operations do not. oci_kms_key and oci_kms_key_version need the management endpoint the vault exports, while secret resources resolve the regional endpoint themselves. The vault exports two planes: management for create, update and delete; crypto for encrypt and decrypt.
The provider schema is the write-only test. Version 9.12.1 has no write-only or ephemeral argument for secret content, and exposes the bundle as a data source. Terraform 1.17.1 supports write-only values, but a provider must declare them, and the provider does not declare them here.
Content is base64 by contract. The secret content type is base64, and the API does not encode a plaintext string for you; the console does. A trailing newline or a shell-escaped character changes the encoded value, so the first read compares an exact canary.
A scheduled rotation needs a target that can act. The rotation configuration names Autonomous Database or a function, and the function performs four steps: verify, create pending, update target, promote. Enabling the schedule without a working target produces a timestamp and no new version.
Key rotation has a narrower home. Automatic key rotation exists only in a virtual private vault, with an interval of 60 to 365 days. A default vault needs a manual or pipeline-driven schedule.
Check the shape units before the first apply. AES lengths are bytes, so 32 means a 256-bit key; RSA and ECDSA lengths are also bytes, so 256 means 2048 bits. A length copied from a bit-based example is rejected at create.
Read the schema for the arguments that are not returned. Secret content is an input that is not exported, which makes it look write-only in the documentation. Terraform still stores configured arguments, so the absence of an attribute proves nothing about the state file.
Verify the value's path, not the resource's existence. A plan that creates a vault, key and secret can still leave the runtime unable to read: the route may be missing, the policy may name the wrong compartment, or the key may be disabled. Each check has a different owner.
Inspect Synthetic State, Plan and Log Exposure Privately
Terraform can hold the value in three places. The configuration holds it if it is written in HCL, a saved plan holds the variable values, and the state holds the argument after apply. A sensitive output redacts the terminal, not the file.
A plan file is a credential artifact. A saved plan contains the values needed to apply without re-reading variables, so a plan uploaded as a CI artifact is as sensitive as the state. Delete it after the run instead of archiving it.
State history is the part rotation forgets. A versioned bucket keeps the previous state object after the current one is overwritten. Rotating a secret in Vault does not change those copies, and deleting the current object leaves the old versions.
The bundle data source writes the value into the plan and the state. A lookup that feels read-only has created a second copy, and sensitive = true on an output only changes what the terminal prints. If Terraform must read a value, the read belongs in a short-lived workspace with its own backend.
Debug logs are value-handling logs. Provider debug output can include request and response bodies, and a crash log can include values held in memory. Turn debug logging off for any run that reads or writes a secret, and treat a captured debug run as an incident.
Search the artifacts for the canary, not for the word secret. A synthetic prefix proves which files hold the value; a search for the resource name proves nothing. Record the file, the object version and the date, then destroy it.
Historical copies change the rotation order. Rotate the value at the target first, then in Vault, then purge the copies. If you rotate Vault first, the old plan still describes the old value and the next apply can put it back.
Audit is metadata, state is content. OCI Audit records the bundle read, and KMS service logs record the crypto operation with the principal and key version. Neither is designed to store the plaintext; a canary test proves it.
Keep the inspection private. Read the state in a controlled session, print only the key, version and timestamp, and attach the redacted extract to the review. A ticket that quotes the value creates a copy that rotation cannot reach.
Figure 4 compares a value written by Terraform with a value written at runtime. The left path turns every artifact store into a credential store, and rotation cannot reach the copies. The right path leaves Terraform holding the OCID, so a state leak names a secret, not its value.
Prove Rotation and Post-Revocation Behavior
The lab produces evidence, not a green plan. It proves the reader can retrieve the value, rotation creates a version, key deletion can be cancelled, and audit names the principal. A synthetic canary keeps every artifact harmless.
Prove Rotation and Post-Revocation Behavior
Status: design-only. No Oracle Cloud tenancy, credential or billable resource was used, and none of these steps were executed. Every identifier is a placeholder you supply: the sandbox tenancy, the secrets compartment, the dynamic group, the target system and the review owner.
Prerequisites. Terraform 1.17.1 with oracle/oci 9.12.1, a sandbox tenancy, one default vault for the cheap path, one AES-256 key with HSM protection, one secret holding a canary, one dynamic group matching a test instance, a KMS crypto service log on the vault, and audit retention that covers the exercise. Automatic key rotation needs a virtual private vault, so test that separately.
| Check | Evidence to capture | Pass looks like |
|---|---|---|
| Reader | the canary from a bundle read | exact match, no key permission |
| Metadata only | the second principal's result | secret listed, bundle refused |
| Rotation | version numbers and stages | new CURRENT, old PREVIOUS |
| Schedule | last and next rotation fields | next time advanced with a new version |
| Key rotation | key version count and old ciphertext | new version, old decrypt works |
| Deletion | lifecycle state during the window | pending, then readable after cancel |
| Audit | event name and key version fields | bundle read and crypto call recorded |
| Artifact | canary location in state and plan | value found, then copies destroyed |
- Record an empty baseline plan. A non-empty baseline makes every later diff ambiguous.
- Create the vault, the AES key and the canary secret in one security-owned compartment. Record only OCID suffixes in the lab notes.
- Add a reader policy scoped to the secret OCID for the instance dynamic group. Wait for the dynamic group rule to propagate before testing.
- Read the bundle as the instance principal. Expect the canary exactly; a 404 means the group, the compartment or the bundle grant is wrong.
- Add a second principal with metadata read only. Expect the secret to list and the bundle to fail; that pair proves which verb the value needs.
- Inspect the state and confirm the canary is present. Record the file and object version, then delete the copy.
- Add a new secret version with a second canary. Confirm the new version is CURRENT and the first is PREVIOUS, then read both by version number.
- If the rotation function is configured, run one rotation and confirm all four steps: pending created, target updated, pending promoted. A leftover PENDING version is a failed or unfinished rotation.
- Read the rotation fields: last rotation time, next rotation time and status. A next timestamp without a new version is a schedule, not a rotation.
- Rotate the key manually. Confirm a new key version, an unchanged key OCID, and that ciphertext from the old version still decrypts.
- Schedule key deletion with the minimum 7-day window. Confirm a secret read fails immediately, cancel the deletion, and confirm the read returns after the key is enabled.
- Schedule secret deletion with the minimum 1-day window. Confirm the read fails, cancel, make the version current again, and confirm the read returns.
- Confirm the audit event for the bundle read and the service-log entry for that decrypt. Record whether either contains the canary; a hit means that log holds the value.
- Keep the lab root until the review is signed, then schedule deletion from the console or CLI. Confirm the vault and keys show pending deletion rather than disappearing.
Expected observation. The reader returns the exact canary, the metadata-only principal is refused a bundle, and the new version becomes CURRENT while the old one remains readable by number. The key keeps its OCID and old ciphertext still decrypts. Both deletion windows produce a pending state that can be cancelled, and the audit event names the bundle read.
Failure checks. A create that fails on the key is a missing key permission or a key in another vault. A bundle read that fails while metadata succeeds is a missing bundle grant. A schedule with an advancing next time and an unchanged version is a function that is not promoting. An unavailable key rotation on a default vault is the vault type, not the provider.
Recovery owner. Name the reviewer before the test. Cancel-deletion rights belong to a break-glass group, not the pipeline, and that same group confirms that the target credential was rotated rather than only the Vault value. Revoking a read grant does not invalidate a value a consumer already fetched; only rotating the credential at the target does.
Redaction rules. Keep the secret OCID suffix, the version number, the stage, the key version, the lifecycle state, the timestamps and the event name. Drop the value, the request body, the response body and anything copied from a plan or state file.
Evidence to keep. The empty baseline plan, the reader result, the refused bundle, the two version stages, the rotation timestamps, the key version before and after, the deletion state and the recovery result. They answer who could read, what changed, whether it could be undone, and who would be told.
The missing denial is a result, not a failed lab. A principal that unexpectedly reads a value proves the policy is wider than the review claimed, and that finding is cheaper before an incident than after. Write it next to the statement that granted it.
Revocation has two clocks. The Vault grant stops the next read, while the credential already cached by the application keeps working until the target rotates it. Evidence that shows only the first clock is a permission test, not a recovery test.
Next in the Series
In OCI Operations: Monitoring, Logging, Defined Tags and Budgets, we'll explore Tie resource changes to verified signals, tag permissions and accountable spending.