-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathapp.py
95 lines (79 loc) · 3.27 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
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
#!/usr/bin/env python3
# -*- encoding: utf-8 -*-
# vim: tabstop=2 shiftwidth=2 softtabstop=2 expandtab
import os
import aws_cdk as cdk
from data_analytics_system import (
VpcStack,
BastionHostStack,
KinesisDataStreamStack,
# ElasticSearchStack,
##XXX: For using Amazon OpenSearch Service, remove comments from both the below code
OpenSearchStack,
KinesisFirehoseStack,
UpsertToESStack,
MergeSmallFilesLambdaStack,
GlueCatalogDatabaseStack,
DataLakePermissionsStack
)
ACCOUNT = os.getenv('CDK_DEFAULT_ACCOUNT', '')
REGION = os.getenv('CDK_DEFAULT_REGION', 'us-east-1')
AWS_ENV = cdk.Environment(account=ACCOUNT, region=REGION)
app = cdk.App()
vpc_stack = VpcStack(app, 'DataAnalyticsVpcStack',
env=AWS_ENV)
bastion_host_stack = BastionHostStack(app, 'DataAnalyticsBastionHostStack',
vpc_stack.vpc,
#XXX: YOU SHOULD pass `region` and `account` values in the `env` of the StackProps
# in order to prevent the following error:
# Cross stack references are only supported for stacks deployed
# to the same environment or between nested stacks and their parent stack
env=AWS_ENV)
bastion_host_stack.add_dependency(vpc_stack)
kds_stack = KinesisDataStreamStack(app, 'DataAnalyticsKinesisStreamStack')
kds_stack.add_dependency(vpc_stack)
firehose_stack = KinesisFirehoseStack(app, 'DataAnalyticsFirehoseStack',
kds_stack.kinesis_stream)
firehose_stack.add_dependency(kds_stack)
# search_stack = ElasticSearchStack(app, 'DataAnalyticsElasticSearchStack',
# vpc_stack.vpc,
# bastion_host_stack.sg_bastion_host,
# #XXX: YOU SHOULD pass `region` and `account` values in the `env` of the StackProps
# # in order to prevent the following error:
# # Cross stack references are only supported for stacks deployed
# # to the same environment or between nested stacks and their parent stack
# env=AWS_ENV)
#XXX: For using Amazon OpenSearch Service,
# remove comments from both the below codes and the dependent codes,
# then comments out `search_stack = ElasticSearchStack(...)` codes
#
search_stack = OpenSearchStack(app, 'DataAnalyticsOpenSearchStack',
vpc_stack.vpc,
bastion_host_stack.sg_bastion_host,
#XXX: YOU SHOULD pass `region` and `account` values in the `env` of the StackProps
# in order to prevent the following error:
# Cross stack references are only supported for stacks deployed
# to the same environment or between nested stacks and their parent stack
env=AWS_ENV)
search_stack.add_dependency(firehose_stack)
upsert_to_es_stack = UpsertToESStack(app, 'DataAnalyticsUpsertToESStack',
vpc_stack.vpc,
kds_stack.kinesis_stream,
search_stack.sg_search_client,
search_stack.search_domain_endpoint,
search_stack.search_domain_arn,
env=AWS_ENV
)
upsert_to_es_stack.add_dependency(search_stack)
merge_small_files_stack = MergeSmallFilesLambdaStack(app, 'DataAnalyticsMergeSmallFilesStack',
firehose_stack.s3_bucket_name
)
merge_small_files_stack.add_dependency(upsert_to_es_stack)
athena_databases = GlueCatalogDatabaseStack(app, 'DataAnalyticsGlueDatabases')
athena_databases.add_dependency(merge_small_files_stack)
lakeformation_grant_permissions = DataLakePermissionsStack(app,
'DataAnalyticsGrantLFPermissionsOnMergeFilesJob',
merge_small_files_stack.lambda_exec_role
)
lakeformation_grant_permissions.add_dependency(athena_databases)
app.synth()