-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathshared_remote_agent_module.tf
258 lines (224 loc) · 6.04 KB
/
shared_remote_agent_module.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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
variable "aws_remote_region" {
description = "AWS region to launch servers."
default = "us-east-1"
}
provider "aws" {
alias = "bursted-vpc"
profile = "${var.aws_profile}"
region = "${var.aws_remote_region}"
}
# Create a VPC to launch our instances into
resource "aws_vpc" "bursted_region" {
provider = "aws.bursted-vpc"
cidr_block = "10.128.0.0/16"
#enable_dns_hostnames = "true"
tags {
Name = "${coalesce(var.owner, data.external.whoami.result["owner"])}"
}
}
# Create an internet gateway to give our subnet access to the outside world
resource "aws_internet_gateway" "bursted_region" {
provider = "aws.bursted-vpc"
vpc_id = "${aws_vpc.bursted_region.id}"
}
# Grant the VPC internet access on its main route table
resource "aws_route" "group_3_internet_access" {
provider = "aws.bursted-vpc"
route_table_id = "${aws_vpc.bursted_region.main_route_table_id}"
destination_cidr_block = "0.0.0.0/0"
gateway_id = "${aws_internet_gateway.bursted_region.id}"
}
# A security group that allows all port access to internal vpc
resource "aws_security_group" "group_any_access_internal" {
provider = "aws.bursted-vpc"
name = "cluster-security-group"
description = "Manage all ports cluster level"
vpc_id = "${aws_vpc.bursted_region.id}"
# full access internally
ingress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["10.0.0.0/8"]
}
# full access internally
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["10.0.0.0/8"]
}
}
resource "aws_security_group" "group_admin" {
provider = "aws.bursted-vpc"
name = "admin-security-group-1"
description = "Administrators can manage their machines"
vpc_id = "${aws_vpc.bursted_region.id}"
# SSH access from anywhere
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["${var.admin_cidr}"]
}
# http access from anywhere
ingress {
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["${var.admin_cidr}"]
}
# httpS access from anywhere
ingress {
from_port = 443
to_port = 443
protocol = "tcp"
cidr_blocks = ["${var.admin_cidr}"]
}
# outbound internet access
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}
# A security group for private slave so it is accessible internally
resource "aws_security_group" "group_private_slave" {
provider = "aws.bursted-vpc"
name = "private-slave-security-group"
description = "security group for slave private"
vpc_id = "${aws_vpc.bursted_region.id}"
# full access internally
ingress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["10.0.0.0/8"]
}
# full access internally
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["10.0.0.0/8"]
}
}
# A security group for public slave so it is accessible via the web
resource "aws_security_group" "group_public_slave" {
provider = "aws.bursted-vpc"
name = "public-slave-security-group"
description = "security group for slave public"
vpc_id = "${aws_vpc.bursted_region.id}"
# Allow ports within range
ingress {
to_port = 21
from_port = 0
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
# Allow ports within range
ingress {
to_port = 5050
from_port = 23
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
# Allow ports within range
ingress {
to_port = 32000
from_port = 5052
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
# Allow ports within range
ingress {
to_port = 21
from_port = 0
protocol = "udp"
cidr_blocks = ["0.0.0.0/0"]
}
# Allow ports within range
ingress {
to_port = 5050
from_port = 23
protocol = "udp"
cidr_blocks = ["0.0.0.0/0"]
}
# Allow ports within range
ingress {
to_port = 32000
from_port = 5052
protocol = "udp"
cidr_blocks = ["0.0.0.0/0"]
}
# full access internally
ingress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["10.0.0.0/8"]
}
# full access internally
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["10.0.0.0/8"]
}
tags {
KubernetesCluster = "${var.kubernetes_cluster}"
}
}
# A security group for Admins to control access
resource "aws_security_group" "remote-http-https" {
provider = "aws.bursted-vpc"
name = "http-https-security-group"
description = "Administrators can manage their machines"
vpc_id = "${aws_vpc.bursted_region.id}"
# http access from anywhere
ingress {
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["${var.admin_cidr}"]
}
# httpS access from anywhere
ingress {
from_port = 443
to_port = 443
protocol = "tcp"
cidr_blocks = ["${var.admin_cidr}"]
}
}
# A security group for any machine to download artifacts from the web
# without this, an agent cannot get internet access to pull containers
# This does not expose any ports locally, just external access.
resource "aws_security_group" "remote-internet-outbound" {
provider = "aws.bursted-vpc"
name = "internet-outbound-only-access"
description = "Security group to control outbound internet access only."
vpc_id = "${aws_vpc.bursted_region.id}"
# outbound internet access
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}
# Create DCOS Mesos Agent Scripts to execute
module "dcos-remote-mesos-agent" {
source = "github.com/dcos/tf_dcos_core"
bootstrap_private_ip = "${aws_instance.bootstrap.private_ip}"
dcos_install_mode = "${var.state}"
dcos_version = "${var.dcos_version}"
dcos_type = "${var.dcos_type}"
role = "dcos-mesos-agent"
}
# Provide tested AMI and user from listed region startup commands
module "aws-tested-oses-bursted" {
source = "./modules/dcos-tested-aws-oses"
os = "${var.os}"
region = "${var.aws_remote_region}"
}