-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
466 lines (340 loc) · 18.9 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
453
454
455
456
457
458
459
460
461
462
463
464
465
466
variable "aws_profile" {}
variable "env_name" {}
variable "aws_region" {}
variable "aws_account" {}
variable "project_name" {}
variable "vpc_cidr_b" {}
// always_run for local-exec
variable "always_run-ecr-mlb-statsapi-etl-build" {}
variable "always_run-ecr-mlb-statsapi-etl-push" {}
variable "always_run-lambda-layer-mlb-statsapi" {}
variable "always_run-lambda-function-run-workflow" {}
variable "always_run-lambda-function-event-handler" {}
variable "always_run-lambda-sf-season-state-set-season" {}
variable "always_run-lambda-sf-gameday-state-date-in-season" {}
variable "always_run-lambda-sf-gameday-state-set-scheduled-games" {}
variable "always_run-lambda-sf-pregame-state-set-game" {}
terraform {
backend "s3" {
bucket = "power-edge-sports.terraform"
}
}
provider "aws" {
region = var.aws_region
}
locals {
always_run-ecr-mlb-statsapi-etl-build = coalesce(var.always_run-ecr-mlb-statsapi-etl-build, timestamp())
always_run-ecr-mlb-statsapi-etl-push = coalesce(var.always_run-ecr-mlb-statsapi-etl-push, timestamp())
always_run-lambda-layer-mlb-statsapi = coalesce(var.always_run-lambda-layer-mlb-statsapi, timestamp())
always_run-lambda-function-run-workflow = coalesce(var.always_run-lambda-function-run-workflow, timestamp())
always_run-lambda-function-event-handler = coalesce(var.always_run-lambda-function-event-handler, timestamp())
always_run-lambda-sf-season-state-set-season = coalesce(var.always_run-lambda-sf-season-state-set-season, timestamp())
always_run-lambda-sf-gameday-state-date-in-season = coalesce(var.always_run-lambda-sf-gameday-state-date-in-season, timestamp())
always_run-lambda-sf-gameday-state-set-scheduled-games = coalesce(var.always_run-lambda-sf-gameday-state-set-scheduled-games, timestamp())
always_run-lambda-sf-pregame-state-set-game = coalesce(var.always_run-lambda-sf-pregame-state-set-game, timestamp())
}
module "variables" {
source = "./tf/variables"
}
module "iam-logs-delivery-full-access-policy" {
source = "./tf/modules/iam/iam-logs-delivery-full-access-policy"
aws_region = var.aws_region
}
/*
module "s3-code-bucket" {
source = "./tf/modules/s3/s3-code-bucket"
env_name = var.env_name
aws_region = var.aws_region
}
*/
module "s3-data-bucket" {
source = "./tf/modules/s3/s3-data-bucket"
env_name = var.env_name
aws_region = var.aws_region
aws_account = var.aws_account
}
module "mlb-statsapi-vpc" {
source = "./tf/modules/vpc"
env_name = var.env_name
aws_profile = var.aws_profile
aws_account = var.aws_account
aws_region = var.aws_region
cidr_b = var.vpc_cidr_b
}
module "mlb-statsapi-event-notification" {
source = "./tf/modules/notifications/mlb-statsapi-event-notification"
aws_region = var.aws_region
}
module "mlb-statsapi-workflow-notification" {
source = "./tf/modules/notifications/mlb-statsapi-workflow-notification"
aws_region = var.aws_region
}
module "mlb-statsapi-pregame-forecast-notification" {
source = "./tf/modules/notifications/mlb-statsapi-pregame-forecast-notification"
aws_region = var.aws_region
env_name = var.env_name
}
module "ecr-mlb-statsapi-etl-repository" {
source = "./tf/modules/ecr/mlb-statsapi-etl"
env_name = var.env_name
aws_profile = var.aws_profile
aws_account = var.aws_account
aws_region = var.aws_region
tag_latest = true
always_run-ecr-mlb-statsapi-etl-build = local.always_run-ecr-mlb-statsapi-etl-build
always_run-ecr-mlb-statsapi-etl-push = local.always_run-ecr-mlb-statsapi-etl-push
build_version = module.variables.build
depends_on = [
module.variables
]
}
module "ecs-mlb-statsapi-etl-task" {
source = "./tf/modules/ecs/mlb-statsapi-etl"
env_name = var.env_name
aws_profile = var.aws_profile
aws_account = var.aws_account
aws_region = var.aws_region
build_version = module.variables.build
mlb_statsapi_etl_image-repository_name = module.ecr-mlb-statsapi-etl-repository.mlb_statsapi_etl_image-repository_name
mlb_statsapi_s3_data_bucket_service_policy-arn = module.s3-data-bucket.mlb_statsapi_s3_data_bucket_service_policy-arn
mlb_statsapi_sns_publish_event_policy-arn = module.mlb-statsapi-event-notification.mlb_statsapi_sns_publish_event_policy-arn
depends_on = [
module.variables,
module.ecr-mlb-statsapi-etl-repository,
module.s3-data-bucket
]
}
module "iam-sf_mlb_statsapi_etl_runTask-policy" {
source = "./tf/modules/iam/iam-sf_mlb_statsapi_etl_runTask-policy"
aws_region = var.aws_region
ecs_mlb_statsapi_etl-taskExecutionRole-arn = module.ecs-mlb-statsapi-etl-task.ecs_mlb_statsapi_etl-taskExecutionRole-arn
ecs_mlb_statsapi_etl-taskRole-arn = module.ecs-mlb-statsapi-etl-task.ecs_mlb_statsapi_etl-taskRole-arn
ecs_task_definition_mlb_statsapi_etl-arn = module.ecs-mlb-statsapi-etl-task.ecs_task_definition_mlb_statsapi_etl-arn
}
module "sf-mlb-statsapi-game" {
source = "./tf/modules/stepfunctions/sf-mlb-statsapi-game"
env_name = var.env_name
aws_profile = var.aws_profile
aws_account = var.aws_account
aws_region = var.aws_region
cloudwatch_logs_delivery_full_access_policy-arn = module.iam-logs-delivery-full-access-policy.cloudwatch_logs_delivery_full_access_policy-arn
sf_mlb_statsapi_etl_runTask_policy-arn = module.iam-sf_mlb_statsapi_etl_runTask-policy.sf_mlb_statsapi_etl_runTask_policy-arn
mlb_statsapi_sg-id = module.mlb-statsapi-vpc.mlb_statsapi_sg-id
subnet_public_ids = module.mlb-statsapi-vpc.subnet-public-ids
ecs_task_definition_mlb_statsapi_etl-arn = module.ecs-mlb-statsapi-etl-task.ecs_task_definition_mlb_statsapi_etl-arn
ecs_cluster_mlb_statsapi_etl-arn = module.ecs-mlb-statsapi-etl-task.ecs_cluster_mlb_statsapi_etl-arn
mlb_statsapi_etl_image-repository_name = module.ecr-mlb-statsapi-etl-repository.mlb_statsapi_etl_image-repository_name
mlb_statsapi_s3_data_bucket = module.s3-data-bucket.mlb_statsapi_s3_data_bucket
depends_on = [
module.iam-logs-delivery-full-access-policy,
module.iam-sf_mlb_statsapi_etl_runTask-policy,
module.mlb-statsapi-vpc,
module.ecs-mlb-statsapi-etl-task,
]
}
module "lambda-layer-mlb-statsapi" {
source = "./tf/modules/lambda-layer/mlb-statsapi-layer"
aws_region = var.aws_region
env_name = var.env_name
build_version = module.variables.build
always_run = local.always_run-lambda-layer-mlb-statsapi
depends_on = [
module.variables
]
}
module "lambda-sf-pregame-state-set-game" {
source = "./tf/modules/lambda-function/lambda-sf-pregame-state-set-game"
aws_region = var.aws_region
env_name = var.env_name
always_run = local.always_run-lambda-sf-pregame-state-set-game
build_version = module.variables.build
mlb_statsapi_lambda_layer_arn = module.lambda-layer-mlb-statsapi.mlb_statsapi_lambda_layer_arn
AWSLambdaBasicExecutionRole-arn = module.lambda-layer-mlb-statsapi.AWSLambdaBasicExecutionRole-arn
depends_on = [
module.variables,
module.lambda-layer-mlb-statsapi,
]
}
module "sf-mlb-statsapi-season" {
source = "./tf/modules/stepfunctions/sf-mlb-statsapi-season"
env_name = var.env_name
aws_profile = var.aws_profile
aws_account = var.aws_account
aws_region = var.aws_region
cloudwatch_logs_delivery_full_access_policy-arn = module.iam-logs-delivery-full-access-policy.cloudwatch_logs_delivery_full_access_policy-arn
sns_mlb_statsapi_event-arn = module.mlb-statsapi-event-notification.sns_mlb_statsapi_event-arn
mlb_statsapi_sns_publish_event_policy-arn = module.mlb-statsapi-event-notification.mlb_statsapi_sns_publish_event_policy-arn
depends_on = [
module.iam-logs-delivery-full-access-policy,
module.mlb-statsapi-event-notification,
]
}
module "sf-mlb-statsapi-pregame" {
source = "./tf/modules/stepfunctions/sf-mlb-statsapi-pregame"
env_name = var.env_name
aws_profile = var.aws_profile
aws_account = var.aws_account
aws_region = var.aws_region
cloudwatch_logs_delivery_full_access_policy-arn = module.iam-logs-delivery-full-access-policy.cloudwatch_logs_delivery_full_access_policy-arn
mlb_statsapi_sns_publish_event_policy-arn = module.mlb-statsapi-event-notification.mlb_statsapi_sns_publish_event_policy-arn
mlb_statsapi_sns_publish_workflow_policy-arn = module.mlb-statsapi-workflow-notification.mlb_statsapi_sns_publish_workflow_policy-arn
sns_mlb_statsapi_event-arn = module.mlb-statsapi-event-notification.sns_mlb_statsapi_event-arn
sns_mlb_statsapi_workflow-arn = module.mlb-statsapi-workflow-notification.sns_mlb_statsapi_workflow-arn
sns_mlb_statsapi_pregame_forecast-arn = module.mlb-statsapi-pregame-forecast-notification.sns_mlb_statsapi_pregame_forecast-arn
iam_policy_snsPublish_pregame_forecast-arn = module.mlb-statsapi-pregame-forecast-notification.iam_policy_snsPublish_pregame_forecast-arn
mlb_statsapi_states_pregame_set_game_lambda-arn = module.lambda-sf-pregame-state-set-game.mlb_statsapi_states_pregame_set_game_lambda-arn
sf_mlb_statsapi_etl_game-arn = module.sf-mlb-statsapi-game.sf_mlb_statsapi_etl_game-arn
mlb_statsapi_s3_data_bucket = module.s3-data-bucket.mlb_statsapi_s3_data_bucket
subnet_public_ids = module.mlb-statsapi-vpc.subnet-public-ids
mlb_statsapi_sg-id = module.mlb-statsapi-vpc.mlb_statsapi_sg-id
mlb_statsapi_etl_image-repository_name = module.ecr-mlb-statsapi-etl-repository.mlb_statsapi_etl_image-repository_name
ecs_cluster_mlb_statsapi_etl-arn = module.ecs-mlb-statsapi-etl-task.ecs_cluster_mlb_statsapi_etl-arn
ecs_task_definition_mlb_statsapi_etl-arn = module.ecs-mlb-statsapi-etl-task.ecs_task_definition_mlb_statsapi_etl-arn
sf_mlb_statsapi_etl_runTask_policy-arn = module.iam-sf_mlb_statsapi_etl_runTask-policy.sf_mlb_statsapi_etl_runTask_policy-arn
depends_on = [
module.iam-logs-delivery-full-access-policy,
module.mlb-statsapi-event-notification,
module.mlb-statsapi-workflow-notification,
module.lambda-sf-pregame-state-set-game,
module.sf-mlb-statsapi-game
]
}
module "lambda-sf-gameday-state-set-scheduled-games" {
source = "./tf/modules/lambda-function/lambda-sf-gameday-state-set-scheduled-games"
aws_region = var.aws_region
env_name = var.env_name
build_version = module.variables.build
always_run = local.always_run-lambda-sf-gameday-state-set-scheduled-games
mlb_statsapi_lambda_layer_arn = module.lambda-layer-mlb-statsapi.mlb_statsapi_lambda_layer_arn
AWSLambdaBasicExecutionRole-arn = module.lambda-layer-mlb-statsapi.AWSLambdaBasicExecutionRole-arn
sqs_mlb_statsapi_workflow-id = module.mlb-statsapi-workflow-notification.sqs_mlb_statsapi_workflow-id
sf_mlb_statsapi_etl_pregame-arn = module.sf-mlb-statsapi-pregame.sf_mlb_statsapi_etl_pregame-arn
depends_on = [
module.variables,
module.lambda-layer-mlb-statsapi,
module.mlb-statsapi-workflow-notification,
module.sf-mlb-statsapi-pregame,
]
}
module "sf-mlb-statsapi-schedule" {
source = "./tf/modules/stepfunctions/sf-mlb-statsapi-schedule"
env_name = var.env_name
aws_profile = var.aws_profile
aws_account = var.aws_account
aws_region = var.aws_region
cloudwatch_logs_delivery_full_access_policy-arn = module.iam-logs-delivery-full-access-policy.cloudwatch_logs_delivery_full_access_policy-arn
sf_mlb_statsapi_etl_runTask_policy-arn = module.iam-sf_mlb_statsapi_etl_runTask-policy.sf_mlb_statsapi_etl_runTask_policy-arn
mlb_statsapi_sg-id = module.mlb-statsapi-vpc.mlb_statsapi_sg-id
subnet_public_ids = module.mlb-statsapi-vpc.subnet-public-ids
mlb_statsapi_etl_image-repository_name = module.ecr-mlb-statsapi-etl-repository.mlb_statsapi_etl_image-repository_name
ecs_task_definition_mlb_statsapi_etl-arn = module.ecs-mlb-statsapi-etl-task.ecs_task_definition_mlb_statsapi_etl-arn
ecs_cluster_mlb_statsapi_etl-arn = module.ecs-mlb-statsapi-etl-task.ecs_cluster_mlb_statsapi_etl-arn
ecs_mlb_statsapi_etl-taskRole-arn = module.ecs-mlb-statsapi-etl-task.ecs_mlb_statsapi_etl-taskRole-arn
ecs_mlb_statsapi_etl-taskExecutionRole-arn = module.ecs-mlb-statsapi-etl-task.ecs_mlb_statsapi_etl-taskExecutionRole-arn
depends_on = [
module.iam-logs-delivery-full-access-policy,
module.iam-sf_mlb_statsapi_etl_runTask-policy,
module.mlb-statsapi-vpc,
module.ecr-mlb-statsapi-etl-repository,
module.ecs-mlb-statsapi-etl-task,
]
}
module "lambda-sf-gameday-state-date-in-season" {
source = "./tf/modules/lambda-function/lambda-sf-gameday-state-date-in-season"
aws_region = var.aws_region
env_name = var.env_name
build_version = module.variables.build
always_run = local.always_run-lambda-sf-gameday-state-date-in-season
mlb_statsapi_lambda_layer_arn = module.lambda-layer-mlb-statsapi.mlb_statsapi_lambda_layer_arn
AWSLambdaBasicExecutionRole-arn = module.lambda-layer-mlb-statsapi.AWSLambdaBasicExecutionRole-arn
depends_on = [
module.variables,
module.lambda-layer-mlb-statsapi,
]
}
module "sf-mlb-statsapi-gameday" {
source = "./tf/modules/stepfunctions/sf-mlb-statsapi-gameday"
env_name = var.env_name
aws_profile = var.aws_profile
aws_account = var.aws_account
aws_region = var.aws_region
mlb_statsapi_states_gameday_date_in_season_lambda-function_name = module.lambda-sf-gameday-state-date-in-season.mlb_statsapi_states_gameday_date_in_season_lambda-function_name
mlb_statsapi_states_gameday_date_in_season_lambda-arn = module.lambda-sf-gameday-state-date-in-season.mlb_statsapi_states_gameday_date_in_season_lambda-arn
mlb_statsapi_states_gameday_set_scheduled_games_lambda-function_name = module.lambda-sf-gameday-state-set-scheduled-games.mlb_statsapi_states_gameday_set_scheduled_games_lambda-function_name
mlb_statsapi_states_gameday_set_scheduled_games_lambda-arn = module.lambda-sf-gameday-state-set-scheduled-games.mlb_statsapi_states_gameday_set_scheduled_games_lambda-arn
cloudwatch_logs_delivery_full_access_policy-arn = module.iam-logs-delivery-full-access-policy.cloudwatch_logs_delivery_full_access_policy-arn
sns_mlb_statsapi_workflow-arn = module.mlb-statsapi-workflow-notification.sns_mlb_statsapi_workflow-arn
mlb_statsapi_sns_publish_workflow_policy-arn = module.mlb-statsapi-workflow-notification.mlb_statsapi_sns_publish_workflow_policy-arn
depends_on = [
module.lambda-sf-gameday-state-date-in-season,
module.lambda-sf-gameday-state-set-scheduled-games,
module.iam-logs-delivery-full-access-policy,
module.mlb-statsapi-workflow-notification,
]
}
module "lambda-function-run-workflow" {
source = "./tf/modules/lambda-function/lambda-function-run-workflow"
aws_region = var.aws_region
env_name = var.env_name
aws_account = var.aws_account
build_version = module.variables.build
always_run = local.always_run-lambda-function-run-workflow
mlb_statsapi_lambda_layer_arn = module.lambda-layer-mlb-statsapi.mlb_statsapi_lambda_layer_arn
AWSLambdaBasicExecutionRole-arn = module.lambda-layer-mlb-statsapi.AWSLambdaBasicExecutionRole-arn
sf_mlb_statsapi_etl_season-arn = module.sf-mlb-statsapi-season.sf_mlb_statsapi_etl_season-arn
sf_mlb_statsapi_etl_season-name = module.sf-mlb-statsapi-season.sf_mlb_statsapi_etl_season-name
sf_mlb_statsapi_etl_gameday-arn = module.sf-mlb-statsapi-gameday.sf_mlb_statsapi_etl_gameday-arn
sf_mlb_statsapi_etl_gameday-name = module.sf-mlb-statsapi-gameday.sf_mlb_statsapi_etl_gameday-name
sf_mlb_statsapi_etl_pregame-arn = module.sf-mlb-statsapi-pregame.sf_mlb_statsapi_etl_pregame-arn
sf_mlb_statsapi_etl_pregame-name = module.sf-mlb-statsapi-pregame.sf_mlb_statsapi_etl_pregame-name
sf_mlb_statsapi_etl_schedule-name = module.sf-mlb-statsapi-schedule.sf_mlb_statsapi_etl_schedule-name
sf_mlb_statsapi_etl_schedule-arn = module.sf-mlb-statsapi-schedule.sf_mlb_statsapi_etl_schedule-arn
sf_mlb_statsapi_etl_game-arn = module.sf-mlb-statsapi-game.sf_mlb_statsapi_etl_game-arn
sqs_mlb_statsapi_workflow-arn = module.mlb-statsapi-workflow-notification.sqs_mlb_statsapi_workflow-arn
sqs_mlb_statsapi_workflow-id = module.mlb-statsapi-workflow-notification.sqs_mlb_statsapi_workflow-id
sqs_mlb_statsapi_workflow-name = module.mlb-statsapi-workflow-notification.sqs_mlb_statsapi_workflow-name
depends_on = [
module.mlb-statsapi-workflow-notification,
module.lambda-layer-mlb-statsapi,
module.sf-mlb-statsapi-season,
module.sf-mlb-statsapi-gameday,
module.sf-mlb-statsapi-pregame,
module.sf-mlb-statsapi-schedule,
module.sf-mlb-statsapi-game
]
}
module "lambda-function-event-handler" {
source = "./tf/modules/lambda-function/lambda-function-event-handler"
aws_region = var.aws_region
env_name = var.env_name
aws_account = var.aws_account
build_version = module.variables.build
always_run = local.always_run-lambda-function-event-handler
mlb_statsapi_lambda_layer_arn = module.lambda-layer-mlb-statsapi.mlb_statsapi_lambda_layer_arn
AWSLambdaBasicExecutionRole-arn = module.lambda-layer-mlb-statsapi.AWSLambdaBasicExecutionRole-arn
mlb_statsapi_s3_data_bucket_service_policy-arn = module.s3-data-bucket.mlb_statsapi_s3_data_bucket_service_policy-arn
sqs_mlb_statsapi_event-arn = module.mlb-statsapi-event-notification.sqs_mlb_statsapi_event-arn
sqs_mlb_statsapi_event-id = module.mlb-statsapi-event-notification.sqs_mlb_statsapi_event-id
sqs_mlb_statsapi_event-name = module.mlb-statsapi-event-notification.sqs_mlb_statsapi_event-name
depends_on = [
module.variables,
module.lambda-layer-mlb-statsapi,
module.mlb-statsapi-event-notification,
module.s3-data-bucket,
]
}
output "env_name" {value = var.env_name}
output "aws_region" {value = var.aws_region}
output "project_name" {value = var.project_name}
output "vpc_cidr_b" {value = var.vpc_cidr_b}
output "always_run-ecr-mlb-statsapi-etl-build" {value = local.always_run-ecr-mlb-statsapi-etl-build}
output "always_run-ecr-mlb-statsapi-etl-push" {value = local.always_run-ecr-mlb-statsapi-etl-push}
output "always_run-lambda-layer-mlb-statsapi" {value = local.always_run-lambda-layer-mlb-statsapi}
output "always_run-lambda-function-run-workflow" {value = local.always_run-lambda-function-run-workflow}
output "always_run-lambda-function-event-handler" {value = local.always_run-lambda-function-event-handler}
output "always_run-lambda-sf-season-state-set-season" {value = local.always_run-lambda-sf-season-state-set-season}
output "always_run-lambda-sf-gameday-state-date-in-season" {value = local.always_run-lambda-sf-gameday-state-date-in-season}
output "always_run-lambda-sf-gameday-state-set-scheduled-games" {value = local.always_run-lambda-sf-gameday-state-set-scheduled-games}
output "always_run-lambda-sf-pregame-state-set-game" {value = local.always_run-lambda-sf-pregame-state-set-game}
output "sns_objectCreated_arn" {value = module.s3-data-bucket.sns_objectCreated_arn}
output "mlb_statsapi_s3_data_bucket_arn" {value = module.s3-data-bucket.mlb_statsapi_s3_data_bucket_arn}