-
Notifications
You must be signed in to change notification settings - Fork 14
/
cdk_app.py
49 lines (36 loc) · 1.36 KB
/
cdk_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
#!/usr/bin/env python3
import os
from aws_cdk import App, Environment, Tags
from cdk_stacks.stacks.code_deploy import EECodeDeployment
from cdk_stacks.stacks.command_runner import EEOncePerTagCommandRunner
from cdk_stacks.stacks.image_builder import EEImageUpdater
from cdk_stacks.stacks.power_off_at_end_of_day import PowerOffAtEndOfDay
valid_environments = (
"development",
"staging",
"production",
)
app_wide_context = {}
if dc_env := os.environ.get("DC_ENVIRONMENT"):
app_wide_context["dc-environment"] = dc_env
app = App(context=app_wide_context)
env = Environment(account=os.getenv("CDK_DEFAULT_ACCOUNT"), region="eu-west-2")
# Set the DC Environment early on. This is important to be able to conditionally
# change the stack configurations
dc_environment = app.node.try_get_context("dc-environment") or None
assert (
dc_environment in valid_environments
), f"context `dc-environment` must be one of {valid_environments}"
if dc_environment == "production":
EEImageUpdater(
app,
"EEImageUpdater",
env=env,
)
EECodeDeployment(app, "EECodeDeployment", env=env)
EEOncePerTagCommandRunner(app, "EEOncePerTagCommandRunner", env=env)
if dc_environment != "production":
PowerOffAtEndOfDay(app, "PowerOffAtEndOfDay", env=env)
Tags.of(app).add("dc-product", "ee")
Tags.of(app).add("dc-environment", dc_environment)
app.synth()