-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsg.tf
More file actions
61 lines (52 loc) · 1.48 KB
/
sg.tf
File metadata and controls
61 lines (52 loc) · 1.48 KB
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
######################################
# Creating an eks-only security group
######################################
resource "aws_security_group" "sg_eks_cluster" {
name = var.sg_eks_cluster_name
description = var.sg_eks_cluster_description
vpc_id = aws_vpc.vpc.id
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
tags = {
Name = var.sg_eks_cluster_name
}
}
# add ingress rule of security group
resource "aws_security_group_rule" "sg_eks_cluster_ingress" {
cidr_blocks = ["0.0.0.0/0"]
from_port = 0
protocol = "-1"
security_group_id = aws_security_group.sg_eks_cluster.id
to_port = 0
type = "ingress"
}
##################################################
# Create a security group that allows all inbound
##################################################
resource "aws_security_group" "sg_allow_all" {
name = var.sg_allow_all
description = var.sg_allow_all_description
vpc_id = aws_vpc.vpc.id
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
tags = {
Name = var.sg_allow_all
}
}
# add ingress rule of security group
resource "aws_security_group_rule" "sg_eks_allow_all" {
cidr_blocks = ["0.0.0.0/0"]
from_port = 0
protocol = "-1"
security_group_id = aws_security_group.sg_allow_all.id
to_port = 0
type = "ingress"
}