More Info:
Enforce the CIS landing zone architecture by requiring custom compartments. Resources should never be deployed directly into the root tenancy compartment to ensure strict administrative boundary isolationRisk Level
HighAddress
Compliance, SecurityCompliance Standards
- APRA CPS 234 (Australia)
- BSI C5 (Germany)
- Brazil LGPD
- CCPA / CPRA (California)
- CIS Critical Security Controls v8
- CMMC 2.0
- CSA Cloud Controls Matrix v4
- Cloudanix Best Practice
- DPDPA
- Digital Operational Resilience Act (EU)
- Essential 8
- ISO/IEC 27017
- ISO/IEC 27018
- ISO/IEC 27701
- KSA PDPL
- MAS Technology Risk Management (Singapore)
- MITRE ATT&CK (Cloud)
- NIS2 Directive
- NIST SP 800-171
- NYDFS 23 NYCRR 500
- SWIFT Customer Security Controls Framework
- Sarbanes-Oxley IT General Controls
- UK NCSC Cyber Assessment Framework
Triage and Remediation
- Remediation
Remediation
Using Console
Using Console
To meet the “OCI Governance Should Have Custom Compartments Created” requirement using the OCI Console, you just need to create at least one non-root compartment (and typically more, aligned to your governance model). Here are the steps:
1. Sign in and choose the right tenancy/root compartment
- Sign in to the OCI Console.
- In the top-left, open the hamburger menu.
- Make sure you are in the correct tenancy and region (top-right of the console).
- In the Compartment selector (usually above the main pane), confirm you are viewing the root compartment (the tenancy name).
2. Navigate to Compartments
- Open the hamburger menu.
- Go to Identity & Security → Compartments.
3. Create a custom compartment
- On the Compartments page, click Create Compartment.
- Fill in:
- Name: e.g.,
prod,nonprod,network,logging, etc. - Description: brief description of its purpose.
- Parent Compartment:
- Usually the root compartment for top-level governance compartments, or
- Another compartment if building a hierarchy (e.g.,
prod > prod-network).
- Name: e.g.,
- (Optional but recommended) Add Tags if your governance model uses tag-based organization.
- Click Create Compartment.
4. Attach or verify IAM policies for the new compartments
To make the compartments actually usable under your governance model:- Go to Identity & Security → Policies.
- Create or edit policies in the root compartment (or appropriate parent) that:
- Grant groups access to use/manage resources in the new compartments.
- Example policy (pseudo):
- Click Create or Save changes.
5. (If applicable) Move resources into the new compartments
If you already have resources in the root compartment that should be governed:- Navigate to the resource type (e.g., Compute → Instances, Networking → VCNs).
- For each resource, open its Details page.
- Click Move resource (or equivalent).
- Choose the appropriate target compartment and confirm.
6. Confirm remediation for Governance Monitoring
- Go back to your Governance/Compliance/Cloud Guard or Monitoring page where the finding was raised.
- Wait for the next evaluation cycle (or trigger a rescan if supported).
- Verify the finding “OCI Governance Should Have Custom Compartments Created” is Resolved/Closed.
Using CLI
Using CLI
To satisfy “OCI Governance Should Have Custom Compartments Created” using the OCI CLI, you need to create at least one compartment under the root tenancy (not use only the root compartment).Below are the minimal step-by-step CLI instructions.
Follow prompts (tenancy OCID, user OCID, region, etc.).
Look for the compartment with
You can also see it in the web console under: Profile icon → Tenancy OCID.Assume:
This returns JSON including the new compartment
Ensure your new compartment is listed and lifecycle-state is
That’s all that’s required from the CLI side to remediate this specific control.
1. Ensure OCI CLI is configured
If not already done:2. Get your tenancy OCID (root compartment ID)
If you don’t know your tenancy OCID, you can fetch it via:"name": "tenancy" (or your tenancy name). Its "id" is the root compartment OCID.You can also see it in the web console under: Profile icon → Tenancy OCID.Assume:
3. Create a custom compartment
Useoci iam compartment create with the root compartment as the parent:"id" and "lifecycle-state": "CREATING" or "ACTIVE".4. (Optional) Verify the compartment exists and is ACTIVE
ACTIVE.5. Wait for governance monitoring to re-evaluate
OCI governance/posture tools (Cloud Guard / Security Zones / Governance Monitoring) usually re-check on a schedule. After the compartment is created and ACTIVE, the “Custom Compartments Created” requirement should pass on the next evaluation cycle.If you need more than one custom compartment (e.g., by environment), repeat step 3 with different names:Using Python
Using Python
Below is a concise, stepwise way to remediate the finding “OCI Governance Should Have Custom Compartments Created” using Python and the OCI SDK.
1. Prerequisites
-
Install OCI Python SDK:
-
Configure your OCI CLI profile (used by the SDK):
This creates
~/.oci/config. Note your:tenancyuserfingerprintkey_fileregionprofilename (e.g.,DEFAULT)
-
Have appropriate IAM permissions on the tenancy root to create compartments:
inspect compartments in tenancyuse tenancymanage compartments in tenancy(or equivalent policy)
2. Decide the Compartment Structure
Define the custom compartments you want for governance/monitoring. Common patterns:security-governance-rootsecurity-monitoringcompliance-logsaudit-archive
3. Python Script to Ensure Custom Compartments Exist
This script will:- Connect using your OCI config profile.
- Look up the tenancy OCID.
- Check if the target compartments already exist.
- Create any that are missing under the correct parent.
4. Connect These Compartments to Governance Monitoring
After creating the custom compartments:-
Update your Governance/Monitoring policies so that the monitoring service (or your monitoring user/group/dynamic group) can:
- Read from monitored compartments.
- Write logs/metrics into the new governance compartments (e.g.,
security-monitoring,compliance-logs).
-
In your governance/monitoring code or Terraform/Resource Manager stacks, reference the new compartment OCIDs (printed by the script) when:
- Creating log groups.
- Creating alarms.
- Creating notifications channels.
5. Automate Execution
Integrate the script into your CI/CD or governance bootstrap process so it:- Runs on initial tenancy onboarding.
- Optionally verifies the compartments remain present and active.
Using Terraform
Using Terraform
terraform plan that remediates the finding should show:- A new
oci_identity_compartment.APP_COMPARTMENTto be created. - For each governed resource currently in the root tenancy, an update where
compartment_idchanges from the root tenancy OCID to the new compartment’s OCID (or, for some resources, a destroy-and-recreate reflecting the move).

