Skip to content
This repository has been archived by the owner on Dec 10, 2021. It is now read-only.

configure multiple destination ranges #77

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ module "nat-gateway" {
}

resource "google_compute_route" "nat-gateway" {
count = "${var.module_enabled ? 1 : 0}"
name = "${local.zonal_tag}"
count = "${var.module_enabled ? length(var.dest_ranges) : 0}"
name = "${local.zonal_tag}-${count.index}"
project = "${var.project}"
dest_range = "${var.dest_range}"
dest_range = "${element(var.dest_ranges, count.index)}"
network = "${data.google_compute_network.network.self_link}"
next_hop_instance = "${element(split("/", element(module.nat-gateway.instances[0], 0)), 10)}"
next_hop_instance_zone = "${local.zone}"
Expand Down
5 changes: 3 additions & 2 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ variable region_params {
}
}

variable "dest_range" {
variable "dest_ranges" {
type = "list"
description = "The destination IPv4 address range that this route applies to"
default = "0.0.0.0/0"
default = ["0.0.0.0/0"]
}