-
Notifications
You must be signed in to change notification settings - Fork 1
/
modules-cluster1.tf
437 lines (384 loc) · 13.4 KB
/
modules-cluster1.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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
########## Active Active Db Redis Enterprise Clusters between 2 regions (Cluster 1) #####
#### Modules to create the following:
#### Brand new VPC in region A
#### VPC peering requestor from region A to VPC in region B
#### VPC peering acceptor from region B to region A
#### Route table VPC peering id association for VPC A
#### Cluster A, RE nodes and install RE software (ubuntu)
#### VPC A, Test node with Redis and Memtier
#### Cluster A, DNS (NS and A records for RE nodes)
#### Cluster A, Create and Join RE cluster
#### Create CRDB DB between Cluster A & Cluster B
#### Run Memtier benchmark data load and benchmark cmd from tester node in VPC A to Cluster A
########### VPC Module
#### create a brand new VPC, use its outputs in future modules
#### If you already have an existing VPC, comment out and
#### enter your VPC params in the future modules
module "vpc1" {
source = "./modules/vpc"
providers = {
aws = aws.a
}
aws_creds = var.aws_creds
owner = var.owner
region = var.region1
base_name = var.base_name1
vpc_cidr = var.vpc_cidr1
subnet_cidr_blocks = var.subnet_cidr_blocks1
subnet_azs = var.subnet_azs1
}
### VPC outputs
### Outputs from VPC outputs.tf,
### must output here to use in future modules)
output "subnet-ids1" {
value = module.vpc1.subnet-ids
}
output "vpc-id1" {
value = module.vpc1.vpc-id
}
output "vpc_name1" {
description = "get the VPC Name tag"
value = module.vpc1.vpc-name
}
output "route-table-id1" {
description = "route table id"
value = module.vpc1.route-table-id
}
########### Security Group Module
#### create a security group
module "security-group1" {
source = "./modules/security-group"
providers = {
aws = aws.a
}
owner = var.owner
vpc_cidr = var.vpc_cidr1
allow-public-ssh = var.allow-public-ssh
open-nets = var.open-nets
### vars pulled from previous modules
## from vpc module outputs
vpc_name = module.vpc1.vpc-name
vpc_id = module.vpc1.vpc-id
depends_on = [
module.vpc1
]
}
output "aws_security_group_id1" {
description = "aws security group"
value = module.security-group1.aws_security_group_id
}
######
#### VPC Peering Modules
#### VPC peering is broken into 2 modules because you need to
#### request from region A (provider A), and accept from region B (provider B)
#### Final step is to do a route table association to the VPC peering ID
#### VPC peering requestor from region A (VPC A) to region B (VPC B)
module "vpc-peering-requestor" {
source = "./modules/vpc-peering-requestor"
providers = {
aws = aws.a
}
peer_region = var.region2
main_vpc_id = module.vpc1.vpc-id
peer_vpc_id = module.vpc2.vpc-id
vpc_name1 = module.vpc1.vpc-name
vpc_name2 = module.vpc2.vpc-name
owner = var.owner
depends_on = [
module.vpc1, module.vpc2
]
}
#### output the vpc peering ID to use in acceptor module
output "vpc_peering_connection_id" {
description = "VPC peering connection ID"
value = module.vpc-peering-requestor.vpc_peering_connection_id
}
#### VPC peering acceptor, accept from region B (VPC B) to region A (VPC A)
module "vpc-peering-acceptor" {
source = "./modules/vpc-peering-acceptor"
providers = {
aws = aws.b
}
vpc_peering_connection_id = module.vpc-peering-requestor.vpc_peering_connection_id
depends_on = [
module.vpc1, module.vpc2, module.vpc-peering-requestor
]
}
#### Route table association in reigon A (VPC A) for vpc peering id to VPC CIDR in Region B
module "vpc-peering-routetable1" {
source = "./modules/vpc-peering-routetable"
providers = {
aws = aws.a
}
peer_vpc_id = module.vpc2.vpc-id
main_vpc_route_table_id = module.vpc1.route-table-id
vpc_peering_connection_id = module.vpc-peering-requestor.vpc_peering_connection_id
peer_vpc_cidr = var.vpc_cidr2
depends_on = [
module.vpc1,
module.vpc2,
module.vpc-peering-requestor,
module.vpc-peering-acceptor
]
}
####################################
########### Node Redis Enterprise Module
#### Create the nodes that will be used for Redis Enterprise
#### Just create the nodes and associated infra.
#### configure them and install RE in the config module.
module "nodes-re1" {
source = "./modules/nodes"
providers = {
aws = aws.a
}
owner = var.owner
region = var.region1
vpc_cidr = var.vpc_cidr1
subnet_azs = var.subnet_azs1
ssh_key_name = var.ssh_key_name1
ssh_key_path = var.ssh_key_path1
node-count = var.data-node-count
ec2_instance_type = var.re_instance_type
node-prefix = var.node-prefix-re
ebs-volume-size = var.re-volume-size
create_ebs_volumes = var.create_ebs_volumes_re
### vars pulled from previous modules
security_group_id = module.security-group1.aws_security_group_id
## from vpc module outputs
vpc_name = module.vpc1.vpc-name
vpc_subnets_ids = module.vpc1.subnet-ids
vpc_id = module.vpc1.vpc-id
depends_on = [
module.vpc1,
module.security-group1
]
}
#### Node Outputs to use in future modules
output "re-data-node-eips1" {
value = module.nodes-re1.node-eips
}
output "re-data-node-internal-ips1" {
value = module.nodes-re1.node-internal-ips
}
output "re-data-node-eip-public-dns1" {
value = module.nodes-re1.node-eip-public-dns
}
####################################
########### Node Module
#### Create Test nodes
#### Create the test nodes and their associated infra
#### configure them and install RE in the config module.
module "nodes-tester1" {
source = "./modules/nodes"
providers = {
aws = aws.a
}
owner = var.owner
region = var.region1
vpc_cidr = var.vpc_cidr1
subnet_azs = var.subnet_azs1
ssh_key_name = var.ssh_key_name1
ssh_key_path = var.ssh_key_path1
node-count = var.test-node-count
node-prefix = var.node-prefix-tester
ec2_instance_type = var.test_instance_type
#ebs-volume-size = var.re-volume-size
create_ebs_volumes = var.create_ebs_volumes_tester
### vars pulled from previous modules
security_group_id = module.security-group1.aws_security_group_id
## from vpc module outputs
vpc_name = module.vpc1.vpc-name
vpc_subnets_ids = module.vpc1.subnet-ids
vpc_id = module.vpc1.vpc-id
depends_on = [
module.vpc1,
module.security-group1
]
}
#### Node Outputs to use in future modules
output "test-node-eips1" {
value = module.nodes-tester1.node-eips
}
output "test-node-internal-ips1" {
value = module.nodes-tester1.node-internal-ips
}
output "test-node-eip-public-dns1" {
value = module.nodes-tester1.node-eip-public-dns
}
#####################################
#### Configure Redis Enterprise nodes
#### Ansible playbooks configure and install RE software on nodes
module "nodes-config-re-1" {
source = "./modules/nodes-config-re"
providers = {
aws = aws.a
}
ssh_key_name = var.ssh_key_name1
ssh_key_path = var.ssh_key_path1
re_download_url = var.re_download_url
data-node-count = var.data-node-count
### vars pulled from previous modules
## from vpc module outputs
vpc_name = module.vpc1.vpc-name
vpc_id = module.vpc1.vpc-id
aws_eips = module.nodes-re1.node-eips
depends_on = [
module.nodes-re1
]
}
#### Create Test nodes
#### Ansible playbooks configure Test node with Redis and Memtier
module "nodes-config-redisoss-1" {
source = "./modules/nodes-config-redisoss"
providers = {
aws = aws.a
}
ssh_key_name = var.ssh_key_name1
ssh_key_path = var.ssh_key_path1
test_instance_type = var.test_instance_type
test-node-count = var.test-node-count
### vars pulled from previous modules
## from vpc module outputs
vpc_name = module.vpc1.vpc-name
vpc_id = module.vpc1.vpc-id
aws_eips = module.nodes-tester1.node-eips
depends_on = [
module.nodes-tester1
]
}
########### DNS Module
#### Create DNS (NS record, A records for each RE node and its eip)
#### Currently using existing dns hosted zone
module "dns1" {
source = "./modules/dns"
providers = {
aws = aws.a
}
dns_hosted_zone_id = var.dns_hosted_zone_id
data-node-count = var.data-node-count
### vars pulled from previous modules
vpc_name = module.vpc1.vpc-name
re-data-node-eips = module.nodes-re1.node-eips
}
#### dns FQDN output used in future modules
output "dns-ns-record-name1" {
value = module.dns1.dns-ns-record-name
}
############## RE Cluster
#### Ansible Playbook runs locally to create the cluster A
module "create-cluster1" {
source = "./modules/re-cluster"
providers = {
aws = aws.a
}
ssh_key_path = var.ssh_key_path1
region = var.region1
re_cluster_username = var.re_cluster_username
re_cluster_password = var.re_cluster_password
flash_enabled = var.flash_enabled
rack_awareness = var.rack_awareness
### vars pulled from previous modules
vpc_name = module.vpc1.vpc-name
re-node-internal-ips = module.nodes-re1.node-internal-ips
re-node-eip-ips = module.nodes-re1.node-eips
re-data-node-eip-public-dns = module.nodes-re1.node-eip-public-dns
dns_fqdn = module.dns1.dns-ns-record-name
depends_on = [
module.vpc1,
module.nodes-re1,
module.nodes-config-re-1,
module.dns1]
}
#### Cluster Outputs
output "re-cluster-url" {
value = module.create-cluster1.re-cluster-url
}
output "re-cluster-username" {
value = module.create-cluster1.re-cluster-username
}
output "re-cluster-password" {
value = module.create-cluster1.re-cluster-password
}
############## RE Cluster CRDB databases
#### Ansible Playbook runs locally to create the CRDB db between cluster A and B
module "create-crdbs" {
source = "./modules/re-crdb"
providers = {
aws = aws.a
}
re_cluster_username = var.re_cluster_username
re_cluster_password = var.re_cluster_password
dns_fqdn1 = module.dns1.dns-ns-record-name
dns_fqdn2 = module.dns2.dns-ns-record-name #getting cluster2 name from other module
#### crdb db inputs
crdb_db_name = var.crdb_db_name
crdb_port = var.crdb_port
crdb_db_password = var.crdb_db_password
crdb_memory_size = var.crdb_memory_size
crdb_replication = var.crdb_replication
crdb_aof_policy = var.crdb_aof_policy
crdb_sharding = var.crdb_sharding
crdb_shards_count = var.crdb_shards_count
depends_on = [module.vpc1,
module.vpc2,
module.nodes-re1,
module.nodes-config-re-1,
module.nodes-re2,
module.nodes-config-re-2,
module.dns1,
module.dns2,
module.create-cluster1,
module.create-cluster2]
}
#### CRDB Outputs
output "crdb_endpoint_cluster1" {
value = module.create-crdbs.crdb_endpoint_cluster1
}
output "crdb_endpoint_cluster2" {
value = module.create-crdbs.crdb_endpoint_cluster2
}
output "crdb_cluster1_redis_cli_cmd" {
value = module.create-crdbs.crdb_cluster1_redis_cli_cmd
}
output "crdb_cluster2_redis_cli_cmd" {
value = module.create-crdbs.crdb_cluster2_redis_cli_cmd
}
############## RE Cluster CRDB databases memtier benchmark
#### Ansible Playbook runs locally to run the memtier benchmark cmds for cluster A
module "memtier_benchmark1" {
source = "./modules/re-crdb-memtier"
providers = {
aws = aws.a
}
test-node-count = var.test-node-count
vpc_name = module.vpc1.vpc-name
ssh_key_path = var.ssh_key_path1
crdb_port = var.crdb_port
crdb_endpoint_cluster = module.create-crdbs.crdb_endpoint_cluster1
#### memtier inputs (no need to include db endpoint, its auto added)
memtier_data_load_cluster = var.memtier_data_load_cluster1
memtier_benchmark_cmd = var.memtier_benchmark_cluster1
depends_on = [module.vpc1,
module.vpc2,
module.nodes-re1,
module.nodes-config-re-1,
module.nodes-config-redisoss-1,
module.nodes-re2,
module.nodes-config-re-2,
module.nodes-config-redisoss-2,
module.dns1,
module.dns2,
module.create-cluster1,
module.create-cluster2,
module.create-crdbs]
}
### outputs
output "crdb_cluster1_memtier-data-load-cmd" {
value = module.memtier_benchmark1.memtier-data-load-cmd
}
output "crdb_cluster1_memtier-benchmark-cmd" {
value = module.memtier_benchmark1.memtier-benchmark-cmd
}
output "crdb_cluster1_memtier-ansible-playbook-cmd" {
value = module.memtier_benchmark1.memtier-ansible-playbook-cmd
}