Skip to content

Commit

Permalink
fix(UMIG): access_config should be 2D array (#111)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: var.access_config has been changed to a 2D array, with a separate element for each VM.
  • Loading branch information
UrosSimovic authored Sep 15, 2020
1 parent 7a21e78 commit 69f7520
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/umig/full/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,5 @@ module "umig" {
instance_template = module.instance_template.self_link
named_ports = var.named_ports
region = var.region
access_config = [local.access_config]
access_config = [[local.access_config]]
}
3 changes: 2 additions & 1 deletion modules/umig/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ resource "google_compute_instance_from_template" "compute_instance" {
network_ip = length(var.static_ips) == 0 ? "" : element(local.static_ips, count.index)

dynamic "access_config" {
for_each = var.access_config
# convert to map to use lookup function with default value
for_each = lookup({ for k, v in var.access_config : k => v }, count.index, [])
content {
nat_ip = access_config.value.nat_ip
network_tier = access_config.value.network_tier
Expand Down
4 changes: 2 additions & 2 deletions modules/umig/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ variable "instance_template" {

variable "access_config" {
description = "Access configurations, i.e. IPs via which the VM instance can be accessed via the Internet."
type = list(object({
type = list(list(object({
nat_ip = string
network_tier = string
}))
})))
default = []
}

0 comments on commit 69f7520

Please sign in to comment.