This repository has been archived by the owner on Jul 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
/
admin.tf
139 lines (119 loc) · 4.57 KB
/
admin.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
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
resource "aws_iam_instance_profile" "admin-ec2-profile" {
name = "admin-ec2-profile"
roles = ["admin-ec2-role"]
}
resource "aws_security_group" "admin-ec2-sg" {
name = "admin-ec2-sg"
description = "admin SG"
vpc_id = "${aws_vpc.apps-shared-vpc.id}"
}
resource "aws_security_group_rule" "admin-ec2-sg-allowsharedssh" {
type = "ingress"
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["${aws_vpc.apps-shared-vpc.cidr_block}"]
security_group_id = "${aws_security_group.admin-ec2-sg.id}"
}
resource "aws_security_group_rule" "admin-ec2-sg-allowsharedjenkins" {
type = "ingress"
from_port = 8081
to_port = 8081
protocol = "tcp"
cidr_blocks = ["${aws_vpc.apps-shared-vpc.cidr_block}"]
security_group_id = "${aws_security_group.admin-ec2-sg.id}"
}
resource "aws_security_group_rule" "admin-ec2-sg-allowhttpfromadmin-elb" {
type = "ingress"
from_port = 80
to_port = 80
protocol = "tcp"
source_security_group_id = "${aws_security_group.admin-elb-sg.id}"
security_group_id = "${aws_security_group.admin-ec2-sg.id}"
}
resource "aws_security_group_rule" "admin-ec2-sg-allowallegress" {
type = "egress"
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
security_group_id = "${aws_security_group.admin-ec2-sg.id}"
}
resource "aws_instance" "admin-ec2" {
ami = "${lookup(var.aws_amis, "admin-node-2016-07-15")}" # For bug 1285306
instance_type = "t2.medium"
disable_api_termination = true
key_name = "ansible"
vpc_security_group_ids = ["${aws_security_group.admin-ec2-sg.id}"]
subnet_id = "${aws_subnet.apps-shared-1c.id}"
iam_instance_profile = "${aws_iam_instance_profile.admin-ec2-profile.name}"
root_block_device {
volume_type = "standard"
volume_size = 20
}
tags {
Name = "admin"
app = "jenkins"
env = "shared"
project = "partinfra"
}
}
resource "aws_security_group" "admin-elb-sg" {
name = "admin-elb-sg"
description = "Admin ELB SG"
vpc_id = "${aws_vpc.apps-shared-vpc.id}"
}
resource "aws_security_group_rule" "admin-elb-sg-allowhttps" {
type = "ingress"
from_port = 443
to_port = 443
protocol = "tcp"
cidr_blocks = [
"${aws_vpc.apps-shared-vpc.cidr_block}",
"${aws_vpc.apps-staging-vpc.cidr_block}",
"${aws_vpc.apps-production-vpc.cidr_block}"
]
security_group_id = "${aws_security_group.admin-elb-sg.id}"
}
resource "aws_security_group_rule" "admin-elb-sg-allowall" {
type = "egress"
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = [
"${aws_vpc.apps-shared-vpc.cidr_block}",
"${aws_vpc.apps-staging-vpc.cidr_block}",
"${aws_vpc.apps-production-vpc.cidr_block}"
]
security_group_id = "${aws_security_group.admin-elb-sg.id}"
}
resource "aws_elb" "admin-elb" {
name = "admin-elb"
security_groups = ["${aws_security_group.admin-elb-sg.id}"]
subnets = ["${aws_subnet.apps-shared-1c.id}"]
internal = true
listener {
instance_port = 80
instance_protocol = "http"
lb_port = 443
lb_protocol = "https"
ssl_certificate_id = "arn:aws:acm:${var.aws_region}:${var.aws_account_id}:certificate/27b77e07-6d6f-4ea6-8d5c-8e216d33c5d7"
}
health_check {
healthy_threshold = 2
unhealthy_threshold = 2
timeout = 3
target = "TCP:80"
interval = 30
}
instances = ["${aws_instance.admin-ec2.id}"]
cross_zone_load_balancing = true
idle_timeout = 400
connection_draining = true
connection_draining_timeout = 400
tags {
Name = "admin-elb"
app = "jenkins"
env = "shared"
}
}