-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
64 lines (49 loc) · 1.86 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
#!/usr/bin/env python3
# -*- encoding: utf-8 -*-
# vim: tabstop=2 shiftwidth=2 softtabstop=2 expandtab
import os
import aws_cdk as cdk
from saas_metering_demo import (
KinesisFirehoseStack,
RandomGenApiStack,
VpcStack,
AthenaWorkGroupStack,
AthenaNamedQueryStack,
MergeSmallFilesLambdaStack,
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, 'SaaSMeteringDemoVpc',
env=AWS_ENV)
firehose_stack = KinesisFirehoseStack(app, 'RandomGenApiLogToFirehose')
firehose_stack.add_dependency(vpc_stack)
random_gen_apigw = RandomGenApiStack(app, 'RandomGenApiGw', firehose_stack.firehose_arn)
random_gen_apigw.add_dependency(firehose_stack)
athena_work_group_stack = AthenaWorkGroupStack(app,
'SaaSMeteringAthenaWorkGroup'
)
athena_work_group_stack.add_dependency(random_gen_apigw)
merge_small_files_stack = MergeSmallFilesLambdaStack(app,
'RestApiAccessLogMergeSmallFiles',
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, 'GlueDatabasesOnAccessLogs')
athena_databases.add_dependency(merge_small_files_stack)
lakeformation_grant_permissions = DataLakePermissionsStack(app, 'GrantLFPermissionsOnMergeFilesJob',
merge_small_files_stack.lambda_exec_role
)
lakeformation_grant_permissions.add_dependency(athena_databases)
athena_named_query_stack = AthenaNamedQueryStack(app,
'SaaSMeteringAthenaNamedQueries',
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()