Skip to content

Error: 404-NotAuthorizedOrNotFound Oracle oci #1397

@IlyaShestopalovQB

Description

@IlyaShestopalovQB

Hello Community, I trying create my own oracle infrastructure using terraform provider oci.
For the beginning i want to create compartment for my infrastructure, and use it for sub compartments, instances, buckets and all another, but when I try use compartment id that was created and use it in some resources i have error 404-NotAuthorizedOrNotFound.
If I change my tf file just for create compartment and do output, I see that compartment was created and i have permissions on it.
Here is a simple example of what I am trying to do

provider "oci" {
  region            = var.region
  tenancy_ocid      = var.tenancy_ocid
  user_ocid         = var.user_ocid
  fingerprint       = var.fingerprint
  private_key_path  = var.private_key_path
}
resource "oci_identity_compartment" "test" {
    compartment_id = var.tenancy_ocid
    description    = "test"
    name           = "testcomp1"
    enable_delete  = true   
}
resource "oci_identity_compartment" "child_comp" {
    compartment_id = oci_identity_compartment.test.id
    description    = "child_compartment"
    name           = "testcomp2"
    enable_delete  = true   
}

And I get an error

oci_identity_compartment.test: Creating...
oci_identity_compartment.test: Creation complete after 2s [id=ocid1.compartment.oc1..#################################u34btwr7th6xj3ksba]
oci_identity_compartment.child_comp: Creating...
╷
│ Error: 404-NotAuthorizedOrNotFound 
│ Provider version: 4.31.0, released on 2021-06-16.  
│ Service: Identity Compartment 
│ Error Message: Authorization failed or requested resource not found 
│ OPC request ID: 50970b6329c5bbecd4d2e05349416363/3312C2400C4F75663D3A3BF1B285EE2F/271B6D5366B5FB0B5634653B0EFC4B18 
│ Suggestion: Either the resource has been deleted or service Identity Compartment need policy to access this resource. Policy reference: https://docs.oracle.com/en-us/iaas/Content/Identity/Reference/policyreference.htm
│ 
│ 
│   with oci_identity_compartment.child_comp,
│   on main.tf line 14, in resource "oci_identity_compartment" "child_comp":
│   14: resource "oci_identity_compartment" "child_comp" {

But if i run terraform apply second time, it will create sub compartment and all what I need.
Maybe somebody can help me with this problem, what need to do for creating my infrastructure from the first run

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions