@@ -52,21 +52,21 @@ The following sample infrastructure will be used throughout this documentation:
52
52
FeatureStoreApp:
53
53
Type: AWS::AppConfig::Application
54
54
Properties:
55
- Description: "AppConfig Appliction for feature toggles"
56
- Name: my-app
55
+ Description: "AppConfig Application for feature toggles"
56
+ Name: product-catalogue
57
57
58
58
FeatureStoreDevEnv:
59
59
Type: AWS::AppConfig::Environment
60
60
Properties:
61
61
ApplicationId: !Ref FeatureStoreApp
62
62
Description: "Development Environment for the App Config Store"
63
- Name: "development"
63
+ Name: dev
64
64
65
65
FeatureStoreConfigProfile:
66
66
Type: AWS::AppConfig::ConfigurationProfile
67
67
Properties:
68
68
ApplicationId: !Ref FeatureStoreApp
69
- Name: "MyTestProfile"
69
+ Name: features
70
70
LocationUri: "hosted"
71
71
72
72
HostedConfigVersion:
@@ -110,69 +110,58 @@ The following sample infrastructure will be used throughout this documentation:
110
110
111
111
=== "CDK"
112
112
113
- ```typescript hl_lines="2-7 13-32 34-35 40 47 54"
114
- import * as cdk from '@aws-cdk/core';
115
- import {
116
- CfnApplication,
117
- CfnConfigurationProfile, CfnDeployment,
118
- CfnEnvironment,
119
- CfnHostedConfigurationVersion
120
- } from "@aws-cdk/aws-appconfig";
113
+ ```python hl_lines="13-29 31 33 37 41 47"
114
+ import json
121
115
122
- export class CdkStack extends cdk.Stack {
123
- constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
124
- super(scope, id, props);
116
+ import aws_cdk.aws_appconfig as appconfig
117
+ from aws_cdk import core
125
118
126
- const featureConfig = {
119
+
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 = {
127
126
"premium_features": {
128
- "default": false ,
127
+ "default": False ,
129
128
"rules": {
130
129
"customer tier equals premium": {
131
- "when_match": true,
132
- "conditions": [
133
- {
134
- "action": "EQUALS",
135
- "key": "tier",
136
- "value": "premium"
137
- }
138
- ]
130
+ "when_match": True,
131
+ "conditions": [{
132
+ "action": "EQUALS",
133
+ "key": "tier",
134
+ "value": "premium"
135
+ }]
139
136
}
140
137
}
141
138
},
142
139
"ten_percent_off_campaign": {
143
- "default": true
140
+ "default": True
144
141
}
145
142
}
146
-
147
- const app = new CfnApplication(this, "app", {name: "productapp"});
148
- const env = new CfnEnvironment(this, "env", {
149
- applicationId: app.ref,
150
- name: "dev-env"
151
- });
152
-
153
- const configProfile = new CfnConfigurationProfile(this, "profile", {
154
- applicationId: app.ref,
155
- locationUri: "hosted",
156
- name: "configProfile"
157
- });
158
-
159
-
160
- const hostedConfigVersion = new CfnHostedConfigurationVersion(this, "version", {
161
- applicationId: app.ref,
162
- configurationProfileId: configProfile.ref,
163
- content: JSON.stringify(featureConfig),
164
- contentType: "application/json"
165
- });
166
-
167
- new CfnDeployment(this, "deploy", {
168
- applicationId: app.ref,
169
- configurationProfileId: configProfile.ref,
170
- configurationVersion: hostedConfigVersion.ref,
171
- deploymentStrategyId: "AppConfig.AllAtOnce",
172
- environmentId: env.ref
173
- });
174
- }
175
- }
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)
176
165
```
177
166
178
167
### Evaluating a single feature flag
0 commit comments