-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfirewall.tf
72 lines (60 loc) · 1.89 KB
/
firewall.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// --- Firewall Rules --- //
// Common / root rules deployment wide
// Allow ICMP traffic --- //
resource "google_compute_firewall" "vpc_netfw_allow_icmp" {
name = "${module.vpc_network.network_name}-allow-icmp"
description = "VPC-wide firewall baseline configuration to allow ICMP"
network = module.vpc_network.network_self_link
depends_on = [module.vpc_network]
allow {
protocol = "icmp"
}
source_ranges = [
"0.0.0.0/0"
]
}
// Allow HTTP traffic to tagged nodes --- //
resource "google_compute_firewall" "vpc_netfw_allow_http" {
name = "${module.vpc_network.network_name}-allow-http"
description = "VPC-wide firewall configuration to allow HTTP on VMs tagged accrodingly"
network = module.vpc_network.network_self_link
depends_on = [module.vpc_network]
allow {
protocol = "tcp"
ports = ["80", "8080"]
}
target_tags = [local.fw_tag_http]
source_ranges = [
"0.0.0.0/0"
]
}
// Allow HTTPS traffic to tagged nodes --- //
resource "google_compute_firewall" "vpc_netfw_allow_https" {
name = "${module.vpc_network.network_name}-allow-https"
description = "VPC-wide firewall configuration to allow HTTPS on VMs tagged accrodingly"
network = module.vpc_network.network_self_link
depends_on = [module.vpc_network]
allow {
protocol = "tcp"
ports = ["443"]
}
target_tags = [local.fw_tag_https]
source_ranges = [
"0.0.0.0/0"
]
}
// Allow SSH traffic to tagged nodes --- //
resource "google_compute_firewall" "vpc_netfw_allow_ssh" {
name = "${module.vpc_network.network_name}-allow-ssh"
description = "VPC-wide firewall configuration to allow SSH on VMs tagged accrodingly"
network = module.vpc_network.network_self_link
depends_on = [module.vpc_network]
allow {
protocol = "tcp"
ports = ["22"]
}
target_tags = [local.fw_tag_ssh]
source_ranges = [
"0.0.0.0/0"
]
}