-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.tf
452 lines (397 loc) · 17.8 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
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
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
locals {
naming_suffix = "apps-${var.naming_suffix}"
}
module "external_tableau" {
source = "github.com/UKHomeOffice/dq-tf-external-tableau"
acp_prod_ingress_cidr = "10.5.0.0/16"
dq_ops_ingress_cidr = var.route_table_cidr_blocks["ops_cidr"]
dq_external_dashboard_subnet = "10.1.14.0/24"
peering_cidr_block = "10.3.0.0/16"
apps_vpc_id = aws_vpc.appsvpc.id
route_table_id = aws_route_table.apps_route_table.id
az = var.az
naming_suffix = local.naming_suffix
s3_archive_bucket_name = aws_s3_bucket.data_archive_bucket.id
s3_archive_bucket = aws_s3_bucket.data_archive_bucket.arn
s3_carrier_portal_docs = aws_s3_bucket.carrier_portal_docs.arn
s3_archive_bucket_key = aws_kms_key.bucket_key.arn
haproxy_private_ip = var.haproxy_private_ip
haproxy_private_ip2 = var.haproxy_private_ip2
environment = var.namespace
haproxy_config_bucket = var.haproxy_config_bucket
haproxy_config_bucket_key = var.haproxy_config_bucket_key
account_id = var.account_id
}
# module "ec2_alarms_ext_tableau" {
# source = "github.com/UKHomeOffice/dq-tf-cloudwatch-ec2"
# naming_suffix = local.naming_suffix
# environment = var.namespace
# pipeline_name = "ext-tableau"
# ec2_instance_id = module.external_tableau.ext_tab_inst_id
# }
module "internal_tableau" {
source = "github.com/UKHomeOffice/dq-tf-internal-tableau"
acp_prod_ingress_cidr = "10.5.0.0/16"
dq_ops_ingress_cidr = var.route_table_cidr_blocks["ops_cidr"]
dq_internal_dashboard_subnet_cidr = "10.1.12.0/24"
dq_internal_dashboard_subnet_cidr_az2 = "10.1.13.0/24"
peering_cidr_block = "10.3.0.0/16"
apps_vpc_id = aws_vpc.appsvpc.id
route_table_id = aws_route_table.apps_route_table.id
az = var.az
az2 = var.az2
naming_suffix = local.naming_suffix
s3_archive_bucket_name = aws_s3_bucket.data_archive_bucket.id
s3_archive_bucket = aws_s3_bucket.data_archive_bucket.arn
s3_archive_bucket_key = aws_kms_key.bucket_key.arn
haproxy_private_ip = var.haproxy_private_ip
haproxy_private_ip2 = var.haproxy_private_ip2
environment = var.namespace
s3_httpd_config_bucket = var.s3_httpd_config_bucket
s3_httpd_config_bucket_key = var.s3_httpd_config_bucket_key
security_group_ids = module.lambda.lambda_sgrp
lambda_subnet = module.lambda.lambda_subnet
lambda_subnet_az2 = module.lambda.lambda_subnet_az2
rds_enhanced_monitoring_role = aws_iam_role.rds_enhanced_monitoring_role.arn
account_id = var.account_id
}
module "data_feeds" {
source = "github.com/UKHomeOffice/dq-tf-datafeeds"
appsvpc_id = aws_vpc.appsvpc.id
opssubnet_cidr_block = var.route_table_cidr_blocks["ops_cidr"]
data_feeds_cidr_block = "10.1.4.0/24"
data_feeds_cidr_block_az2 = "10.1.5.0/24"
peering_cidr_block = "10.3.0.0/16"
az = var.az
az2 = var.az2
lambda_subnet = module.lambda.lambda_subnet
lambda_subnet_az2 = module.lambda.lambda_subnet_az2
lambda_sgrp = module.lambda.lambda_sgrp
naming_suffix = local.naming_suffix
route_table_id = aws_route_table.apps_route_table.id
rds_enhanced_monitoring_role = aws_iam_role.rds_enhanced_monitoring_role.arn
environment = var.namespace
}
module "data_ingest" {
source = "github.com/UKHomeOffice/dq-tf-dataingest"
naming_suffix = local.naming_suffix
logging_bucket_id = aws_s3_bucket.log_archive_bucket.id
archive_bucket = aws_s3_bucket.data_archive_bucket.arn
archive_bucket_name = aws_s3_bucket.data_archive_bucket.id
apps_buckets_kms_key = aws_kms_key.bucket_key.arn
environment = var.namespace
}
module "lambda" {
source = "github.com/UKHomeOffice/dq-tf-lambda"
appsvpc_id = aws_vpc.appsvpc.id
dq_lambda_subnet_cidr = "10.1.42.0/24"
dq_lambda_subnet_cidr_az2 = "10.1.43.0/24"
az = var.az
az2 = var.az2
naming_suffix = local.naming_suffix
route_table_id = aws_route_table.apps_route_table.id
}
module "acl_oag_nats_ingest_monitor" {
source = "github.com/UKHomeOffice/dq-tf-acl-oag-nats-ingest-monitor"
naming_suffix = local.naming_suffix
namespace = var.namespace
}
module "tableau_backup_monitor" {
source = "github.com/UKHomeOffice/dq-tf-tableau-backup-monitor"
naming_suffix = local.naming_suffix
namespace = var.namespace
}
module "airports_pipeline" {
source = "git::ssh://git@gitlab.digital.homeoffice.gov.uk:2222/dacc-dq/dq-tf-airports-pipeline.git"
kms_key_s3 = aws_kms_key.bucket_key.arn
kms_key_glue = data.aws_kms_key.glue.arn
lambda_subnet = module.lambda.lambda_subnet
lambda_subnet_az2 = module.lambda.lambda_subnet_az2
lambda_sgrp = module.lambda.lambda_sgrp
rds_db_name = var.rds_db_name
rds_address = module.internal_tableau.rds_internal_tableau_address
lambda_slack = module.ops_pipeline.lambda_slack
naming_suffix = local.naming_suffix
namespace = var.namespace
}
module "airports_input_pipeline" {
source = "git::ssh://git@gitlab.digital.homeoffice.gov.uk:2222/dacc-dq/dq-tf-airports-input.git"
kms_key_s3 = aws_kms_key.bucket_key.arn
kms_key_glue = data.aws_kms_key.glue.arn
lambda_slack = module.ops_pipeline.lambda_slack
naming_suffix = local.naming_suffix
namespace = var.namespace
}
module "oag_input_pipeline" {
source = "git::ssh://git@gitlab.digital.homeoffice.gov.uk:2222/dacc-dq/dq-tf-oag-input-pipeline.git"
kms_key_s3 = aws_kms_key.bucket_key.arn
lambda_slack = module.ops_pipeline.lambda_slack
naming_suffix = local.naming_suffix
namespace = var.namespace
}
module "oag_transform_pipeline" {
source = "git::ssh://git@gitlab.digital.homeoffice.gov.uk:2222/dacc-dq/dq-tf-oag-transform-pipeline.git"
kms_key_s3 = aws_kms_key.bucket_key.arn
naming_suffix = local.naming_suffix
lambda_slack = module.ops_pipeline.lambda_slack
namespace = var.namespace
}
module "acl_input_pipeline" {
source = "git::ssh://git@gitlab.digital.homeoffice.gov.uk:2222/dacc-dq/dq-tf-acl-input-pipeline.git"
kms_key_s3 = aws_kms_key.bucket_key.arn
naming_suffix = local.naming_suffix
lambda_slack = module.ops_pipeline.lambda_slack
namespace = var.namespace
}
module "reference_data_pipeline" {
source = "git::ssh://git@gitlab.digital.homeoffice.gov.uk:2222/dacc-dq/dq-tf-reference-data-pipeline.git"
kms_key_s3 = aws_kms_key.bucket_key.arn
lambda_slack = module.ops_pipeline.lambda_slack
naming_suffix = local.naming_suffix
namespace = var.namespace
}
module "consolidated_schedule_pipeline" {
source = "git::ssh://git@gitlab.digital.homeoffice.gov.uk:2222/dacc-dq/dq-tf-consolidated-schedule-pipeline.git"
kms_key_s3 = aws_kms_key.bucket_key.arn
lambda_slack = module.ops_pipeline.lambda_slack
naming_suffix = local.naming_suffix
namespace = var.namespace
}
module "cdlz" {
source = "git::ssh://git@gitlab.digital.homeoffice.gov.uk:2222/dacc-dq/dq-tf-cdlz.git"
kms_key_s3 = aws_kms_key.bucket_key.arn
lambda_slack = module.ops_pipeline.lambda_slack
naming_suffix = local.naming_suffix
namespace = var.namespace
}
module "api_input_pipeline" {
source = "git::ssh://git@gitlab.digital.homeoffice.gov.uk:2222/dacc-dq/dq-tf-api-input-pipeline.git"
kms_key_s3 = aws_kms_key.bucket_key.arn
lambda_slack = module.ops_pipeline.lambda_slack
naming_suffix = local.naming_suffix
namespace = var.namespace
}
module "api_record_level_score_pipeline" {
source = "git::ssh://git@gitlab.digital.homeoffice.gov.uk:2222/dacc-dq/dq-tf-api-record-level-score-pipeline.git"
kms_key_s3 = aws_kms_key.bucket_key.arn
lambda_slack = module.ops_pipeline.lambda_slack
naming_suffix = local.naming_suffix
namespace = var.namespace
}
module "api_cross_record_scored_pipeline" {
source = "git::ssh://git@gitlab.digital.homeoffice.gov.uk:2222/dacc-dq/dq-tf-api-cross-record-score-pipeline.git"
kms_key_s3 = aws_kms_key.bucket_key.arn
lambda_slack = module.ops_pipeline.lambda_slack
naming_suffix = local.naming_suffix
namespace = var.namespace
}
module "gait_pipeline" {
source = "git::ssh://git@gitlab.digital.homeoffice.gov.uk:2222/dacc-dq/dq-tf-gait-pipeline.git"
kms_key_s3 = aws_kms_key.bucket_key.arn
lambda_slack = module.ops_pipeline.lambda_slack
naming_suffix = local.naming_suffix
namespace = var.namespace
}
module "internal_reporting_pipeline" {
source = "git::ssh://git@gitlab.digital.homeoffice.gov.uk:2222/dacc-dq/dq-tf-internal-reporting-pipeline.git"
lambda_subnet = module.lambda.lambda_subnet
lambda_subnet_az2 = module.lambda.lambda_subnet_az2
lambda_sgrp = module.lambda.lambda_sgrp
rds_db_name = var.rds_db_name
rds_internal_tableau_address = module.internal_tableau.rds_internal_tableau_address
kms_key_s3 = aws_kms_key.bucket_key.arn
lambda_slack = module.ops_pipeline.lambda_slack
naming_suffix = local.naming_suffix
namespace = var.namespace
}
module "rds_deploy" {
source = "git::ssh://git@gitlab.digital.homeoffice.gov.uk:2222/dacc-dq/dq-tf-rds-deploy.git"
lambda_subnet = module.lambda.lambda_subnet
lambda_subnet_az2 = module.lambda.lambda_subnet_az2
lambda_sgrp = module.lambda.lambda_sgrp
rds_internal_tableau_address = module.internal_tableau.rds_internal_tableau_address
rds_fms_address = module.fms.rds_address
rds_datafeed_address = module.data_feeds.rds_address
naming_suffix = local.naming_suffix
namespace = var.naming_suffix
rds_internal_tableau_staging_address = module.internal_tableau.rds_internal_tableau_staging_endpoint
}
module "fms_pipeline" {
source = "git::ssh://git@gitlab.digital.homeoffice.gov.uk:2222/dacc-dq/dq-tf-fms-pipeline.git"
lambda_subnet = module.lambda.lambda_subnet
lambda_subnet_az2 = module.lambda.lambda_subnet_az2
lambda_sgrp = module.lambda.lambda_sgrp
rds_address = module.fms.rds_address
kms_key_s3 = aws_kms_key.bucket_key.arn
lambda_slack = module.ops_pipeline.lambda_slack
naming_suffix = local.naming_suffix
namespace = var.namespace
}
module "drt_pipeline" {
source = "git::ssh://git@gitlab.digital.homeoffice.gov.uk:2222/dacc-dq/dq-tf-drt-pipeline.git"
lambda_subnet = module.lambda.lambda_subnet
lambda_subnet_az2 = module.lambda.lambda_subnet_az2
lambda_sgrp = module.lambda.lambda_sgrp
rds_address = module.data_feeds.rds_address
kms_key_s3 = aws_kms_key.bucket_key.arn
lambda_slack = module.ops_pipeline.lambda_slack
naming_suffix = local.naming_suffix
namespace = var.namespace
}
module "mds_extractor" {
source = "git::ssh://git@gitlab.digital.homeoffice.gov.uk:2222/dacc-dq/dq-tf-mds-extractor.git"
lambda_subnet = module.lambda.lambda_subnet
lambda_subnet_az2 = module.lambda.lambda_subnet_az2
lambda_sgrp = module.lambda.lambda_sgrp
kms_key_s3 = aws_kms_key.bucket_key.arn
naming_suffix = local.naming_suffix
namespace = var.namespace
}
module "raw_file_index" {
source = "git::ssh://git@gitlab.digital.homeoffice.gov.uk:2222/dacc-dq/dq-tf-raw-file-index.git"
kms_key_s3 = aws_kms_key.bucket_key.arn
lambda_subnet = module.lambda.lambda_subnet
lambda_subnet_az2 = module.lambda.lambda_subnet_az2
lambda_sgrp = module.lambda.lambda_sgrp
rds_db_name = var.rds_db_name
rds_address = module.internal_tableau.rds_internal_tableau_address
lambda_slack = module.ops_pipeline.lambda_slack
naming_suffix = local.naming_suffix
namespace = var.namespace
}
module "fms" {
source = "github.com/UKHomeOffice/dq-tf-fms"
appsvpc_id = aws_vpc.appsvpc.id
opssubnet_cidr_block = var.route_table_cidr_blocks["ops_cidr"]
fms_cidr_block = "10.1.40.0/24"
fms_cidr_block_az2 = "10.1.41.0/24"
peering_cidr_block = "10.3.0.0/16"
az = var.az
az2 = var.az2
naming_suffix = local.naming_suffix
route_table_id = aws_route_table.apps_route_table.id
rds_enhanced_monitoring_role = aws_iam_role.rds_enhanced_monitoring_role.arn
environment = var.namespace
}
module "ops_pipeline" {
source = "git::ssh://git@gitlab.digital.homeoffice.gov.uk:2222/dacc-dq/dq-tf-pipeline-ops.git"
kms_key_s3 = aws_kms_key.bucket_key.arn
lambda_subnet = module.lambda.lambda_subnet
lambda_subnet_az2 = module.lambda.lambda_subnet_az2
lambda_sgrp = module.lambda.lambda_sgrp
rds_internal_tableau_address = module.internal_tableau.rds_internal_tableau_address
rds_fms_address = module.fms.rds_address
rds_datafeed_address = module.data_feeds.rds_address
naming_suffix = local.naming_suffix
namespace = var.namespace
athena_maintenance_bucket = var.athena_maintenance_bucket
dq_pipeline_ops_readwrite_bucket_list = var.dq_pipeline_ops_readwrite_bucket_list
}
module "dailytasks" {
source = "github.com/UKHomeOffice/dq-tf-dailytasks"
naming_suffix = local.naming_suffix
namespace = var.namespace
}
module "nats_internal_pipeline" {
source = "git::ssh://git@gitlab.digital.homeoffice.gov.uk:2222/dacc-dq/dq-tf-fpl-pipeline.git"
naming_suffix = local.naming_suffix
namespace = var.namespace
}
module "cdlz_bitd_input" {
source = "git::ssh://git@gitlab.digital.homeoffice.gov.uk:2222/dacc-dq/dq-tf-btid-cdlz-pipeline.git"
kms_key_s3 = aws_kms_key.bucket_key.arn
lambda_slack = module.ops_pipeline.lambda_slack
naming_suffix = local.naming_suffix
lambda_subnet = module.lambda.lambda_subnet
lambda_subnet_az2 = module.lambda.lambda_subnet_az2
lambda_sgrp = module.lambda.lambda_sgrp
namespace = var.namespace
}
module "kpi_accuracy_scoring" {
source = "git::ssh://git@gitlab.digital.homeoffice.gov.uk:2222/dacc-dq/dq-tf-kpi-accuracy-scoring-pipeline.git"
lambda_slack = module.ops_pipeline.lambda_slack
naming_suffix = local.naming_suffix
namespace = var.namespace
}
module "api_rls_xrs_reconciliation" {
source = "git::ssh://git@gitlab.digital.homeoffice.gov.uk:2222/dacc-dq/dq-tf-api-rls-xrs-reconcilation.git"
naming_suffix = local.naming_suffix
namespace = var.namespace
}
resource "aws_vpc" "appsvpc" {
cidr_block = var.cidr_block
enable_dns_hostnames = true
tags = {
Name = "vpc-${local.naming_suffix}"
}
}
resource "aws_route_table" "apps_route_table" {
vpc_id = aws_vpc.appsvpc.id
tags = {
Name = "route-table-${local.naming_suffix}"
}
}
resource "aws_route" "ops" {
route_table_id = aws_route_table.apps_route_table.id
destination_cidr_block = var.route_table_cidr_blocks["ops_cidr"]
vpc_peering_connection_id = var.vpc_peering_connection_ids["peering_to_ops"]
}
resource "aws_route" "peering" {
route_table_id = aws_route_table.apps_route_table.id
destination_cidr_block = var.route_table_cidr_blocks["peering_cidr"]
vpc_peering_connection_id = var.vpc_peering_connection_ids["peering_to_peering"]
}
resource "aws_route" "nat" {
route_table_id = aws_route_table.apps_route_table.id
destination_cidr_block = "0.0.0.0/0"
nat_gateway_id = aws_nat_gateway.appsnatgw.id
}
resource "aws_route_table" "apps_public_route_table" {
vpc_id = aws_vpc.appsvpc.id
tags = {
Name = "public-route-table-${local.naming_suffix}"
}
}
resource "aws_route" "igw" {
route_table_id = aws_route_table.apps_public_route_table.id
destination_cidr_block = "0.0.0.0/0"
gateway_id = aws_internet_gateway.AppsRouteToInternet.id
}
resource "aws_eip" "appseip" {
domain = "vpc"
}
resource "aws_nat_gateway" "appsnatgw" {
allocation_id = aws_eip.appseip.id
subnet_id = aws_subnet.public_subnet.id
tags = {
Name = "natgw-${local.naming_suffix}"
}
}
resource "aws_internet_gateway" "AppsRouteToInternet" {
vpc_id = aws_vpc.appsvpc.id
tags = {
Name = "igw-${local.naming_suffix}"
}
}
resource "aws_subnet" "public_subnet" {
vpc_id = aws_vpc.appsvpc.id
cidr_block = var.public_subnet_cidr_block
map_public_ip_on_launch = false
availability_zone = var.az
tags = {
Name = "public-subnet-${local.naming_suffix}"
}
}
resource "aws_route_table_association" "public_subnet" {
subnet_id = aws_subnet.public_subnet.id
route_table_id = aws_route_table.apps_public_route_table.id
}
resource "aws_default_security_group" "default" {
vpc_id = aws_vpc.appsvpc.id
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}