forked from dcos-terraform/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
172 lines (136 loc) · 4.78 KB
/
main.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
provider "aws" {
region = "us-east-1"
alias = "master"
}
provider "aws" {
region = "us-west-2"
alias = "us-west-2"
}
provider "aws" {
region = "eu-west-1"
alias = "eu-west-1"
}
data "http" "whatismyip" {
url = "http://whatismyip.akamai.com/"
}
// lets define variables which are shared between all regions
locals {
ssh_public_key_file = "~/.ssh/id_rsa.pub"
cluster_name = "remotetest"
dcos_license_key_contents = "${file("~/license.txt")}"
dcos_variant = "ee"
dcos_version = "1.13.3"
region_networks = {
// dont use 172.17/26 as its used by docker.
"master" = "172.16.0.0/16" // this is the default
"us-west-2" = "10.128.0.0/16"
"eu-west-1" = "10.129.0.0/16"
}
allowed_internal_networks = ["${values(local.region_networks)}"]
}
############################################################
# main region holding masters
############################################################
module "dcos" {
source = "dcos-terraform/dcos/aws"
version = "~> 0.2.0"
providers = {
aws = "aws.master"
}
subnet_range = "${local.region_networks["master"]}"
num_masters = 1
num_private_agents = 1
num_public_agents = 1
dcos_instance_os = "centos_7.5"
bootstrap_instance_type = "m4.xlarge"
bootstrap_root_volume_type = "gp2"
// accepted_internal_networks is holding a list of internal use networks.
// They will be
accepted_internal_networks = "${local.allowed_internal_networks}"
cluster_name = "${local.cluster_name}"
ssh_public_key_file = "${local.ssh_public_key_file}"
admin_ips = ["${data.http.whatismyip.body}/32"]
dcos_license_key_contents = "${local.dcos_license_key_contents}"
dcos_variant = "${local.dcos_variant}"
dcos_version = "${local.dcos_version}"
#ansible related config
ansible_bundled_container = "fatz/dcos-ansible-bundle:additional-vars"
ansible_additional_config = <<EOF
foo: bar
bar: baz
EOF
# add additional agents to install run
additional_private_agent_ips = ["${concat(module.dcos-usw2.private_agents.private_ips,module.dcos-euw1.private_agents.private_ips)}"]
}
############################################################
# us-west-2 region having agents
############################################################
module "dcos-usw2" {
source = "dcos-terraform/infrastructure/aws"
version = "~> 0.2.0"
admin_ips = ["${data.http.whatismyip.body}/32"]
name_prefix = "usw2"
cluster_name = "${local.cluster_name}"
accepted_internal_networks = "${local.allowed_internal_networks}"
num_masters = 0
num_private_agents = 1
num_public_agents = 0
lb_disable_public_agents = true
lb_disable_masters = true
ssh_public_key_file = "${local.ssh_public_key_file}"
subnet_range = "${local.region_networks["us-west-2"]}"
providers = {
aws = "aws.us-west-2"
}
}
# connect to master region
module "vpc-connection-master-usw2" {
source = "dcos-terraform/vpc-peering/aws" // module init the peering
version = "~> 0.2.0"
providers = {
"aws.local" = "aws.master"
"aws.remote" = "aws.us-west-2"
}
local_vpc_id = "${module.dcos.infrastructure.vpc_id}"
local_subnet_range = "${local.region_networks["master"]}"
remote_vpc_id = "${module.dcos-usw2.vpc.id}"
remote_subnet_range = "${local.region_networks["us-west-2"]}"
}
############################################################
# eu-west-1 region having agents
############################################################
module "dcos-euw1" {
source = "dcos-terraform/infrastructure/aws"
version = "~> 0.2.0"
admin_ips = ["${data.http.whatismyip.body}/32"]
name_prefix = "euw1"
cluster_name = "${local.cluster_name}"
accepted_internal_networks = "${local.allowed_internal_networks}"
num_masters = 0
num_private_agents = 1
num_public_agents = 0
lb_disable_public_agents = true
lb_disable_masters = true
ssh_public_key_file = "${local.ssh_public_key_file}"
subnet_range = "${local.region_networks["eu-west-1"]}"
providers = {
aws = "aws.eu-west-1"
}
}
# connect to master region
module "vpc-connection-master-euw1" {
source = "dcos-terraform/vpc-peering/aws" // module init the peering
version = "~> 0.2.0"
providers = {
"aws.local" = "aws.master"
"aws.remote" = "aws.eu-west-1"
}
local_vpc_id = "${module.dcos.infrastructure.vpc_id}"
local_subnet_range = "${local.region_networks["master"]}"
remote_vpc_id = "${module.dcos-euw1.vpc.id}"
remote_subnet_range = "${local.region_networks["eu-west-1"]}"
}
output "masters_dns_name" {
description = "This is the load balancer address to access the DC/OS UI"
value = "${module.dcos.masters-loadbalancer}"
}