Skip to main content

OCI Foundations & Security : OCI Policies — How to Control Who Can Do What

Calculating read time…

Imagine your school has a big library with thousands of books, computers, and a printer room. 📚

Not everyone is allowed everywhere! Students can only borrow books. Teachers can also use the printer room. Only the librarian can add or remove books from the shelves.

That's exactly how OCI Policies work! They are the rules that decide who can do what inside your Oracle Cloud account.

01. What is an OCI Policy?

A Policy is a simple written rule that tells Oracle Cloud: "This person (or group) is allowed to do THIS with THAT resource."

Every OCI Allow policy statement follows this basic pattern:

Allow  <subject>  to  <verb>  <resource-type>  in  <location>  where <condition>

The where clause is optional. Let's break the main parts down: 🎯

  • subject → The principal receiving access. Common subjects include a group (people), a dynamic-group (matching OCI resources), any-group, any-user, or a supported service principal. The exact supported subject syntax depends on the tenancy's IAM configuration.
  • verb → The access level, such as inspect, read, use, or manage.
  • resource-type → The kind of resource the policy covers, such as instances, buckets, or a resource family.
  • location → The target scope, usually in tenancy or in compartment Dev.
  • condition → An optional additional test, introduced with where, such as a network-source or bucket-name condition.

💡 Think of it like: A school permission slip! "Alice is allowed to borrow books from the Science section in Room 3." Same structure — who, what, which thing, where! 📝

The statement names a group or another supported principal—not a direct user subject. For a human user, the usual pattern is to place that user in a group and grant the group the required access. OCI also supports a user-specific condition using the user's OCID when a narrowly targeted exception is necessary.

02. The 4 Verb Levels — How Much Power to Give?

The verb part of a policy describes the level of access. Oracle orders the four common Allow verbs from least to most access, but the exact permissions depend on the resource type:

VerbGeneral meaningTypical use
inspectUsually allows listing resources and viewing basic identifying information.Limited inventory or audit visibility.
readIncludes inspect and adds permission to retrieve the resource and user-provided metadata.Read-only access to resource details or content.
useIncludes read and adds actions on existing resources. The actions vary by resource type; it generally does not allow creating or deleting that resource type.Working with existing resources, such as using a network or starting/stopping supported resources.
manageIncludes all permissions for the resource type.Administrative access, including create and delete operations where supported.

💡 Think of it like library access cards:

  • inspect → You can see the book titles on the shelf (but may not be able to open them) 👀
  • read → You can open and read books (but cannot change the library's records) 📖
  • use → You can work with existing library resources in the ways allowed for that resource type 📚
  • manage → You're the librarian — you can perform all operations covered by that resource type 🔑

Important exception: These verbs are permission bundles, not universal descriptions of every API operation. For some resource types, inspect can expose more than a simple name—for example, network list operations can return security-list and route-table details, and listing IAM policies can reveal their statements. Some update operations require manage rather than use. Always check the verb/resource-type permission table for the exact service.

03. Where Do Policies Live? — Compartments Explained

Before we write policies, we need to understand Compartments. Think of your Oracle Cloud account like a big office building. 🏢

  • The whole building = your Tenancy (your entire OCI account)
  • Each floor or department = a Compartment (a logical container for your resources)
  • Rooms on each floor = your actual resources (servers, databases, etc.)

A policy statement can grant access in the tenancy or in a named compartment. A policy is also attached to one compartment (or the tenancy). These are related but different ideas: the statement's in location defines the resource scope, while the attachment location controls who can later modify or delete that policy.

Policy inheritance matters: Compartments inherit applicable policies from their parent compartments. Therefore, a policy granting access in the tenancy can also grant that access in child compartments. A policy for a parent compartment can apply to its descendants as well. A child compartment does not automatically receive access only from policies created directly inside it; you must consider applicable parent and tenancy policies too.

💡 Real example: You might have compartments called Production, Development, and Testing. Developers get full access to Development but only read access to Production — keeping live systems safe! ✅ The effective access still depends on every applicable policy, including inherited policies.

04. How a Policy Is Evaluated in Real Time 🕐

When someone tries to do something in OCI — like starting a server — the relevant OCI service checks whether the request has the required permissions. Here's the simplified flow:

  Developer requests "Start Instance" in OCI Console
             |
             ▼
  OCI identifies the requesting principal
  (user, group membership, dynamic group, or service principal)
             |
             ▼
  OCI checks the required permission for the operation
             |
             ▼
  OCI evaluates applicable policy statements, including
  policies inherited from parent compartments
             |
             ▼
  Are the required permissions granted and conditions met?
             |
       ┌─────┴─────┐
       ▼           ▼
   ALLOW applies?  No applicable Allow?
       |                |
       ▼                ▼
  Check applicable  ❌ DENIED
  Deny policies     (implicit deny)
       |
       ▼
  If an enabled Deny policy matches, access is denied.
  Otherwise, the authorized action can proceed.

Key things to know about how evaluation works:

  • OCI uses an implicit-deny model for protected resources — if no applicable Allow policy grants the required permission, access is denied. Some self-service actions, such as managing your own Console password and credentials, are available without a separate resource policy.
  • Allow permissions accumulate across applicable policies and group memberships. A permission granted by one applicable Allow policy is not removed just because another Allow policy is narrower.
  • OCI now also supports optional IAM Deny Policies. They are disabled by default and must be deliberately enabled. When enabled, a matching Deny policy takes precedence over an Allow policy.
  • For people, the usual approach is to grant permissions to groups and add users to those groups. Policies can also use dynamic groups, service principals, and other supported subjects.

🛡️ Important: OCI IAM Deny Policies

The statement "there is no Deny statement in OCI" is no longer correct. OCI introduced opt-in IAM Deny Policies on November 20, 2025. The feature is disabled by default; only members of the default administrator group in the default domain can enable it through the Console. Enabling it is a deliberate, permanent action. Once enabled, a matching Deny policy overrides an Allow policy. Deny verbs also need special care: denying manage does not necessarily block lower access levels, while denying inspect generally blocks higher access levels too. The default administrator group in the default domain is exempt from Deny policies to help prevent administrative lockout.

Do not enable this feature casually. Review Oracle's current Deny Policies documentation and its known issues before turning it on.

💡 Think of it like: A bouncer at a club. The bouncer checks your permission when you request entry. A matching Allow rule can admit you; if no applicable permission exists, entry is refused. In a tenancy where Deny Policies are enabled, a matching Deny rule can override an Allow rule. 🚪

How quickly do changes take effect? Oracle documents that policy creation, updates, and deletion typically take effect within 10 seconds in the home region. IAM changes are then replicated to other regions; cross-region propagation can take several minutes. Do not describe policy updates as instant everywhere or assume every region has received a change immediately.

05. Writing Your First OCI Policy — Step by Step

Let's write real policies together, starting from the simplest and building up! 👇

Example 1: Let a Group Read Object Storage

Scenario: Your team DataAnalysts needs to read files from storage buckets. Nothing else.

Allow group DataAnalysts to read buckets in compartment DataLake
Allow group DataAnalysts to read objects in compartment DataLake

What this does:

  • Line 1 → DataAnalysts can list the buckets and retrieve bucket information in the compartment
  • Line 2 → DataAnalysts can list objects and download existing objects
  • They cannot upload, delete, or create objects with these read-only statements! 🔒

Example 2: Let Developers Manage Compute in One Compartment

Scenario: Developers need to manage Compute instances in the Dev compartment and launch instances into its network. The following is a common starting pattern for instance, network, and existing-volume access:

Allow group Developers to manage instance-family in compartment Dev
Allow group Developers to use volume-family in compartment Dev
Allow group Developers to use virtual-network-family in compartment Dev

What this does:

  • Line 1 → Developers can manage Compute instance-family resources in Dev
  • Line 2 → Lets them use existing Block Volume resources, including volume attachments, when required for the launch workflow
  • Line 3 → Lets them use network resources needed to launch instances into the VCN and subnet
  • If the image is from the Marketplace, the group may also need read app-catalog-listing in tenancy. If networks or volumes are in other compartments, scope those statements to the compartments where those resources actually reside.

These statements grant access in Dev; they do not, by themselves, prove that Developers have no access to Production. Check for other applicable policies inherited from the tenancy or parent compartments.

Example 3: Admin Gets Full Tenancy Access

Scenario: Your cloud admin needs to manage everything everywhere.

Allow group Administrators to manage all-resources in tenancy

What this does:

  • One single line gives the Administrators group broad control over resources in the tenancy
  • all-resources = every resource type covered by the statement in that scope
  • in tenancy = across the tenancy, with access inherited into its compartments
  • ⚠️ Only give broad administrator access to people who genuinely need it! It's the master key 🗝️

06. How to Create a Policy in OCI Console — Step by Step

Let's actually create a policy in Oracle Cloud right now! Follow these steps: 👇

Step 1: Open the Policies Section

  • Log in at cloud.oracle.com
  • Click the ☰ menu (top left)
  • Go to: Identity & Security → Policies

Step 2: Click "Create Policy"

  • Click "Create Policy"
  • Give it a meaningful name like developer-access-policy
  • Add a description: Allows Developers group to manage resources in Dev compartment
  • Choose which compartment this policy will be attached to

Step 3: Write Your Policy Statements

  • Use the basic policy builder if one of its templates matches your requirement
  • Choose "Customize (Advanced)" to enter or edit policy statements in the free-form editor
  • Type your policy rules, one statement per line
  • Select "Create" to save the policy
  • ✅ Your policy is created!

Policy changes typically take effect within 10 seconds in the home region. Replication to other regions can take several minutes, so allow for that delay before treating a cross-region authorization failure as a policy-design problem.

07. How to Assign a Policy to a User — The Right Way

Here's something very important that confuses many beginners! In OCI, the usual approach is to grant permissions to a group rather than write a policy statement naming an individual user.

Instead, the standard flow for a human user is:

  User → Group → Policy
           |
        Step 1: Create a Group
           |
        Step 2: Add the User to the Group
           |
        Step 3: Write a Policy for the Group

  For OCI resources, use a Dynamic Group or another
  supported principal type when appropriate.

💡 Think of it like: A company badge system. You don't give each employee custom keys. Instead, you put them in a team (group) and give the whole team access to certain rooms (policy). Much easier to manage! 🏢

A direct subject such as Allow user john.doe@company.com ... is not the normal policy syntax. OCI does, however, document a way to target one user by using a supported subject with a condition on request.user.id. Use that only when an individual-user exception is genuinely required; group-based grants are easier to administer at scale.

Step-by-Step: Add a User to a Group

Step 1: Create a Group

  • Go to: Identity & Security → Groups
  • Click "Create Group"
  • Name it something clear like Developers or DataAnalysts
  • Click "Create"

Step 2: Add a User to the Group

  • Open your newly created group
  • Click "Add User to Group"
  • Search for the user by name or email
  • Click "Add"
  • ✅ The user is now part of the group and can receive the permissions granted to that group by applicable policies

Step 3: Write the Policy for That Group

  • Go to: Identity & Security → Policies
  • Create a new policy with rules referencing group Developers
  • Done! The group membership and policy together determine the user's permissions ✅

The new membership or policy change typically takes effect first in the home region, then propagates to other regions. Cross-region replication can take several minutes. 🚀

08. Managing Policies with OCI CLI

You can also create and manage policies from your terminal using the OCI CLI. This is much faster once you get comfortable with it!

List All Policies in a Compartment

📌 What the command below does: It prints a list of all the policies attached to your chosen compartment — their names, descriptions, and the actual rule statements inside them. Like asking "what are all the rules for this floor of our building?" 📋

# Replace YOUR_COMPARTMENT_ID with your compartment OCID
oci iam policy list \
  --compartment-id YOUR_COMPARTMENT_ID \
  --output table

Output:

+------------------------------+------------+----------------------------------------+
| name                         | state      | description                            |
+------------------------------+------------+----------------------------------------+
| developer-access-policy      | ACTIVE     | Developers access to Dev compartment   |
| readonly-analysts-policy     | ACTIVE     | DataAnalysts read access to DataLake   |
| admin-tenancy-policy         | ACTIVE     | Full admin access across tenancy       |
+------------------------------+------------+----------------------------------------+

All your policies listed clearly! 🎯

Create a New Policy via CLI

📌 What the command below does: It creates a brand new OCI policy from your terminal — no clicking in the console needed! You give it a name, description, compartment, and the actual rule statements. Like emailing a new rule to the building security team — it's enforced after the policy change propagates! 📨

oci iam policy create \
  --compartment-id YOUR_COMPARTMENT_ID \
  --name "developer-access-policy" \
  --description "Allows Developers group to manage compute in Dev compartment" \
  --statements '["Allow group Developers to manage instance-family in compartment Dev",
                 "Allow group Developers to use virtual-network-family in compartment Dev"]'

Output:

{
  "data": {
    "name"         : "developer-access-policy",
    "lifecycle-state" : "ACTIVE",
    "statements"   : [
      "Allow group Developers to manage instance-family in compartment Dev",
      "Allow group Developers to use virtual-network-family in compartment Dev"
    ]
  }
}

Policy is created! ✅ Developers can now manage instance-family resources in Dev and use the network resources allowed by the second statement. The example assumes the relevant network resources are also in Dev.

09. How to Protect Resources via Policies 🛡️

Policies aren't just about giving access — they're your primary tool for controlling access to resources too! Here are some important protection patterns used:

Pattern 1: Protect Production from Developers

Developers should not be able to touch Production servers unless they have been granted the required permissions. A least-privilege starting point is to grant them access only to the Development compartment:

# Developers get full access to the Development compartment only
Allow group Developers to manage all-resources in compartment Development

# No applicable Allow policy for Production = implicit deny,
# provided no tenancy-level or parent-compartment policy grants access.

A missing Production-specific Allow statement does not cancel a broader Allow statement inherited from the tenancy or a parent compartment. Review all applicable policies. If your tenancy has deliberately enabled IAM Deny Policies, a matching Deny statement can override an Allow grant.

💡 Think of it like: A hotel key card. Your card opens Room 305. It does not automatically open Room 405. But if your card also has a building-wide access permission, it may open more rooms than you expected. Always check the full set of permissions! 🗝️

Pattern 2: Read-Only Access for Auditors

Auditors need to see resources but must not change them. A broad starting pattern is to let them inspect resources, then add the more specific read permissions required for services whose list or audit operations require them:

# Auditors can inspect resources across the tenancy
Allow group Auditors to inspect all-resources in tenancy

# Oracle's examples use read for these additional operations
Allow group Auditors to read instances in tenancy
Allow group Auditors to read audit-events in tenancy

The exact read permissions depend on which services and data auditors need. Avoid giving read all-resources automatically when a narrower set of permissions will meet the audit requirement.

Pattern 3: Lock Down Sensitive Data with Conditions

OCI supports Conditions in policies — extra rules that must also be true. This is powerful for fine-grained access control!

# Only allow access if the request comes from a named network source
Allow group Developers to manage instances in compartment Dev
  where request.networkSource.name = 'office-network'

# Allow a group to read objects only in a specific bucket
Allow group DataAnalysts to read objects in compartment DataLake
  where target.bucket.name = 'approved-data-bucket'

How conditions work:

  • The where clause adds an extra check on top of the basic Allow
  • The main policy statement must grant the required permission and the condition must evaluate to true
  • If the condition fails (e.g. wrong network source or wrong bucket) → this statement does not grant access ❌

Pattern 4: Protect Critical Resources with Dynamic Groups

Sometimes you want your OCI resources (like an instance) to access other OCI resources (like a storage bucket). For supported OCI resource principals, you can use a Dynamic Group — a special group whose membership is determined by matching rules rather than manually adding people!

# Step 1: Create a Dynamic Group that matches your compute instances
# (In OCI Console → Identity → Dynamic Groups → Create)
# Matching Rule:
All {instance.compartment.id = 'ocid1.compartment.oc1..xxxxx'}

# Step 2: Write a policy allowing that Dynamic Group to access storage
Allow dynamic-group my-compute-instances to read objects in compartment DataLake

What this achieves:

  • Your matching OCI compute instances can read objects from storage — without storing user passwords or API signing keys in application code 🔐
  • The instance principal is authenticated using its OCI resource identity, and policy grants the required authorization
  • This is a common pattern for Compute instance-to-OCI-service access; use the principal type supported by the source service for other workloads

💡 Think of it like: A company car has a special badge on the windshield. When it enters the car park, the barrier recognizes the car and checks whether its identity has the required permission — no driver password needs to be stored in the car! 🚗

10. Real-World Policy Setup — A Complete Example 🏢

Let's put it all together! Here's a complete, realistic policy setup for a small company with 3 teams — exactly like you'd do it..

The company has 3 compartments: Production, Development, DataLake

# ── ADMINISTRATORS ──────────────────────────────────────────
# Full control over everything
Allow group Administrators to manage all-resources in tenancy


# ── DEVELOPERS ──────────────────────────────────────────────
# Full access to Development, read access to Production
Allow group Developers to manage all-resources in compartment Development
Allow group Developers to read all-resources in compartment Production


# ── DATA ANALYSTS ───────────────────────────────────────────
# Read-only access to the DataLake
Allow group DataAnalysts to read buckets in compartment DataLake
Allow group DataAnalysts to read objects in compartment DataLake


# ── AUDITORS ────────────────────────────────────────────────
# Inspect resources across the tenancy; read specific audit resources
Allow group Auditors to inspect all-resources in tenancy
Allow group Auditors to read instances in tenancy
Allow group Auditors to read audit-events in tenancy


# ── AI COMPUTE INSTANCES (Dynamic Group) ────────────────────
# Servers in Production can read AI models from a specific DataLake bucket
Allow dynamic-group production-servers to read objects in compartment DataLake
  where target.bucket.name = 'ai-models-bucket'

Each team has permissions selected for its role — with the intention of applying least-privilege access, the golden rule of cloud security! 🏆

Important: The example is a starting point, not a substitute for reviewing effective access. A tenancy- or parent-compartment Allow policy may grant additional permissions. Also, manage all-resources in a compartment can include the ability to manage policies attached to that compartment, so use that broad grant only when the team is trusted to administer access there.

11. Common Policy Mistakes to Avoid

Here are the mistakes beginners make all the time — and how to avoid them:

Mistake 1: Writing Policies for Users Instead of Groups

# ❌ Wrong — this direct-user subject form is not valid policy syntax
Allow user john.doe@company.com to manage instances in compartment Dev

# ✅ Standard group-based grant
Allow group Developers to manage instances in compartment Dev

For a user-specific exception, OCI documents a supported subject plus condition pattern, for example using any-group with request.user.id set to that user's OCID. This is different from writing user as the policy subject.

Mistake 2: Forgetting the Other Resources Needed When Creating Instances

# ❌ Incomplete for a typical instance-launch workflow
Allow group Developers to manage instances in compartment Dev

# ✅ Common launch pattern (adjust each compartment to where
# the instance, network, and volume resources actually reside)
Allow group Developers to manage instance-family in compartment Dev
Allow group Developers to use volume-family in compartment Dev
Allow group Developers to use virtual-network-family in compartment Dev

Launching an instance involves more than the instance resource itself. The group needs the appropriate permissions for the instance, network, and—when attaching existing block volumes—volume resources. If these resources are in different compartments, grant the required permissions in each relevant compartment. Marketplace images can require an additional read app-catalog-listing in tenancy statement. The exact policy depends on the launch workflow.

Mistake 3: Using "manage all-resources in tenancy" Too Freely

# ❌ Dangerous — giving full admin power to the wrong group!
Allow group Developers to manage all-resources in tenancy

# ✅ Safer — scope it to just the compartment they need
Allow group Developers to manage all-resources in compartment Development

Always follow the rule: give the minimum access needed to do the job. Nothing more! 🔒

12. Do's and Don'ts ✅❌

✅ DO — Good Policy Habits
  • Assign human-user access to Groups; use Dynamic Groups or other supported principal types for OCI resources
  • Use the least-privilege principle — give only the minimum access needed
  • Use compartments to separate environments (Dev, Staging, Production)
  • Use Dynamic Groups for supported resource-principal patterns instead of embedding API keys in application code
  • Add conditions (network sources, bucket names) for extra protection on sensitive resources
  • Give Auditors only the inspect and specific read permissions they actually need
  • Review inherited policies as well as policies attached directly to the target compartment
❌ DON'T — Avoid These Mistakes
  • Don't give manage all-resources in tenancy to any group except true administrators who need that broad access
  • Don't assume that a missing compartment-level Allow means no access; tenancy and parent-compartment policies can be inherited
  • Don't write a direct user subject in a policy statement; use the supported group/principal pattern
  • Don't put all resources in one compartment when separate compartments would improve isolation and administration
  • Don't store API keys in code for workloads that support safer OCI resource-principal authentication
  • Don't assume Deny Policies are available or enabled by default; they are an opt-in feature, and enabling them is permanent
💡 Important Things to Remember
  • Basic Allow policy format: Allow <subject> to <verb> <resource-type> in <location>
  • Common verbs, from least to most access: inspect < read < use < manage. Exact permissions vary by resource type.
  • No applicable Allow permission means access is implicitly denied for protected resources
  • IAM Allow policy changes typically take effect within 10 seconds in the home region; cross-region replication can take several minutes
  • Optional IAM Deny Policies can explicitly block access and override Allow policies when enabled
  • Dynamic Groups let supported OCI resources access other OCI resources securely using resource principals
  • Adding a user to a group gives the user the permissions granted to that group by applicable policies, after the change propagates

13. Additional References

The following Oracle documentation pages explain the IAM policy syntax, permission model, conditions, common examples, and current Deny Policy feature discussed in this post.

  1. IAM Policies Overview — Current policy statement structure and the meaning of its elements.
  2. Policy Syntax — Subjects, verbs, resource types, locations, and conditions in policy statements.
  3. How Policies Work — Policy inheritance, compartment scope, verb behavior, and resource-type combinations.
  4. Policy Reference — Detailed mappings between verbs, resource types, permissions, and API operations.
  5. Common Policies — Oracle examples for Object Storage access, Compute instance launch, auditors, and resource principals.
  6. Advanced Policy Features — Conditions, request variables, resource variables, and more granular policy rules.
  7. Deny Policies — Current opt-in IAM Deny Policy behavior, precedence, enablement, and safeguards.
  8. Managing Policies — Console steps, policy builder options, and policy-change propagation guidance.

14. Quick Summary 📝

What we learned :

  • Policy → A written rule: Allow <subject> to <verb> <resource-type> in <location>
  • Verbs → inspect (list/basic visibility) → read (retrieve) → use (work with existing resources) → manage (all permissions for that resource type). Exact permissions vary by resource type.
  • Implicit deny → No applicable Allow policy = access denied for protected resources
  • Deny Policies → Optional IAM feature, disabled by default; when enabled, a matching Deny policy overrides an Allow policy
  • Compartments → Logical containers to scope and isolate your resources; policies can be inherited from parent compartments
  • Groups → The usual way to grant permissions to human users; add users to groups and write policies for those groups
  • Conditions → Add where clauses for extra checks (network source, bucket name, and other supported variables)
  • Dynamic Groups → Let supported OCI resources access other resources without embedding user credentials
  • Least privilege → Always give the minimum access needed. Nothing more! 🔒
  • Policy propagation → Changes typically take effect within 10 seconds in the home region and can take several minutes to reach other regions

Happy cloud learning! ☁️✨

Comments