-
Notifications
You must be signed in to change notification settings - Fork 0
/
security_groups.tf
87 lines (72 loc) · 2.32 KB
/
security_groups.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
module "ssh_sg" {
source = "terraform-aws-modules/security-group/aws"
version = "3.4"
name = "${var.prefix}-gbi-${var.application}-${var.env}-${var.region_trigram}-ssh-sg"
description = "Security group for ssh access"
vpc_id = module.vpc.vpc_id
ingress_cidr_blocks = sort(compact(distinct(concat(var.auto_ingress_rules, var.ingress_rules, [""]))))
ingress_with_cidr_blocks = [
{
from_port = 22
to_port = 22
protocol = "tcp"
description = "User-ssh ports"
cidr_blocks = "0.0.0.0/0"
},
]
}
module "http_sg" {
source = "terraform-aws-modules/security-group/aws"
name = "emobg-gbi-${var.application}-${var.env}-${var.region_trigram}-http-sg"
description = "Security group for http"
vpc_id = module.vpc.vpc_id
ingress_cidr_blocks = ["0.0.0.0/0"]
ingress_rules = ["http-80-tcp", "all-icmp"]
egress_rules = ["all-all"]
ingress_with_cidr_blocks = [
{
from_port = 10000
to_port = 10000
protocol = "tcp"
description = "http ports"
cidr_blocks = module.vpc.vpc_cidr_block
},
]
}
# TODO: Refactor this SG for RDS
module "rds_sg" {
source = "terraform-aws-modules/security-group/aws"
name = "${var.prefix}-gbi-${var.application}-${var.env}-${var.region_trigram}-rds-sg"
description = "Security group for http "
vpc_id = module.vpc.vpc_id
ingress_cidr_blocks = [module.vpc.vpc_cidr_block]
ingress_with_cidr_blocks = [
{
rule = "postgresql-tcp"
cidr_blocks = module.vpc.vpc_cidr_block
},
]
egress_with_cidr_blocks = [
{
rule = "postgresql-tcp"
cidr_blocks = "0.0.0.0/0"
},
]
}
module "redshift_sg" {
source = "terraform-aws-modules/security-group/aws"
name = "${var.prefix}-gbi-${var.application}-${var.env}-${var.region_trigram}-redshift-sg"
description = "Security group for Redshift "
vpc_id = module.vpc.vpc_id
ingress_cidr_blocks = [module.vpc.vpc_cidr_block]
ingress_with_cidr_blocks = [
{
from_port = 5439
to_port = 5439
protocol = "tcp"
description = "redshift ports"
cidr_blocks = module.vpc.vpc_cidr_block
},
]
egress_rules = ["all-all"]
}