-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsg-consul.tf
69 lines (61 loc) · 2.54 KB
/
sg-consul.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
resource "google_service_account" "consul_sg" {
account_id = "${var.vpc_name}-${var.consul_sg_name}"
description = "${var.consul_sg_name} service account"
count = var.consul_enabled ? 1 : 0
}
resource "google_compute_firewall" "consul_sg_ssh" {
name = "${var.vpc_name}-${var.consul_sg_name}-ssh"
network = module.public-vpc.network_name
count = var.consul_enabled && ! var.bastion_enabled ? 1 : 0
description = "${var.consul_sg_name} SSH access from corporate IP"
direction = "INGRESS"
source_ranges = var.corporate_ip == "" ? ["0.0.0.0/0"] : ["${var.corporate_ip}/32"]
target_service_accounts = google_service_account.consul_sg[*].email
allow {
ports = [
"22"]
protocol = "tcp"
}
}
resource "google_compute_firewall" "consul_sg_bastion_ssh" {
name = "${var.vpc_name}-${var.consul_sg_name}-ssh"
network = module.private-vpc.network_name
count = var.consul_enabled && var.bastion_enabled ? 1 : 0
description = "${var.consul_sg_name} SSH access via bastion host"
direction = "INGRESS"
source_service_accounts = google_service_account.bastion_sg[*].email
target_service_accounts = google_service_account.consul_sg[*].email
allow {
ports = [
"22"]
protocol = "tcp"
}
}
resource "google_compute_firewall" "consul_sg_mon_prom" {
name = "${var.vpc_name}-${var.consul_sg_name}-monitoring"
network = module.private-vpc.network_name
count = var.consul_enabled && var.monitoring_enabled ? 1 : 0
description = "${var.consul_sg_name} node exporter"
direction = "INGRESS"
source_service_accounts = google_service_account.monitoring_sg[*].email
target_service_accounts = google_service_account.consul_sg[*].email
allow {
ports = [
"9100"]
protocol = "tcp"
}
}
resource "google_compute_firewall" "consul_sg_mon_nordstrom" {
name = "${var.vpc_name}-${var.consul_sg_name}-monitoring"
network = module.private-vpc.network_name
count = var.consul_enabled && ! var.monitoring_enabled ? 1 : 0
description = "${var.consul_sg_name} node exporter"
direction = "INGRESS"
source_service_accounts = google_service_account.monitoring_sg[*].email
target_service_accounts = google_service_account.consul_sg[*].email
allow {
ports = [
"9428"]
protocol = "tcp"
}
}