Added option to create routes for NVA.

This commit is contained in:
2025-03-31 21:36:30 +02:00
parent e7222382f1
commit bd16823f66
3 changed files with 17 additions and 2 deletions
+11 -1
View File
@@ -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
}