Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vcd_nsxt_edgegateway external_network should ignore primary_ip if not set #1267

Open
xorinzor opened this issue May 16, 2024 · 3 comments
Open
Assignees

Comments

@xorinzor
Copy link

Terraform Version

1.7.1

Affected Resource(s)

  • vcd_nsxt_edgegateway

Terraform Configuration Files

resource "vcd_nsxt_edgegateway" "nsxt_egw" {
  org                 = "myorg"
  owner_id            = vcd_org_vdc.vdc.id
  name                = "edge-gateway"
  external_network_id = data.vcd_external_network_v2.ext_net.id
  edge_cluster_id     = data.vcd_nsxt_edge_cluster.edge_cluster.id

  external_network {
    allocated_ip_count  = 1
    external_network_id = data.vcd_external_network_v2.some_ext_net.id
    gateway             = var.gateway
    prefix_length       = 24
  }
}

Expected Behavior

When the plan is applied, a subsequent plan should indicate no changes as no primary_ip is defined in the config and thus should be left as-is.

Actual Behavior

When the plan is applied, a subsequent plan removes and recreates the external_network because the primary_ip has been automatically assigned.

Screenshot (4)

Steps to Reproduce

  1. terraform apply to apply the initial state
  2. terraform plan to show that terraform wants to recreate the external_network
@Didainius
Copy link
Collaborator

Hello @xorinzor ,
is this the complete snippet that you're using?

@xorinzor
Copy link
Author

Hi, it is not.

I excluded everything that I deemed irrelevant due to the confidential nature of the code.

@Didainius
Copy link
Collaborator

Hi, it is not.

I excluded everything that I deemed irrelevant due to the confidential nature of the code.

Could you try to just maintain the structure with all fields, but anonimise data?

There may be some limitations that we can't overcome due to how Terraform schema works, but here is what I tried and it seems to work. Subsequent plans are clean once it is created.

resource "vcd_nsxt_edgegateway" "nsxt-edge" {
  org         = "v51"
  owner_id    = vcd_vdc_group.test1.id
  name        = "TestAccVcdNsxtEdgeGatewayVdcGroupExternalUplink-edge"
  description = "Description"

  external_network_id = vcd_external_network_v2.ext-net-nsxt-t0.id

  subnet {
     gateway       = tolist(vcd_external_network_v2.ext-net-nsxt-t0.ip_scope)[0].gateway
     prefix_length = tolist(vcd_external_network_v2.ext-net-nsxt-t0.ip_scope)[0].prefix_length

     primary_ip = tolist(tolist(vcd_external_network_v2.ext-net-nsxt-t0.ip_scope)[0].static_ip_pool)[0].end_address
     allocated_ips {
       start_address = tolist(tolist(vcd_external_network_v2.ext-net-nsxt-t0.ip_scope)[0].static_ip_pool)[0].end_address
       end_address   = tolist(tolist(vcd_external_network_v2.ext-net-nsxt-t0.ip_scope)[0].static_ip_pool)[0].end_address
     }
  }

  external_network {
    external_network_id = vcd_external_network_v2.segment-backed.id
    gateway             = tolist(vcd_external_network_v2.segment-backed.ip_scope)[0].gateway
    prefix_length       = tolist(vcd_external_network_v2.segment-backed.ip_scope)[0].prefix_length
    allocated_ip_count  = 2
  }

  external_network {
    external_network_id = vcd_external_network_v2.segment-backed2.id
    gateway             = tolist(vcd_external_network_v2.segment-backed2.ip_scope)[0].gateway
    prefix_length       = tolist(vcd_external_network_v2.segment-backed2.ip_scope)[0].prefix_length
    allocated_ip_count  = 8
  }
}

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

No branches or pull requests

2 participants