-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
53 lines (42 loc) · 1.07 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
data "google_compute_network" "default" {
name = "default"
}
resource "google_compute_address" "static" {
name = "ipv4-address"
}
data "google_compute_image" "ubuntu_image" {
family = "ubuntu-2004-lts"
project = "ubuntu-os-cloud"
}
resource "google_compute_instance" "pihole" {
name = "pihole"
machine_type = "f1-micro"
zone = "us-east1-b"
tags = ["gcp-demo", "pihole-vpn"]
boot_disk {
initialize_params {
image = data.google_compute_image.ubuntu_image.self_link
}
}
network_interface {
network = data.google_compute_network.default.self_link
access_config {
nat_ip = google_compute_address.static.address
}
}
metadata_startup_script = file("setup.sh")
}
resource "google_compute_firewall" "firewall" {
name = "allow-wireguard"
network = data.google_compute_network.default.name
direction = "INGRESS"
priority = 1000
enable_logging = false
source_ranges = ["0.0.0.0/0"]
target_tags = ["pihole-vpn"]
allow {
protocol = "udp"
ports = ["51515"]
}
source_tags = ["web"]
}