3
3
// implemented behind a flag in order to preserve backwards compatibility for
4
4
// existing apps. When a new app is initialized through `cdk init`, the CLI will
5
5
// automatically add enable these features by adding them to the generated
6
- // `cdk.json` file. In the next major release of the CDK, these feature flags
7
- // will be removed and will become the default behavior.
6
+ // `cdk.json` file.
7
+ //
8
+ // Some of these flags only affect the behavior of the construct library --
9
+ // these will be removed in the next major release and the behavior they are
10
+ // gating will become the only behavior.
11
+ //
12
+ // Other flags also affect the generated CloudFormation templates, in a way
13
+ // that prevents seamless upgrading. In the next major version, their
14
+ // behavior will become the default, but the flag still exists so users can
15
+ // switch it *off* in order to revert to the old behavior. These flags
16
+ // are marked with with the [PERMANENT] tag below.
17
+ //
8
18
// See https://github.com/aws/aws-cdk-rfcs/blob/master/text/0055-feature-flags.md
9
19
// --------------------------------------------------------------------------------
10
20
@@ -31,6 +41,8 @@ export const ENABLE_DIFF_NO_FAIL = ENABLE_DIFF_NO_FAIL_CONTEXT;
31
41
32
42
/**
33
43
* Switch to new stack synthesis method which enable CI/CD
44
+ *
45
+ * [PERMANENT]
34
46
*/
35
47
export const NEW_STYLE_STACK_SYNTHESIS_CONTEXT = '@aws-cdk/core:newStyleStackSynthesis' ;
36
48
@@ -41,6 +53,8 @@ export const NEW_STYLE_STACK_SYNTHESIS_CONTEXT = '@aws-cdk/core:newStyleStackSyn
41
53
* ensure uniqueness, and makes the export names robust against refactoring
42
54
* the location of the stack in the construct tree (specifically, moving the Stack
43
55
* into a Stage).
56
+ *
57
+ * [PERMANENT]
44
58
*/
45
59
export const STACK_RELATIVE_EXPORTS_CONTEXT = '@aws-cdk/core:stackRelativeExports' ;
46
60
@@ -116,6 +130,8 @@ export const ECS_REMOVE_DEFAULT_DESIRED_COUNT = '@aws-cdk/aws-ecs-patterns:remov
116
130
*
117
131
* This feature flag make correct the ServerlessCluster.clusterArn when
118
132
* clusterIdentifier contains a Upper case letters.
133
+ *
134
+ * [PERMANENT]
119
135
*/
120
136
export const RDS_LOWERCASE_DB_IDENTIFIER = '@aws-cdk/aws-rds:lowercaseDbIdentifier' ;
121
137
@@ -132,6 +148,8 @@ export const RDS_LOWERCASE_DB_IDENTIFIER = '@aws-cdk/aws-rds:lowercaseDbIdentifi
132
148
*
133
149
* In effect, there is no way to get out of this mess in a backwards compatible way, while supporting existing stacks.
134
150
* This flag changes the logical id layout of UsagePlanKey to not be sensitive to order.
151
+ *
152
+ * [PERMANENT]
135
153
*/
136
154
export const APIGATEWAY_USAGEPLANKEY_ORDERINSENSITIVE_ID = '@aws-cdk/aws-apigateway:usagePlanKeyOrderInsensitiveId' ;
137
155
@@ -150,13 +168,17 @@ export const EFS_DEFAULT_ENCRYPTION_AT_REST = '@aws-cdk/aws-efs:defaultEncryptio
150
168
* not constitute creating a new Version.
151
169
*
152
170
* See 'currentVersion' section in the aws-lambda module's README for more details.
171
+ *
172
+ * [PERMANENT]
153
173
*/
154
174
export const LAMBDA_RECOGNIZE_VERSION_PROPS = '@aws-cdk/aws-lambda:recognizeVersionProps' ;
155
175
156
176
/**
157
177
* Enable this feature flag to have cloudfront distributions use the security policy TLSv1.2_2021 by default.
158
178
*
159
179
* The security policy can also be configured explicitly using the `minimumProtocolVersion` property.
180
+ *
181
+ * [PERMANENT]
160
182
*/
161
183
export const CLOUDFRONT_DEFAULT_SECURITY_POLICY_TLS_V1_2_2021 = '@aws-cdk/aws-cloudfront:defaultSecurityPolicyTLSv1.2_2021' ;
162
184
@@ -167,6 +189,8 @@ export const CLOUDFRONT_DEFAULT_SECURITY_POLICY_TLS_V1_2_2021 = '@aws-cdk/aws-cl
167
189
* of unnecessary regions included in stacks without a known region.
168
190
*
169
191
* The type of this value should be a list of strings.
192
+ *
193
+ * [PERMANENT]
170
194
*/
171
195
export const TARGET_PARTITIONS = '@aws-cdk/core:target-partitions' ;
172
196
@@ -175,6 +199,8 @@ export const TARGET_PARTITIONS = '@aws-cdk/core:target-partitions';
175
199
* `awslogs` log driver for the application container of the service to send the container logs to CloudWatch Logs.
176
200
*
177
201
* This is a feature flag as the new behavior provides a better default experience for the users.
202
+ *
203
+ * [PERMANENT]
178
204
*/
179
205
export const ECS_SERVICE_EXTENSIONS_ENABLE_DEFAULT_LOG_DRIVER = '@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver' ;
180
206
@@ -190,15 +216,11 @@ export const ECS_SERVICE_EXTENSIONS_ENABLE_DEFAULT_LOG_DRIVER = '@aws-cdk-contai
190
216
export const EC2_UNIQUE_IMDSV2_LAUNCH_TEMPLATE_NAME = '@aws-cdk/aws-ec2:uniqueImdsv2TemplateName' ;
191
217
192
218
/**
193
- * This map includes context keys and values for feature flags that enable
194
- * capabilities "from the future", which we could not introduce as the default
195
- * behavior due to backwards compatibility for existing projects.
196
- *
197
- * New projects generated through `cdk init` will include these flags in their
198
- * generated `cdk.json` file.
219
+ * Flag values that should apply for new projects
199
220
*
200
- * When we release the next major version of the CDK, we will flip the logic of
201
- * these features and clean up the `cdk.json` generated by `cdk init`.
221
+ * Add a flag in here (typically with the value `true`), to enable
222
+ * backwards-breaking behavior changes only for new projects. New projects
223
+ * generated through `cdk init` will include these flags in their generated
202
224
*
203
225
* Tests must cover the default (disabled) case and the future (enabled) case.
204
226
*/
@@ -218,9 +240,6 @@ export const FUTURE_FLAGS: { [key: string]: boolean } = {
218
240
[ CLOUDFRONT_DEFAULT_SECURITY_POLICY_TLS_V1_2_2021 ] : true ,
219
241
[ ECS_SERVICE_EXTENSIONS_ENABLE_DEFAULT_LOG_DRIVER ] : true ,
220
242
[ EC2_UNIQUE_IMDSV2_LAUNCH_TEMPLATE_NAME ] : true ,
221
-
222
- // We will advertise this flag when the feature is complete
223
- // [NEW_STYLE_STACK_SYNTHESIS_CONTEXT]: 'true',
224
243
} ;
225
244
226
245
/**
@@ -238,28 +257,17 @@ export const FUTURE_FLAGS_EXPIRED: string[] = [
238
257
] ;
239
258
240
259
/**
241
- * The set of defaults that should be applied if the feature flag is not
242
- * explicitly configured.
260
+ * The default values of each of these flags.
261
+ *
262
+ * This is the effective value of the flag, unless it's overriden via
263
+ * context.
264
+ *
265
+ * Adding new flags here is only allowed during the pre-release period of a new
266
+ * major version!
243
267
*/
244
268
const FUTURE_FLAGS_DEFAULTS : { [ key : string ] : boolean } = {
245
- [ APIGATEWAY_USAGEPLANKEY_ORDERINSENSITIVE_ID ] : false ,
246
- [ ENABLE_STACK_NAME_DUPLICATES_CONTEXT ] : false ,
247
- [ ENABLE_DIFF_NO_FAIL_CONTEXT ] : false ,
248
- [ STACK_RELATIVE_EXPORTS_CONTEXT ] : false ,
249
- [ NEW_STYLE_STACK_SYNTHESIS_CONTEXT ] : false ,
250
- [ DOCKER_IGNORE_SUPPORT ] : false ,
251
- [ SECRETS_MANAGER_PARSE_OWNED_SECRET_NAME ] : false ,
252
- [ KMS_DEFAULT_KEY_POLICIES ] : false ,
253
- [ S3_GRANT_WRITE_WITHOUT_ACL ] : false ,
254
- [ ECS_REMOVE_DEFAULT_DESIRED_COUNT ] : false ,
255
- [ RDS_LOWERCASE_DB_IDENTIFIER ] : false ,
256
- [ EFS_DEFAULT_ENCRYPTION_AT_REST ] : false ,
257
- [ LAMBDA_RECOGNIZE_VERSION_PROPS ] : false ,
258
- [ CLOUDFRONT_DEFAULT_SECURITY_POLICY_TLS_V1_2_2021 ] : false ,
259
- [ ECS_SERVICE_EXTENSIONS_ENABLE_DEFAULT_LOG_DRIVER ] : false ,
260
- [ EC2_UNIQUE_IMDSV2_LAUNCH_TEMPLATE_NAME ] : false ,
261
269
} ;
262
270
263
- export function futureFlagDefault ( flag : string ) : boolean | undefined {
264
- return FUTURE_FLAGS_DEFAULTS [ flag ] ;
271
+ export function futureFlagDefault ( flag : string ) : boolean {
272
+ return FUTURE_FLAGS_DEFAULTS [ flag ] ?? false ;
265
273
}
0 commit comments