-
Notifications
You must be signed in to change notification settings - Fork 0
/
security-groups
93 lines (88 loc) · 2.24 KB
/
security-groups
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
#Create SG for LB, only TCP/80,TCP/443 and outbound access
resource "aws_security_group" "lb-sg" {
provider = aws.region-master
name = "lb-sg"
description = "Allow 443 and traffic to Jenkins SG"
vpc_id = aws_vpc.vpc_master.id
ingress {
description = "Allow 443 from anywhere"
from_port = 443
to_port = 443
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
description = "Allow 80 from anywhere for redirection"
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}
#Create SG for allowing TCP/8080 from * and TCP/22 from your IP in us-east-1
resource "aws_security_group" "jenkins-sg" {
provider = aws.region-master
name = "jenkins-sg"
description = "Allow TCP/8080 & TCP/22"
vpc_id = aws_vpc.vpc_master.id
ingress {
description = "Allow 22 from our public IP"
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = [var.external_ip]
}
ingress {
description = "allow anyone on port 8080"
from_port = 8080
to_port = 8080
protocol = "tcp"
security_groups = [aws_security_group.lb-sg.id]
}
ingress {
description = "allow traffic from us-west-2"
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["192.168.1.0/24"]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}
#Create SG for allowing TCP/22 from your IP in us-west-2
resource "aws_security_group" "jenkins-sg-oregon" {
provider = aws.region-worker
name = "jenkins-sg-oregon"
description = "Allow TCP/8080 & TCP/22"
vpc_id = aws_vpc.vpc_master_oregon.id
ingress {
description = "Allow 22 from our public IP"
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = [var.external_ip]
}
ingress {
description = "Allow traffic from us-east-1"
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["10.0.1.0/24"]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}