-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsecurity-group.tf
46 lines (46 loc) · 1.53 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
# Ingress Security Port 22 (Inbound)
# Provides a security group rule resource
resource "aws_security_group_rule" "ssh_ingress_access" {
from_port = 22
protocol = "tcp"
security_group_id = aws_security_group.sg_allow_ssh_http.id
to_port = 22
type = "ingress"
cidr_blocks = [var.cidr_blocks]
}
# Ingress Security Port 80 (Inbound)
resource "aws_security_group_rule" "http_ingress_access" {
from_port = 80
protocol = "tcp"
security_group_id = aws_security_group.sg_allow_ssh_http.id
to_port = 80
type = "ingress"
cidr_blocks = [var.cidr_blocks]
}
# Ingress Security Port 8080 (Inbound)
resource "aws_security_group_rule" "http8080_ingress_access" {
from_port = 8080
protocol = "tcp"
security_group_id = aws_security_group.sg_allow_ssh_http.id
to_port = 8080
type = "ingress"
cidr_blocks = [var.cidr_blocks]
}
# Egress Security (Outbound)
resource "aws_security_group_rule" "egress_access" {
from_port = 0
protocol = "-1"
security_group_id = aws_security_group.sg_allow_ssh_http.id
to_port = 0
type = "egress"
cidr_blocks = [var.cidr_blocks]
}
########################### Provides a security group resource
resource "aws_security_group" "sg_allow_ssh_http" {
vpc_id = aws_vpc.devVPC.id
name = "${var.tag_project}_vpc_allow_ssh_http"
tags = {
Name = "${var.tag_project}_sg_allow_ssh_http"
project = var.tag_project
}
}