forked from aws-powertools/powertools-lambda-python
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcdk_app.py
58 lines (53 loc) · 1.9 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
50
51
52
53
54
55
56
57
58
import json
import aws_cdk.aws_appconfig as appconfig
from aws_cdk import core
class SampleFeatureFlagStore(core.Construct):
def __init__(self, scope: core.Construct, id_: str) -> None:
super().__init__(scope, id_)
features_config = {
"premium_features": {
"default": False,
"rules": {
"customer tier equals premium": {
"when_match": True,
"conditions": [{"action": "EQUALS", "key": "tier", "value": "premium"}],
}
},
},
"ten_percent_off_campaign": {"default": True},
}
self.config_app = appconfig.CfnApplication(
self,
id="app",
name="product-catalogue",
)
self.config_env = appconfig.CfnEnvironment(
self,
id="env",
application_id=self.config_app.ref,
name="dev-env",
)
self.config_profile = appconfig.CfnConfigurationProfile(
self,
id="profile",
application_id=self.config_app.ref,
location_uri="hosted",
name="features",
)
self.hosted_cfg_version = appconfig.CfnHostedConfigurationVersion(
self,
"version",
application_id=self.config_app.ref,
configuration_profile_id=self.config_profile.ref,
content=json.dumps(features_config),
content_type="application/json",
)
self.app_config_deployment = appconfig.CfnDeployment(
self,
id="deploy",
application_id=self.config_app.ref,
configuration_profile_id=self.config_profile.ref,
configuration_version=self.hosted_cfg_version.ref,
deployment_strategy_id="AppConfig.AllAtOnce",
environment_id=self.config_env.ref,
)