我正在努力学习wireguard。我找到了这个关于如何在 GCP 上安装它的很棒的教程 .... https://sreejithag.medium.com/set-up-wireguard-vpn-with-google-cloud-57bb3267a6ef
非常基本(对于刚接触wireguard的人)但它确实有效。本教程显示了一个使用 ip forwarding 配置的 vm。通过 GCP Web 界面
我想用 terraform 来设置它。我搜索了 terraform 注册表,发现了这个......
这是我的带有虚拟机配置的 main.tf。我会在哪里放置类似 ip forwarding 的东西?没有 terraform 抱怨?
代码 - -
# This is the provider used to spin up the gcloud instance
provider "google" {
project = var.project_name
region = var.region_name
zone = var.zone_name
credentials = "mycredentials.json"
}
# Locks the version of Terraform for this particular use case
terraform {
required_version = "0.14.6"
}
# This creates the google instance
resource "google_compute_instance" "vm_instance" {
name = "development-vm"
machine_type = var.machine_size
tags = ["allow-http", "allow-https", "allow-dns", "allow-tor", "allow-ssh", "allow-2277", "allow-mosh", "allow-whois", "allow-openvpn", "allow-wireguard"] # FIREWALL
boot_disk {
initialize_params {
image = var.image_name
size = var.disk_size_gb
}
}
network_interface {
network = "default"
# Associated our public IP address to this instance
access_config {
nat_ip = google_compute_address.static.address
}
}
# We connect to our instance via Terraform and remotely executes our script using SSH
provisioner "remote-exec" {
script = var.script_path
connection {
type = "ssh"
host = google_compute_address.static.address
user = var.username
private_key = file(var.private_key_path)
}
}
}
# We create a public IP address for our google compute instance to utilize
resource "google_compute_address" "static" {
name = "vm-public-address"
}