infobloxopen / terraform-provider-infoblox

Infoblox NIOS Terraform Provider
https://github.com/infobloxopen/terraform-provider-infoblox
Mozilla Public License 2.0
68 stars 77 forks source link

Error: getting Network block from network view (default) failed : WAPI request error: 404('404 Not Found' #316

Closed GuillaumeMos closed 5 months ago

GuillaumeMos commented 1 year ago

Hello,

I'm trying to create subnets using a parent network via terraform, it works on the first apply, but when I reapply I get this error:

│ Error: getting Network block from network view (default) failed : WAPI request error: 404('404 Not Found')
│ Contents:
│ { "Error": "AdmConDataNotFoundError: Reference network/ZG5zLm5ldHdvcmskMTAuNTUuMzIuMC8yMS8w:10.55.32.0/21/default not found", 
│ "code": "Client.Ibap.Data.NotFound", 
│ "text": "Reference network/ZG5zLm5ldHdvcmskMTAuNTUuMzIuMC8yMS8w:10.55.32.0/21/default not found"
│ }
│ 
│ 
│ with infoblox_ipv4_network.network_gcp["xxx"],
│ on network.tf line 2, in resource "infoblox_ipv4_network" "network_gcp":
│ 2: resource "infoblox_ipv4_network" "network_gcp" {
│ 

I don't really understand what's going on, I have the impression that it can't recover the parent network to redo the plan. Has anyone encountered this issue before?

TF version ; 1.5.7 Provider infoblox : 2.4.1

Code sample :

network.tf

// Ressources for create networks
resource "infoblox_ipv4_network" "network_gcp" {
  for_each            = var.NETWORK
  parent_cidr         = each.value.parent_cidr
  cidr                = each.value.cidr
  allocate_prefix_len = each.value.allocate_prefix_len
  network_view        = each.value.network_view
  comment             = each.value.comment
  ext_attrs           = jsonencode(each.value.ext_attrs)
}

resource "infoblox_ipv4_network" "network_gcp_vms" {
  for_each            = { for NETWORK, values in var.NETWORK : NETWORK => values if values.vms }
  parent_cidr         = infoblox_ipv4_network.network_gcp[each.key].cidr #data.infoblox_ipv4_network.data_network_gcp[each.key].cidr
  cidr                = each.value.cidr_vms
  allocate_prefix_len = each.value.vms_allocate_prefix_len
  network_view        = each.value.network_view
  comment             = each.value.comment_vms
  ext_attrs           = jsonencode(each.value.ext_attrs)
}

variable.tf ( just for the example)

variable "NETWORK" {
  description = "Network rule configuration"
  type = map(object({
    parent_cidr         = optional(string)
    allocate_prefix_len = optional(number)
    network_view        = optional(string, "default")
    gateway             = optional(string)
    comment             = string
    ext_attrs           = map(string)
    cidr                = optional(string)
    ## VMS
    vms                     = optional(bool, "false")
    cidr_vms                = optional(string)
    comment_vms             = optional(string)
    vms_allocate_prefix_len = optional(number, "24")
    }))}

Thanks boys !

JkhatriInfobox commented 5 months ago

Hi @GuillaumeMos, As between 1st apply and 2nd apply if any drift occur by the manual intervention to data leads to the situation. we have release our plugin to maintain manual drift state with version v2.6.0

This will solves your issue for manual deletion happen.

Hence closing this issue, if issue persist feel free to re-open.