terraform-ibm-modules/terraform-ibm-landing-zone

Public gateways are not able to get attached in case of existing subnet scenario

nupurg-ibm opened this issue · 1 comments

Description

Public gateways are not able to get attached with the subnets in case of existing subnets scenario

If user is giving list of subnet_ids, And those subnets don't have the public gateway attached, we want to attach those using use_public_gateways attribute, as our instances would definitely need public gateways for internet connectivity.

Here are our local vars for reference:

  existing_subnets_use_public_gateways = {
    "zone-1" = true
    "zone-2" = false
    "zone-3" = true 
  }

  vpcs = [
    {
      prefix                       = local.name
      existing_vpc_id              = var.vpc == null ? null : data.ibm_is_vpc.itself[0].id
      existing_subnet_ids          = var.subnet_ids == null ? null : var.subnet_ids
      resource_group               = var.resource_group == null ? "workload-rg" : var.resource_group
      clean_default_security_group = true
      clean_default_acl            = true
      flow_logs_bucket_name        = var.enable_vpc_flow_logs ? "vpc-flow-logs-bucket" : null
      network_acls = [
        {
          name              = "hpc-acl"
          add_cluster_rules = false
          rules             = local.network_acl_rules
        }
      ],
      subnets             = var.subnet_ids == null ? local.subnets : null
      use_public_gateways = var.subnet_ids == null ? local.use_public_gateways : local.existing_subnets_use_public_gateways
      address_prefixes    = local.address_prefixes
    }
  ]

As per the object map provided under use_public_gateways attribute, public gateways got created in existing subnet but attachment didn't happen.

This has been fixed and released: https://github.com/terraform-ibm-modules/terraform-ibm-landing-zone/releases/tag/v5.7.0

Changes needed were:

  • input variable vpcs.existing_subnet_ids renamed to vpcs.existing_subnets
  • type of input changed from list(string) to list(object)
  • existing subnet object contains ID of subnet and boolean for public gateway attachment