0

Trying to provision a network in OCI and I'm getting this same error for every single subnet even though the "terraform plan" is successful with no issues. Anybody know what the problem is here?

Error: 404-NotAuthorizedOrNotFound, Authorization failed or requested resource not found. 
Suggestion: Either the resource has been deleted or service Core Subnet need policy to access this resource. Policy reference: https://docs.oracle.com/en-us/iaas/Content/Identity/Reference/policyreference.htm
Documentation: https://registry.terraform.io/providers/oracle/oci/latest/docs/resources/core_subnet 
API Reference: https://docs.oracle.com/iaas/api/#/en/iaas/xxxxxxxx/Subnet/CreateSubnet 
Request Target: POST https://iaas.us-ashburn-1.oraclecloud.com/xxxxxxxx/subnets 
Provider version: 4.88.1, released on 2022-08-11.  
Service: Core Subnet 
Operation Name: CreateSubnet 
OPC request ID: xx/xx/xx


  on .terraform/modules/network/main-region2.tf line 899, in resource "oci_core_subnet" "subnets_sec":
 899: resource "oci_core_subnet" "subnets_sec" {

This is what I'm using for my subnet resource block:

resource "oci_core_subnet" "subnets_sec" {
  // Description: a subnet will be created for each key within the subnet_params_sec variable
  provider                   = oci.region_sec
  for_each                   = var.subnet_params_sec
  display_name               = each.key
  compartment_id             = oci_core_virtual_network.vcn_sec[each.value.vcn_name].compartment_id
  vcn_id                     = oci_core_virtual_network.vcn_sec[each.value.vcn_name].id
  cidr_block                 = each.value.cidr_block
  dns_label                  = each.value.dns_label
  dhcp_options_id            = lookup(var.dhcp_params_sec, each.key, null) != null ? oci_core_dhcp_options.default_dhcp_vcnres_sec[each.value.vcn_name].id : ""
  prohibit_public_ip_on_vnic = each.value.is_subnet_private
  route_table_id             = each.value.rt_name
}

Last important piece of info is that this was being deployed to an empty compartment so I don't know how a resource can be missing or deleted.

  • have you tried using the "depends_on =", need to see the rest of your terraform but you create "oci_core_virtual_network" vcn first, when you create the subnet, depend on something up the tree like the vcn, also I think for free tier account you cant create vcns – Nigel Savage Aug 21 '22 at 19:58

0 Answers0