The short answer: 404 NotAuthorizedOrNotFound does not tell you which of two things happened. Oracle's API error reference defines it as "A resource specified via the URI (path or query parameters) of the request was not found, or you do not have authorization to access that resource". The same code for an OCID that does not exist and for a resource that exists but your group cannot see. In practice that is three causes: the OCID, the compartment or the region is wrong; there is no policy covering your group in that compartment (or it is attached to the wrong compartment); or the CLI profile points at another tenancy or another region. Three read-only commands separate them, and it pays to start with the last one: the profile check.
What follows is what I do when this error lands in a terraform apply or in an oci ... get that worked yesterday. I read the Oracle pages cited at the end today; whatever is not in them, I label as what it is: my reading.
What the error looks like
In the CLI it is a JSON with "code": "NotAuthorizedOrNotFound", "status": 404 and the message Authorization failed or requested resource not found. In Terraform, the troubleshooting guide for the OCI provider shows it in this shape:
Error: 404-NotAuthorizedOrNotFound
Provider version: <provider_version>, released on <release_date>. This provider is <n> updates behind to current.
Service: <service>
Error Message: Authorization failed or requested resource not found.
OPC request ID: exampleuniqueID
Suggestion: Either the resource has been deleted or service <service> need policy to access this resource. Policy reference: <link>
The provider's suggestion already anticipates both readings: the resource was deleted, or a policy is missing. The same API error page adds two neighbours worth recognising: 400 RelatedResourceNotAuthorizedOrNotFound when the missing resource comes in the request body (the subnet of a launch, for instance) rather than the URI, and 409 NotAuthorizedOrResourceAlreadyExists on create operations, where it replaces the general 404. If the error you have is one of those two, the cause is the same family, but the resource to check is a different one.
Cause 1: the OCID, the compartment or the region
The dumbest and the most frequent. An OCID pasted one character short, the OCID of a compartment someone deleted, or a regional resource (instance, VCN, bucket) requested from another region. The last one is misleading because the CLI answers with the same 404 as if you had no permission: the instance exists, but in sa-saopaulo-1, and your profile is in us-ashburn-1. The first command rules it out:
oci iam compartment get --compartment-id ocid1.compartment.oc1..aaaaaaaaxxxx
# expected: a JSON with "name", "lifecycle-state": "ACTIVE" and "compartment-id" (the parent)
# if "lifecycle-state" is "DELETED", the OCID belonged to a deleted compartment
# if it returns 404, the OCID is wrong or your group cannot even inspect that compartment
Compartments are IAM resources: they live in the home region and are available in every region, so this get does not depend on the profile's region. That is why it works as the first filter: if the compartment resolves and the resource inside it still returns 404, the problem is in the resource (wrong region) or in the policy, not in the compartment. The command reference notes that it does not list what is inside; for that you call the list operation of each resource type with the compartment as a parameter.
Cause 2: no policy covers your group in that compartment
On OCI there is no access without an Allow. The basic syntax, per Oracle's policies page, is Allow group <group_name> to <verb> <resource-type> in compartment <compartment_name>, and statements only allow: there is no Deny, whatever is not written is denied. A group with no statement naming it in that compartment gets a 404, not a 403. The second command lists the statements you need to read:
# in the tenancy (root compartment) and in every compartment on the path down to the resource
oci iam policy list --compartment-id ocid1.tenancy.oc1..aaaaaaaayyyy --all \
--query 'data[].{name:name, statements:statements}' --output json
oci iam policy list --compartment-id ocid1.compartment.oc1..aaaaaaaaxxxx --all \
--query 'data[].statements[]' --output json
# expected: at least one statement naming your group and that compartment (or an ancestor)
You have to run it more than once because of a design detail: the same reference says that to determine which policies apply to a group or a compartment you must view the individual statements inside all your policies, because there is no API call that answers it directly. And inheritance goes downwards: Oracle writes that compartments inherit any policies from their parent compartment, with the example Allow group NetworkAdmins to manage virtual-network-family in compartment CompartmentA, which reaches CompartmentA, CompartmentB and CompartmentC when B is inside A and C inside B.
The most common trap I see is the sibling one. The policy says Allow group DevOps to manage instance-family in compartment Project-A and is attached to Project-A. The instance launches in Project-A, but the subnet lives in Networks, which is a sibling of Project-A, not a child. Inheritance does not cross sideways: DevOps can manage instances in Project-A and cannot even see the subnet in Networks, and the launch returns the 404 (or the related-resource 400) on the subnet. Oracle shows the right shape in its own example, with a third statement for the network: Allow group A-Admins to use virtual-network-family in compartment Networks. One attachment detail: the page says that when the policy is attached higher in the hierarchy than the compartment it names, the statement has to carry the path with colons, CompartmentA:CompartmentB:CompartmentC.
Cause 3: the wrong profile, tenancy or region
The third cause shows up when more than one ~/.oci/config is in play: two tenancies, a DEFAULT profile still pointing at the personal account, an OCI_CLI_PROFILE exported in another terminal, or a region in the profile that is not where the resource is. All of that yields the same 404, because from the wrong tenancy the OCID simply does not exist. The two commands of the third step tell you who you are talking to:
oci os ns get
# expected: {"data": "<namespace>"}; the namespace is unique per tenancy, if it is not the one you expected, the profile points at another account
oci iam region-subscription list --query 'data[].{region:"region-name", home:"is-home-region"}' --output table
# expected: the list of subscribed regions, exactly one with home = true;
# if your profile's region (or --region) is not in the list, the resource cannot be there
The os ns get reference says each tenancy is assigned one unique, uneditable namespace and that the command returns the one for the user making the request: it is the cheapest "am I in the right tenancy" check there is. The region-subscription one lists the subscribed regions of that tenancy. And this is where the home region comes in: Oracle's regions page says users, groups, policies and compartments are created and updated only in the home region, that the policies from the home region are enforced in the other regions, and that a change might take several minutes to become available in all of them. If you created the policy a moment ago and the 404 persists, it may be that, and not another mistake.
Order matters
Profile first (step 3), because if you are in the wrong tenancy the other two commands lie as well. Then the compartment (step 1), because it does not depend on the region. Policies last (step 2), the only step where you have to read rather than compare. In a terraform apply, the OPC request ID in the error is the thing to keep: it is what Oracle support asks for to find the request on their side.
FAQ
Why does OCI not distinguish between "not found" and "not authorized"? The error page does not explain the reason; what it documents is the behaviour, the same code for both cases and the same recommendation: check that the resource exists and that you have access to it. The practical effect is that a caller without permission cannot learn whether an OCID exists, and that is what I tell the team when they ask.
Does a deleted resource also return 404? Yes. The Terraform provider's suggestion puts it first: "Either the resource has been deleted or service need policy to access this resource". A data source pointing at an OCID someone deleted from the console returns exactly this error at plan time.
Is it enough to put the group in the tenancy? A statement in tenancy covers every compartment through inheritance, and that is what the Administrators policy that ships with the account does. It is useful to confirm the problem was the policy; it is not the policy you want to keep.
Where Control Cloud fits, and where it does not
Control Cloud reads the tenancy through the OCI API with a read-only credential, and the pre-flight before a deploy uses that same credential: it verifies that the API answers, that the extended inventory has loaded and that no region returned an error when read; if one did, it flags a warning with the region name and suggests reviewing the credential's permissions on that scope. Then it looks at the network (subnet, internet egress), the template's dependencies and the hosts. It also has an error dictionary that recognises NotAuthorizedOrNotFound and returns the why, the fix and the command oci iam policy list --compartment-id <comp> --all to verify it. What it does not do today: it does not evaluate which policy covers which group in which compartment, it does not check quotas, and it does not run as a CI hook or expose a public API. If you want to see your tenancy on a map, you can request access; the Team plan has a 7-day trial with no card.
The last time this 404 landed on you: was it a badly pasted OCID, a policy attached to the wrong compartment, or a profile looking at another region? And if it was the policy, which compartment was it in, and which one did the resource live in?
Sources
- Oracle, "API Errors" (https://docs.oracle.com/en-us/iaas/Content/API/References/apierrors.htm): definition of
404 NotAuthorizedOrNotFound,400 RelatedResourceNotAuthorizedOrNotFound,409 NotAuthorizedOrResourceAlreadyExistsand the troubleshooting recommendation. Read 2026-11-25. - Oracle, "How Policies Work" (https://docs.oracle.com/en-us/iaas/Content/Identity/Concepts/policies.htm):
Allow group ... in compartment ...syntax, Allow only, inheritance into child compartments, attachment to a single compartment, colon path, the Project-A and Networks example. Read 2026-11-25. - Oracle, "Managing Regions" (https://docs.oracle.com/en-us/iaas/Content/Identity/regions/managingregions.htm): the home region, which IAM resources change only there, home-region policies enforced in the other regions, propagation of several minutes. Read 2026-11-25.
- Oracle, "Troubleshooting" for the OCI Terraform provider (https://docs.oracle.com/en-us/iaas/Content/dev/terraform/troubleshooting.htm): shape of the
404-NotAuthorizedOrNotFounderror and its suggestion. Read 2026-11-25. - OCI CLI reference:
oci iam compartment get(https://docs.oracle.com/en-us/iaas/tools/oci-cli/latest/oci_cli_docs/cmdref/iam/compartment/get.html),oci iam policy list(https://docs.oracle.com/en-us/iaas/tools/oci-cli/latest/oci_cli_docs/cmdref/iam/policy/list.html),oci os ns get(https://docs.oracle.com/en-us/iaas/tools/oci-cli/latest/oci_cli_docs/cmdref/os/ns/get.html) andoci iam region-subscription list(https://docs.oracle.com/en-us/iaas/tools/oci-cli/latest/oci_cli_docs/cmdref/iam/region-subscription/list.html). Read 2026-11-25.
Top comments (9)
The sibling-compartment trap is the part I'd keep — a policy attached to Project-A covering the instance but not the subnet in Networks is exactly the kind of split that looks fine in the console until apply fails. I also liked the ordering advice: checking the profile and tenancy first, since the other two commands lie if you're in the wrong tenancy. Do you find the OPC request ID actually speeds up a support case, or is it mostly useful for your own tracing?
Honest answer: mostly my own tracing. I haven't opened enough Oracle support cases to claim it shortens them. What I can say is that their API error reference tells you to retry and, if the request still fails, contact support with the opc-request-id of the failed request, so putting it in the first message at least saves the round trip where they ask for it.
Where it pays off day to day is the Audit log: every event carries that id under
data.request.id, so from the error in an apply I can jump to the exact audit event (user, compartment, path) instead of guessing which of the last twenty runs produced it. That is also how I confirm it really was a sibling-compartment miss and not a typo in the OCID.Thanks for the honest answer — the Audit log jump is the part that sells it for me. Going from the error in an apply straight to the exact event with user, compartment and path, instead of guessing across the last twenty runs, is a real day-to-day win. And using it to confirm a sibling-compartment miss versus a typo in the OCID is a neat check — do you capture the opc-request-id into your run notes as a habit, or only pull it out when a 404 lands?
Only when something fails. I do not log it as a habit: the OCI provider prints it inside the error ("OPC request ID: ...") and the Audit log keeps every request under data.request.id anyway, so I can always get back to it from the failed apply output. What I do keep is the apply log itself, in the CI run; the id gets copied from there. For a 404 it is the first thing I paste into the Audit log search before touching any policy, because the event shows which compartment and identity the call really hit.
That's a practical split — log the apply output in CI and let the OPC request ID stay where it already lives, in the error and the Audit log, rather than copying it everywhere by habit. Pasting it into the Audit log search first for a 404 makes sense too, since the event tells you the compartment and identity before you touch any policy. Do you keep the apply logs long enough that the ID is still retrievable when a failure surfaces days later, or is the Audit log the real backstop by then?
The Audit log is the backstop, and it is the longer of the two. In our CI the run logs live 90 days by default (GitHub's retention for workflow logs; a private repo can raise it to 400) and that is where the apply output sits. OCI Audit keeps every request for 365 days, tenancy-wide and not adjustable, so when a failure surfaces weeks later I go there first and search by resource id and time window, not by request id: oci audit event list --compartment-id with --start-time and --end-time, filtered on data.resource-id. The request id only matters inside those 90 days, while the apply log is still around to hand it to me. Past 365 days there is nothing on either side unless a Connector Hub connector has been copying Audit to Object Storage.
That's a clean division of labour — CI logs for the recent, fast look, and the Audit log as the backstop that keeps every request for a full year. The 90-day versus 365-day split makes the choice obvious once you lay it out. Do you find the
oci audit event listquery by resource id and time window is usually enough on its own, or do you still need to cross-check the compartment's policy history to explain a 404?Usually the window plus
--queryis enough:oci audit event listonly filters by--compartment-id,--start-timeand--end-time, so the resource goes in--query "data[?data.resourceId=='ocid1...']". There is no policy history to cross-check: IAM policies do not keep revisions. When the 404 smells like policy I run a second query in the compartment where the policy lives, filteringeventNameforUpdatePolicy/DeletePolicy; those events carrydata.stateChange.previousand.current, so the statements before and after are right there. Two queries, same window, and the 404 explains itself.The UpdatePolicy / DeletePolicy second query is the part I hadn't thought of — data.stateChange.previous and .current turning 'no policy history' into a before-and-after you can actually read is a neat workaround. Two queries, same window, and the 404 explains itself is a good rule of thumb. When the 404 turns out to be a deleted resource instead of a policy change, does the same window-plus-query approach still give you a clean answer, or does that one need a different trail?