-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
38 lines (30 loc) · 1.19 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
#!/usr/bin/env python3
from aws_cdk import core
import json
from aws_cdk_python_dev_guide.aws_cdk_python_dev_guide_stack import AwsCdkPythonDevGuideStack
app = core.App()
core.Tags.of(app).add("app", "my-app-tag")
with open('stages.json') as stagesJson:
stages = json.load(stagesJson)
with open('regions.json') as regionsJson:
regions = json.load(regionsJson)
for name in stages:
stage = stages.get(name)
for regionKey in stage.get("regions"):
if regionKey:
region = regions.get(regionKey)
region_options = core.Environment(account=region.get("account"),
region=region.get("region"))
stack_name = f"AwsPythonStack-{name}-{regionKey}"
else:
# deploy region-agnostic when no region is specified
region_options = None
stack_name = f"AwsPythonStack-{name}"
stack_instance = AwsCdkPythonDevGuideStack(
app,
stack_name,
env=region_options,
origin=stage.get("origin"))
# this will add a stack tag to all stack components
core.Tags.of(stack_instance).add("stack-name", stack_name)
app.synth()