36 lines
1.2 KiB
Terraform
36 lines
1.2 KiB
Terraform
data "google_client_config" "default" {}
|
|
|
|
resource "google_compute_instance" "vm" {
|
|
name = var.name
|
|
machine_type = var.machine_type
|
|
can_ip_forward = var.can_ip_forward
|
|
project = var.project_id != null ? var.project_id : data.google_client_config.default.project
|
|
description = var.description
|
|
|
|
boot_disk {
|
|
initialize_params {
|
|
image = "debian-cloud/debian-12"
|
|
}
|
|
}
|
|
|
|
network_interface {
|
|
network = var.network_name
|
|
subnetwork = var.subnet_name
|
|
subnetwork_project = var.project_id != null ? var.project_id : data.google_client_config.default.project
|
|
}
|
|
|
|
metadata = {
|
|
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
|
|
}
|