From c784d419f45802eb9ec2891f78cabc3d4adcc68c Mon Sep 17 00:00:00 2001 From: "aashiq.jacob@ibm.com" Date: Mon, 18 Nov 2024 18:34:04 +0530 Subject: [PATCH 1/5] fix: create VNI name based of the VSI name --- main.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.tf b/main.tf index c4176a74..bc8cac31 100644 --- a/main.tf +++ b/main.tf @@ -115,7 +115,7 @@ data "ibm_is_vpc" "vpc" { ############################################################################## resource "ibm_is_virtual_network_interface" "primary_vni" { for_each = { for vsi_key, vsi_value in local.vsi_map : vsi_key => vsi_value if !var.use_legacy_network_interface } - name = "${each.key}-vni" + name = "${each.value.vsi_name}-vni" subnet = each.value.subnet_id security_groups = flatten([ (var.create_security_group ? [ibm_is_security_group.security_group[var.security_group.name].id] : []), @@ -141,7 +141,7 @@ resource "ibm_is_virtual_network_interface" "primary_vni" { resource "ibm_is_virtual_network_interface" "secondary_vni" { for_each = { for k in var.secondary_subnets : k.zone => k if !var.use_legacy_network_interface } - name = each.value.name + name = "${var.prefix}-${each.value.name}-vni" subnet = each.value.id # If security_groups is empty(list is len(0)) then default list to data.ibm_is_vpc.vpc.default_security_group. # If list is empty it will fail on reapply as when vsi is passed an empty security group list it will attach the default security group. From 44d56eca5448dc576c93f402ad1034decf647ff9 Mon Sep 17 00:00:00 2001 From: "aashiq.jacob@ibm.com" Date: Mon, 18 Nov 2024 20:02:09 +0530 Subject: [PATCH 2/5] test --- main.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.tf b/main.tf index bc8cac31..75cd4e49 100644 --- a/main.tf +++ b/main.tf @@ -141,7 +141,7 @@ resource "ibm_is_virtual_network_interface" "primary_vni" { resource "ibm_is_virtual_network_interface" "secondary_vni" { for_each = { for k in var.secondary_subnets : k.zone => k if !var.use_legacy_network_interface } - name = "${var.prefix}-${each.value.name}-vni" + name = "${var.prefix}-${substr(md5(each.value.name), -4, 4)}-vni" subnet = each.value.id # If security_groups is empty(list is len(0)) then default list to data.ibm_is_vpc.vpc.default_security_group. # If list is empty it will fail on reapply as when vsi is passed an empty security group list it will attach the default security group. @@ -229,7 +229,7 @@ resource "ibm_is_instance" "vsi" { dynamic "primary_network_attachment" { for_each = var.use_legacy_network_interface ? [] : [1] content { - name = "${each.value.subnet_name}-eth0" + name = ibm_is_virtual_network_interface.primary_vni[each.key].name virtual_network_interface { id = ibm_is_virtual_network_interface.primary_vni[each.key].id } From 185f41472e1c7fd8d17b3a3fec9787794a16f3f3 Mon Sep 17 00:00:00 2001 From: "aashiq.jacob@ibm.com" Date: Mon, 18 Nov 2024 22:09:46 +0530 Subject: [PATCH 3/5] change key --- main.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.tf b/main.tf index 75cd4e49..0013e860 100644 --- a/main.tf +++ b/main.tf @@ -78,13 +78,13 @@ locals { secondary_fip_list = !var.use_legacy_network_interface && length(var.secondary_floating_ips) != 0 ? flatten([ for instance in ibm_is_instance.vsi : [ for network_attachment in instance.network_attachments : - network_attachment if contains([for subnet in var.secondary_floating_ips : subnet], network_attachment.name) + network_attachment if contains([for subnet in var.secondary_floating_ips : subnet], network_attachment.virtual_network_interface[0].name) ] ]) : [] secondary_fip_map = { for vni in local.secondary_fip_list : - vni.name => { + vni.virtual_network_interface[0].name => { vni_name = vni.virtual_network_interface[0].name subnet_name = vni.name vni_id = vni.virtual_network_interface[0].id From 79848ce4c766821f0e4b817f3d74620d5df9accc Mon Sep 17 00:00:00 2001 From: "aashiq.jacob@ibm.com" Date: Tue, 19 Nov 2024 09:21:22 +0530 Subject: [PATCH 4/5] revert --- main.tf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.tf b/main.tf index 0013e860..0721c7b2 100644 --- a/main.tf +++ b/main.tf @@ -78,13 +78,13 @@ locals { secondary_fip_list = !var.use_legacy_network_interface && length(var.secondary_floating_ips) != 0 ? flatten([ for instance in ibm_is_instance.vsi : [ for network_attachment in instance.network_attachments : - network_attachment if contains([for subnet in var.secondary_floating_ips : subnet], network_attachment.virtual_network_interface[0].name) + network_attachment if contains([for subnet in var.secondary_floating_ips : subnet], network_attachment.name) ] ]) : [] secondary_fip_map = { for vni in local.secondary_fip_list : - vni.virtual_network_interface[0].name => { + vni.name => { vni_name = vni.virtual_network_interface[0].name subnet_name = vni.name vni_id = vni.virtual_network_interface[0].id @@ -141,7 +141,7 @@ resource "ibm_is_virtual_network_interface" "primary_vni" { resource "ibm_is_virtual_network_interface" "secondary_vni" { for_each = { for k in var.secondary_subnets : k.zone => k if !var.use_legacy_network_interface } - name = "${var.prefix}-${substr(md5(each.value.name), -4, 4)}-vni" + name = each.value.name subnet = each.value.id # If security_groups is empty(list is len(0)) then default list to data.ibm_is_vpc.vpc.default_security_group. # If list is empty it will fail on reapply as when vsi is passed an empty security group list it will attach the default security group. From 4221cfa7e7ad213fe8f85c0adb4c560428d1a9aa Mon Sep 17 00:00:00 2001 From: "aashiq.jacob@ibm.com" Date: Tue, 19 Nov 2024 09:33:03 +0530 Subject: [PATCH 5/5] SKIP UPGRADE TEST