Skip to content

Commit 1a21b3f

Browse files
author
Michael Brewer
authored
fix(feature-toggles): correct cdk example (#601)
1 parent 4318ac9 commit 1a21b3f

File tree

1 file changed

+59
-51
lines changed

1 file changed

+59
-51
lines changed

docs/utilities/feature_flags.md

+59-51
Original file line numberDiff line numberDiff line change
@@ -110,59 +110,67 @@ The following sample infrastructure will be used throughout this documentation:
110110

111111
=== "CDK"
112112

113-
```python hl_lines="13-29 31 33 37 41 47"
114-
import json
115-
116-
import aws_cdk.aws_appconfig as appconfig
117-
from aws_cdk import core
113+
```python hl_lines="11-22 24 29 35 42 50"
114+
import json
115+
116+
import aws_cdk.aws_appconfig as appconfig
117+
from aws_cdk import core
118+
119+
120+
class SampleFeatureFlagStore(core.Construct):
121+
def __init__(self, scope: core.Construct, id_: str) -> None:
122+
super().__init__(scope, id_)
123+
124+
features_config = {
125+
"premium_features": {
126+
"default": False,
127+
"rules": {
128+
"customer tier equals premium": {
129+
"when_match": True,
130+
"conditions": [{"action": "EQUALS", "key": "tier", "value": "premium"}],
131+
}
132+
},
133+
},
134+
"ten_percent_off_campaign": {"default": True},
135+
}
118136

137+
self.config_app = appconfig.CfnApplication(
138+
self,
139+
id="app",
140+
name="product-catalogue",
141+
)
142+
self.config_env = appconfig.CfnEnvironment(
143+
self,
144+
id="env",
145+
application_id=self.config_app.ref,
146+
name="dev-env",
147+
)
148+
self.config_profile = appconfig.CfnConfigurationProfile(
149+
self,
150+
id="profile",
151+
application_id=self.config_app.ref,
152+
location_uri="hosted",
153+
name="features",
154+
)
155+
self.hosted_cfg_version = appconfig.CfnHostedConfigurationVersion(
156+
self,
157+
"version",
158+
application_id=self.config_app.ref,
159+
configuration_profile_id=self.config_profile.ref,
160+
content=json.dumps(features_config),
161+
content_type="application/json",
162+
)
163+
self.app_config_deployment = appconfig.CfnDeployment(
164+
self,
165+
id="deploy",
166+
application_id=self.config_app.ref,
167+
configuration_profile_id=self.config_profile.ref,
168+
configuration_version=self.hosted_cfg_version.ref,
169+
deployment_strategy_id="AppConfig.AllAtOnce",
170+
environment_id=self.config_env.ref,
171+
)
119172

120-
class SampleFeatureFlagStore(core.Construct):
121-
122-
def __init__(self, scope: core.Construct, id_: str) -> None:
123-
super().__init__(scope, id_)
124-
125-
features_config = {
126-
"premium_features": {
127-
"default": False,
128-
"rules": {
129-
"customer tier equals premium": {
130-
"when_match": True,
131-
"conditions": [{
132-
"action": "EQUALS",
133-
"key": "tier",
134-
"value": "premium"
135-
}]
136-
}
137-
}
138-
},
139-
"ten_percent_off_campaign": {
140-
"default": True
141-
}
142-
}
143-
144-
self.config_app = appconfig.CfnApplication(self, id='app', name="product-catalogue")
145-
146-
self.config_env = appconfig.CfnEnvironment(self, id='env',
147-
application_id=self.config_app.ref,
148-
name="dev-env")
149-
150-
self.config_profile = appconfig.CfnConfigurationProfile(self, id='profile',
151-
application_id=self.config_app.ref,
152-
location_uri='hosted', name="features")
153-
154-
self.hosted_cfg_version = appconfig.CfnHostedConfigurationVersion(self, 'version',
155-
application_id=self.config_app.ref,
156-
configuration_profile_id=self.config_profile.ref,
157-
content=json_dumps(features_config),
158-
content_type='application/json')
159-
160-
self.app_config_deployment = appconfig.CfnDeployment(self, id='deploy', application_id=self.config_app.ref,
161-
configuration_profile_id=self.config_profile.ref,
162-
configuration_version=self.hosted_cfg_version.ref,
163-
deployment_strategy_id="AppConfig.AllAtOnce",
164-
environment_id=self.config_env.ref)
165-
```
173+
```
166174

167175
### Evaluating a single feature flag
168176

0 commit comments

Comments
 (0)