-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathglobal.tf
executable file
·115 lines (86 loc) · 2.14 KB
/
global.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#create network interface
resource "google_compute_network" "platform" {
name = "${var.platform-name}"
}
#create network interface for monitoring
resource "google_compute_network" "monitoring" {
name = "${var.monitoring-network-name}"
}
#Open ports
resource "google_compute_firewall" "ssh" {
name = "${var.platform-name}-ssh"
network = "${google_compute_network.platform.name}"
allow {
protocol = "icmp"
}
allow {
protocol = "tcp"
ports = ["22", "80", "443"]
}
source_ranges = ["0.0.0.0/0"]
}
# Firewall Groups Start =====================================
#Monitoring Security Group
# Rules Explanation
# ICMP PING // should be disabled
# 22 SSH
# 80 HTTP for Nagios
# 443 HTTPs for Nagios
# 9200 Elasticsearch
# 5043 Logstash
# 5601 Kibana
# 5666 Nagios NRPE
resource "google_compute_firewall" "monitoring" {
name = "${var.platform-name}-monitoring"
network = "${google_compute_network.monitoring.name}"
allow {
protocol = "icmp"
}
allow {
protocol = "tcp"
ports = ["22", "80", "443", "9200", "5043", "5601", "5666"]
}
source_ranges = ["0.0.0.0/0"]
}
#Bastion Security Group
# Rules Explanation
# ICMP
# 22
resource "google_compute_firewall" "bastion" {
name = "${var.platform-name}-bastion"
network = "${google_compute_network.platform.name}"
allow {
protocol = "icmp"
}
allow {
protocol = "tcp"
ports = ["22"]
}
source_ranges = ["0.0.0.0/0"]
}
#Nginx Security Group
# Rules Explanation
# ICMP
# 80 HTTP
# 22 SSH
# 9200 HTTPS
resource "google_compute_firewall" "nginx" {
name = "${var.platform-name}-nginx"
network = "${google_compute_network.platform.name}"
allow {
protocol = "icmp"
}
allow {
protocol = "tcp"
ports = ["22", "80", "9200"]
}
source_ranges = ["0.0.0.0/0"]
}
# Firewall Groups End =====================================
#Create subnet
# resource "google_compute_subnetwork" "dev" {
# name = "dev-${var.platform-name}-${var.gcloud-region}"
# ip_cidr_range = "10.1.2.0/24"
# network = "${google_compute_network.platform.self_link}"
# region = "${var.gcloud-region}"
# }