Finished first version of network, network-peering and linux-vm modules.

This commit is contained in:
2025-03-31 10:10:39 +02:00
parent 6924f75c86
commit 93537e5da5
6 changed files with 145 additions and 61 deletions
+24
View File
@@ -0,0 +1,24 @@
# Peering
resource "google_compute_network_peering" "left_to_right" {
name = "${var.left.network_name}-to-${var.right.network_name}"
network = var.left.network_id
peer_network = var.right.network_id
export_custom_routes = true
import_custom_routes = var.hub_spoke ? false : true
export_subnet_routes_with_public_ip = true
import_subnet_routes_with_public_ip = var.hub_spoke ? false : true
}
resource "google_compute_network_peering" "right_to_left" {
name = "${var.right.network_name}-to-${var.left.network_name}"
network = var.right.network_id
peer_network = var.left.network_id
export_custom_routes = var.hub_spoke ? false : true
import_custom_routes = true
export_subnet_routes_with_public_ip = var.hub_spoke ? false : true
import_subnet_routes_with_public_ip = true
}
+23
View File
@@ -0,0 +1,23 @@
variable "left" {
description = "The left side of the peering connection."
type = object({
project_id = string
network_id = string
network_name = string
})
}
variable "right" {
description = "The right side of the peering connection."
type = object({
project_id = string
network_id = string
network_name = string
})
}
variable "hub_spoke" {
type = bool
default = false
description = "Set to true if the peering is hub-spoke."
}