-
Notifications
You must be signed in to change notification settings - Fork 1
/
security-groups.tf
42 lines (36 loc) · 1.36 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
resource "aws_security_group" "security_group" {
name = "${var.enviroment}-${var.name}-security-group"
description = "${var.enviroment} ${var.name} Security group to allow controlled inbound traffic"
vpc_id = "${var.vpc_id}"
tags {
Name = "${var.enviroment} ${var.name}"
Enviroment = "${terraform.workspace}"
}
}
resource "aws_security_group_rule" "engine_editor_port_rule" {
type = "ingress"
count = "${length(var.ingress_rules)}"
description = "${lookup(var.ingress_rules[count.index], "description")}"
from_port = "${lookup(var.ingress_rules[count.index], "from_port")}"
to_port = "${lookup(var.ingress_rules[count.index], "to_port")}"
protocol = "${lookup(var.ingress_rules[count.index], "protocol")}"
cidr_blocks = ["0.0.0.0/0"]
security_group_id = "${aws_security_group.security_group.id}"
}
resource "aws_security_group_rule" "ssh_port_rule" {
type = "ingress"
description = "Open allow instance to be accessed via ssh"
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
security_group_id = "${aws_security_group.security_group.id}"
}
resource "aws_security_group_rule" "ec2_egress_rule_all" {
type = "egress"
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
security_group_id = "${aws_security_group.security_group.id}"
}