-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsecurity_groups.tf
64 lines (55 loc) · 1.96 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
resource "aws_security_group" "elb" {
name = "${var.aws_security_group_prefix}${var.env_name}-elb"
description = "ELB Security Group for ${var.env_name}"
vpc_id = "${var.vpc_id}"
tags {
cebeci = "ignore"
Name = "${var.aws_security_group_name_prefix}${var.env_name}-loadbalancer"
}
}
resource "aws_security_group" "eb" {
name = "${var.aws_security_group_prefix}${var.env_name}-eb"
description = "EB Security Group for ${var.env_name}"
vpc_id = "${var.vpc_id}"
tags {
cebeci = "ignore"
Name = "${var.aws_security_group_name_prefix}${var.env_name}-eb"
}
}
# EB security group config
# Allow all incoming communication within the cluster
resource "aws_security_group_rule" "eb_ingress_allow_all_within_cluster" {
type = "ingress"
from_port = 0
to_port = 0
protocol = "-1"
source_security_group_id = "${aws_security_group.eb.id}"
security_group_id = "${aws_security_group.eb.id}"
}
# Allow incoming communication from ELB at port 80
resource "aws_security_group_rule" "eb_ingress_allow_from_elb_80" {
type = "ingress"
from_port = 80
to_port = 80
protocol = "TCP"
source_security_group_id = "${aws_security_group.elb.id}"
security_group_id = "${aws_security_group.eb.id}"
}
# Allow all outgoing communication from the cluster
resource "aws_security_group_rule" "eb_allow_all_egress" {
type = "egress"
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
security_group_id = "${aws_security_group.eb.id}"
}
# ELB security group config
resource "aws_security_group_rule" "elb_allow_all_egress" {
type = "egress"
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
security_group_id = "${aws_security_group.elb.id}"
}