-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathsecurity_group.tf
111 lines (94 loc) · 2.49 KB
/
security_group.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
###############################################################
# Security Group
###############################################################
module "db_sg" {
source = "terraform-aws-modules/security-group/aws"
version = "4.9.0"
name = "${var.prefix}-${var.environment}-db-sg"
description = "MySQL Security Group"
vpc_id = module.vpc.vpc_id
# ingress
ingress_with_cidr_blocks = [
{
from_port = 3306
to_port = 3306
protocol = "tcp"
description = "MySQL access from within VPC"
cidr_blocks = module.vpc.vpc_cidr_block
},
]
tags = var.tags
}
module "efs_sg" {
source = "terraform-aws-modules/security-group/aws"
version = "4.9.0"
name = "${var.prefix}-${var.environment}-efs-sg"
description = "EFS Security Group"
vpc_id = module.vpc.vpc_id
# ingress
ingress_cidr_blocks = [module.vpc.vpc_cidr_block]
ingress_rules = ["all-all"]
tags = var.tags
}
module "ssh_sg" {
source = "terraform-aws-modules/security-group/aws"
version = "4.9.0"
name = "${var.prefix}-${var.environment}-ssh-sg"
description = "SSH Security Group"
vpc_id = module.vpc.vpc_id
# ingress
ingress_with_cidr_blocks = [
{
description = "SSH access from anywhere"
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = "0.0.0.0/0"
},
{
description = "Acess from within VPC"
from_port = 0
to_port = 65535
protocol = "tcp"
cidr_blocks = module.vpc.vpc_cidr_block
},
]
# egress
egress_cidr_blocks = ["0.0.0.0/0"]
egress_rules = ["all-all"]
tags = var.tags
}
module "http_sg" {
source = "terraform-aws-modules/security-group/aws"
version = "4.9.0"
name = "${var.prefix}-${var.environment}-http-sg"
description = "Frontend Security Group"
vpc_id = module.vpc.vpc_id
ingress_with_cidr_blocks = [
{
from_port = 443
to_port = 443
protocol = "tcp"
description = "${var.environment}-https to ELB"
cidr_blocks = "0.0.0.0/0"
},
{
from_port = 80
to_port = 80
protocol = "tcp"
description = "${var.environment}-http to ELB"
cidr_blocks = "0.0.0.0/0"
}
]
##### egress
egress_with_cidr_blocks = [
{
description = "Access from within VPC"
from_port = 0
to_port = 65535
protocol = "tcp"
cidr_blocks = module.vpc.vpc_cidr_block
},
]
tags = var.tags
}