Added option to create routes for NVA.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
data "google_client_config" "default" {}
|
||||
|
||||
resource "google_compute_instance" "vm_hub" {
|
||||
resource "google_compute_instance" "vm" {
|
||||
name = var.name
|
||||
machine_type = var.machine_type
|
||||
can_ip_forward = var.can_ip_forward
|
||||
@@ -23,3 +23,13 @@ resource "google_compute_instance" "vm_hub" {
|
||||
ssh-keys = "${var.ssh[0].public_key} ${var.ssh[0].ssh_user}"
|
||||
}
|
||||
}
|
||||
|
||||
resource "google_compute_route" "route_to_remote_network" {
|
||||
count = length(var.remote_subnets)
|
||||
name = "${var.network_name}-to-${replace(var.remote_subnets[count.index], "/[./]/", "-")}"
|
||||
project = var.project_id != null ? var.project_id : data.google_client_config.default.project
|
||||
network = var.network_name
|
||||
dest_range = var.remote_subnets[count.index]
|
||||
next_hop_instance = google_compute_instance.vm.id
|
||||
next_hop_instance_zone = google_compute_instance.vm.zone
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
output "vm_internal_ip" {
|
||||
value = google_compute_instance.vm_hub.network_interface[0].network_ip
|
||||
value = google_compute_instance.vm.network_interface[0].network_ip
|
||||
}
|
||||
|
||||
@@ -46,3 +46,8 @@ variable "ssh" {
|
||||
ssh_user = string
|
||||
}))
|
||||
}
|
||||
|
||||
variable "remote_subnets" {
|
||||
type = list(string)
|
||||
default = []
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user