Skip to content
This repository has been archived by the owner on Dec 11, 2020. It is now read-only.

Replacement triggered for docker network with ipam_config #279

Open
project0 opened this issue Jul 9, 2020 · 1 comment
Open

Replacement triggered for docker network with ipam_config #279

project0 opened this issue Jul 9, 2020 · 1 comment
Labels

Comments

@project0
Copy link

project0 commented Jul 9, 2020

I experience strange behavior that it tries to replace my docker network after rebooting the server.
Looks like the ipam_config stanza cannot be properly merged and then triggeres the replacement.

Terraform v0.12.28
+ provider.docker v2.7.1
resource "docker_network" "server" {
  name            = local.network_name
  check_duplicate = true

  driver = "bridge"
  ipv6   = true

  ipam_config {
    subnet = var.subnets.ipv4_cidr
  }

  ipam_config {
    subnet = var.subnets.ipv6_cidr
  }
}
  # module.base.docker_network.server must be replaced
-/+ resource "docker_network" "server" {
      - attachable      = false -> null
        check_duplicate = true
        driver          = "bridge"
      ~ id              = "f565f7f1a0db0c184f69c24e8f113ce7d88c12e43ae4bf862b0f51c15940a633" -> (known after apply)
      - ingress         = false -> null
      ~ internal        = false -> (known after apply)
        ipam_driver     = "default"
        ipv6            = true
        name            = "server-vagrant"
      ~ options         = {} -> (known after apply)
      ~ scope           = "local" -> (known after apply)

      - ipam_config { # forces replacement
          - aux_address = {} -> null
          - gateway     = "172.16.10.1" -> null
          - subnet      = "172.16.10.0/24" -> null
        }
      - ipam_config { # forces replacement
          - aux_address = {} -> null
          - gateway     = "2001:1:6d:99f:400::1" -> null
          - subnet      = "2001:1:006d:099f:0100:0000:0000:0000/80" -> null
        }
      + ipam_config { # forces replacement
          + subnet = "172.16.10.0/24"
        }
      + ipam_config { # forces replacement
          + subnet = "2001:1:006d:099f:0100:0000:0000:0000/80"
        }
    }

docker inspect after creation:

    {
        "Name": "server-vagrant",
        "Id": "7347683ef27d04299465172f017fc89b352e7a1546ba50ec2bd7b3223a9721fa",
        "Created": "2020-07-09T16:53:23.763556354Z",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": true,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "172.16.10.0/24"
                },
                {
                    "Subnet": "2001:1:006d:099f:0100:0000:0000:0000/80"
                }
            ]
        }
  }

docker inspect after reboot:

    {
        "Name": "server-vagrant",
        "Id": "f565f7f1a0db0c184f69c24e8f113ce7d88c12e43ae4bf862b0f51c15940a633",
        "Created": "2020-07-06T18:43:47.35749164Z",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": true,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "172.16.10.0/24",
                    "Gateway": "172.16.10.1"
                },
                {
                    "Subnet": "2001:1:006d:099f:0100:0000:0000:0000/80",
                    "Gateway": "2001:1:6d:99f:100::1"
                }
            ]
        }
}
@project0
Copy link
Author

project0 commented Jul 9, 2020

i fixed that by generating the gateway attribute at my own, not sure if this is an expected behavior as the documentation tells its an "optional" parameter.

gateway = cidrhost(var.subnets.ipv4_cidr,1)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants