infobloxopen / terraform-provider-infoblox

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

infoblox_ip_allocation with enable_dns = false and dns_view set will fail on second apply #323

Open grimm26 opened 6 months ago

grimm26 commented 6 months ago

infoblox_ip_allocation will happily take a value for dns_view when enable_dns is set to false and even tell you that it is setting that parameter to what you supplied. However, it actually sets it to " " and then the next apply will fail.

One of two things needs to happen:

  1. Ignore the value of dns_view when enable_dns is set to false.
  2. Do not allow dns_view to be set when enable_dns is false.

The documentation currently supports option 2, but that is not enforced and instead for some strange reason the value for dns_view is transformed into a single whitespace.

mnk-hpbook in ~/tf/ib2 πŸ’  v1.5.7 󰸏 (ohio) took 22s 
08:38:38 ❯ tf -version
Terraform v1.5.7
on linux_amd64
+ provider registry.terraform.io/infobloxopen/infoblox v2.5.0

mnk-hpbook in ~/tf/ib2 πŸ’  v1.5.7 󰸏 (ohio) 
08:38:43 ❯ cat ib2.tf
resource "infoblox_ip_allocation" "ip" {
  enable_dns = false
  dns_view   = "inside"
  fqdn       = "mkthing.staging.thing.com"
  ipv4_cidr  = "10.18.81.0/24"
}

terraform {
  required_version = "~> 1.3"
  required_providers {
    infoblox = {
      source  = "infobloxopen/infoblox"
      version = "~> 2.1"
    }
  }
}

mnk-hpbook in ~/tf/ib2 πŸ’  v1.5.7 󰸏 (ohio) 
08:38:53 ❯ tfa

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # infoblox_ip_allocation.ip will be created
  + resource "infoblox_ip_allocation" "ip" {
      + allocated_ipv4_addr = (known after apply)
      + allocated_ipv6_addr = (known after apply)
      + dns_view            = "inside"
      + enable_dns          = false
      + fqdn                = "mkthing.staging.thing.com"
      + id                  = (known after apply)
      + internal_id         = (known after apply)
      + ipv4_cidr           = "10.18.81.0/24"
      + network_view        = "default"
      + ref                 = (known after apply)
      + ttl                 = -2147483648
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

infoblox_ip_allocation.ip: Creating...
infoblox_ip_allocation.ip: Creation complete after 2s [id=976904b6-b632-47cf-b135-0e6e4a1b99e3]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

mnk-hpbook in ~/tf/ib2 πŸ’  v1.5.7 󰸏 (ohio) took 3s 
08:38:59 ❯ tfa
infoblox_ip_allocation.ip: Refreshing state... [id=976904b6-b632-47cf-b135-0e6e4a1b99e3]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # infoblox_ip_allocation.ip will be updated in-place
  ~ resource "infoblox_ip_allocation" "ip" {
      ~ dns_view            = " " -> "inside"
        id                  = "976904b6-b632-47cf-b135-0e6e4a1b99e3"
        # (8 unchanged attributes hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

infoblox_ip_allocation.ip: Modifying... [id=976904b6-b632-47cf-b135-0e6e4a1b99e3]
β•·
β”‚ Error: changing the value of 'dns_view' field is allowed only for the case of changing 'enable_dns' option
β”‚ 
β”‚   with infoblox_ip_allocation.ip,
β”‚   on ib2.tf line 1, in resource "infoblox_ip_allocation" "ip":
β”‚    1: resource "infoblox_ip_allocation" "ip" {
β”‚ 
mnk-hpbook in ~/tf/ib2 πŸ’  v1.5.7 󰸏 (ohio) 
08:40:18 ❌1 ❯ tf state show infoblox_ip_allocation.ip
# infoblox_ip_allocation.ip:
resource "infoblox_ip_allocation" "ip" {
    allocated_ipv4_addr = "10.18.81.21"
    dns_view            = " "
    enable_dns          = false
    fqdn                = "mkthing.staging.thing.com"
    id                  = "976904b6-b632-47cf-b135-0e6e4a1b99e3"
    internal_id         = "976904b6-b632-47cf-b135-0e6e4a1b99e3"
    ipv4_cidr           = "10.18.81.0/24"
    network_view        = "default"
    ref                 = "record:host/ZG5zLmhvc3QkLm5vbl9ETlNfaG9zdF9yb290LjEuMTcwMzY4NzkzODU5NC5jb20udGhpbmcuc3RhZ2luZy5ta3RoaW5n:mkthing.staging.thing.com/%20"
    ttl                 = -2147483648
}