Skip to content

Commit 69f7520

Browse files
authored
fix(UMIG): access_config should be 2D array (#111)
BREAKING CHANGE: var.access_config has been changed to a 2D array, with a separate element for each VM.
1 parent 7a21e78 commit 69f7520

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

examples/umig/full/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,5 @@ module "umig" {
7373
instance_template = module.instance_template.self_link
7474
named_ports = var.named_ports
7575
region = var.region
76-
access_config = [local.access_config]
76+
access_config = [[local.access_config]]
7777
}

modules/umig/main.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ resource "google_compute_instance_from_template" "compute_instance" {
5656
network_ip = length(var.static_ips) == 0 ? "" : element(local.static_ips, count.index)
5757

5858
dynamic "access_config" {
59-
for_each = var.access_config
59+
# convert to map to use lookup function with default value
60+
for_each = lookup({ for k, v in var.access_config : k => v }, count.index, [])
6061
content {
6162
nat_ip = access_config.value.nat_ip
6263
network_tier = access_config.value.network_tier

modules/umig/variables.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ variable "instance_template" {
7171

7272
variable "access_config" {
7373
description = "Access configurations, i.e. IPs via which the VM instance can be accessed via the Internet."
74-
type = list(object({
74+
type = list(list(object({
7575
nat_ip = string
7676
network_tier = string
77-
}))
77+
})))
7878
default = []
7979
}

0 commit comments

Comments
 (0)