-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.py
68 lines (55 loc) · 2.13 KB
/
app.py
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
#!/usr/bin/env python3
import os
import aws_cdk as cdk
from web_analytics import (
KdsProxyApiGwStack,
KdsStack,
FirehoseDataTransformLambdaStack,
FirehoseStack,
MergeSmallFilesLambdaStack,
AthenaWorkGroupStack,
AthenaNamedQueryStack,
VpcStack,
GlueCatalogDatabaseStack,
DataLakePermissionsStack
)
AWS_ENV = cdk.Environment(account=os.getenv('CDK_DEFAULT_ACCOUNT'),
region=os.getenv('CDK_DEFAULT_REGION'))
app = cdk.App()
vpc_stack = VpcStack(app, 'WebAnalyticsVpc',
env=AWS_ENV)
kds_proxy_apigw = KdsProxyApiGwStack(app, 'WebAnalyticsKdsProxyApiGw')
kds_stack = KdsStack(app, 'WebAnalyticsKinesisStream')
firehose_data_transform_lambda = FirehoseDataTransformLambdaStack(app,
'WebAnalyticsFirehoseDataTransformLambda')
firehose_data_transform_lambda.add_dependency(vpc_stack)
firehose_stack = FirehoseStack(app, 'WebAnalyticsFirehose',
kds_stack.target_kinesis_stream.stream_arn,
firehose_data_transform_lambda.schema_validator_lambda_fn)
firehose_stack.add_dependency(kds_stack)
firehose_stack.add_dependency(firehose_data_transform_lambda)
athena_work_group_stack = AthenaWorkGroupStack(app,
'WebAnalyticsAthenaWorkGroup'
)
athena_work_group_stack.add_dependency(firehose_stack)
merge_small_files_stack = MergeSmallFilesLambdaStack(app,
'WebAnalyticsMergeSmallFiles',
firehose_stack.s3_dest_bucket_name,
firehose_stack.s3_dest_folder_name,
athena_work_group_stack.athena_work_group_name
)
merge_small_files_stack.add_dependency(athena_work_group_stack)
athena_databases = GlueCatalogDatabaseStack(app, 'WebAnalyticsGlueDatabases')
athena_databases.add_dependency(merge_small_files_stack)
lakeformation_grant_permissions = DataLakePermissionsStack(app, 'WebAnalyticsGrantLFPermissionsOnMergeFilesJob',
merge_small_files_stack.lambda_exec_role
)
lakeformation_grant_permissions.add_dependency(athena_databases)
athena_named_query_stack = AthenaNamedQueryStack(app,
'WebAnalyticsAthenaNamedQueries',
athena_work_group_stack.athena_work_group_name,
merge_small_files_stack.s3_json_location,
merge_small_files_stack.s3_parquet_location
)
athena_named_query_stack.add_dependency(lakeformation_grant_permissions)
app.synth()