8000 fix(lambda): disable aws-lambda:useCdkManagedLogGroup feature flag wh… · aws/aws-cdk@d696688 · GitHub
[go: up one dir, main page]

Skip to content

Commit d696688

Browse files
authored
fix(lambda): disable aws-lambda:useCdkManagedLogGroup feature flag when not set (#34613)
### Issue #34612 Closes #34612 ### Reason for this change `USE_CDK_MANAGED_LAMBDA_LOGGROUP` makes CDK create a new log group. This is not backwards compatible with older CDK versions where the log group already exists. ### Description of changes Change the default flag value to false ### Describe any new or updated permissions being added None ### Description of how you validated changes Ran integ tests ### Checklist - [X] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 484719e commit d696688

File tree

5 files changed

+28
-7
lines changed

5 files changed

+28
-7
lines changed

packages/aws-cdk-lib/aws-lambda/test/function.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5036,6 +5036,25 @@ describe('tag propagation to logGroup on FF USE_CDK_MANAGED_LAMBDA_LOGGROUP enab
50365036
});
50375037
});
50385038

5039+
describe('USE_CDK_MANAGED_LAMBDA_LOGGROUP defaults to false when not specified', () = 10000 > {
5040+
it('does not create a managed log group when context flag is not specified', () => {
5041+
// GIVEN
5042+
const app = new cdk.App(); // No context provided
5043+
const stack = new cdk.Stack(app, 'Stack');
5044+
5045+
// WHEN
5046+
new lambda.Function(stack, 'Function', {
5047+
code: lambda.Code.fromInline('exports.handler = async () => {};'),
5048+
handler: 'index.handler',
5049+
runtime: lambda.Runtime.NODEJS_20_X,
5050+
});
5051+
5052+
// THEN
5053+
const template = Template.fromStack(stack);
5054+
template.resourceCountIs('AWS::Logs::LogGroup', 0); // No log group should be created
5055+
});
5056+
});
5057+
50395058
describe('Lambda Function log group behavior', () => {
50405059
it('throws if both logRetention and logGroup are set', () => {
50415060
const app = new cdk.App();

packages/aws-cdk-lib/cx-api/FEATURE_FLAGS.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ The following json shows the current recommended set of flags, as `cdk init` wou
188188
"@aws-cdk/aws-stepfunctions:useDistributedMapResultWriterV2": true,
189189
"@aws-cdk/s3-notifications:addS3TrustKeyPolicyForSnsSubscriptions": true,
190190
"@aws-cdk/aws-ec2:requirePrivateSubnetsForEgressOnlyInternetGateway": true,
191-
"@aws-cdk/aws-s3:publicAccessBlockedByDefault": true
191+
"@aws-cdk/aws-s3:publicAccessBlockedByDefault": true,
192+
"@aws-cdk/aws-lambda:useCdkManagedLogGroup": true
192193
}
193194
}
194195
```
@@ -225,7 +226,6 @@ are migrating a v1 CDK project to v2, explicitly set any of these flags which do
225226

226227
| Flag | Summary | Type | Since | v1 default | v2 default |
227228
| ----- | ----- | ----- | ----- | ----- | ----- |
228-
| [@aws-cdk/aws-lambda:useCdkManagedLogGroup](#aws-cdkaws-lambdausecdkmanagedloggroup) | When enabled, CDK creates and manages loggroup for the lambda function | new default | | `false` | `true` |
229229
| [@aws-cdk/core:newStyleStackSynthesis](#aws-cdkcorenewstylestacksynthesis) | Switch to new stack synthesis method which enables CI/CD | fix | 1.39.0 | `false` | `true` |
230230
| [@aws-cdk/core:stackRelativeExports](#aws-cdkcorestackrelativeexports) | Name exports based on the construct paths relative to the stack, rather than the global construct path | fix | 1.58.0 | `false` | `true` |
231231
| [@aws-cdk/aws-rds:lowercaseDbIdentifier](#aws-cdkaws-rdslowercasedbidentifier) | Force lowercasing of RDS Cluster names in CDK | fix | 1.97.0 | `false` | `true` |
@@ -485,7 +485,7 @@ Refer aws-lambda/README.md for more details on Customizing Log Group creation.
485485
| Since | Default | Recommended |
486486
| ----- | ----- | ----- |
487487
| (not in v1) | | |
488-
| V2_NEXT | `true` | `true` |
488+
| V2_NEXT | `false` | `true` |
489489

490490
**Compatibility with old behavior:** Disable the feature flag to let lambda service create logGroup or specify logGroup or logRetention
491491

packages/aws-cdk-lib/cx-api/lib/features.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1641,7 +1641,7 @@ export const FLAGS: Record<string, FlagInfo> = {
16411641
Refer aws-lambda/README.md for more details on Customizing Log Group creation.
16421642
`,
16431643
introducedIn: { v2: 'V2_NEXT' },
1644-
defaults: { v2: true },
1644+
defaults: { v2: false },
16451645
recommendedValue: true,
16461646
compatibilityWithOldBehaviorMd: 'Disable the feature flag to let lambda service create logGroup or specify logGroup or logRetention',
16471647
},

packages/aws-cdk-lib/cx-api/test/features.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,12 @@ test('feature flag defaults may not be changed anymore', () => {
4444
[feats.USE_NEW_S3URI_PARAMETERS_FOR_BEDROCK_INVOKE_MODEL_TASK]: true,
4545
[feats.PIPELINE_REDUCE_STAGE_ROLE_TRUST_SCOPE]: true,
4646
[feats.PIPELINE_REDUCE_CROSS_ACCOUNT_ACTION_ROLE_TRUST_SCOPE]: true,
47-
[feats.USE_CDK_MANAGED_LAMBDA_LOGGROUP]: true,
48-
// Add new disabling feature flags below this line
4947
[feats.ASPECT_STABILIZATION]: true,
48+
// Add new disabling feature flags below this line
5049
[feats.LOG_USER_POOL_CLIENT_SECRET_VALUE]: false,
5150
[feats.USE_RESOURCEID_FOR_VPCV2_MIGRATION]: false,
51+
[feats.USE_CDK_MANAGED_LAMBDA_LOGGROUP]: false,
52+
5253
});
5354
});
5455

packages/aws-cdk-lib/recommended-feature-flags.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,6 @@
7373
"@aws-cdk/aws-stepfunctions:useDistributedMapResultWriterV2": true,
7474
"@aws-cdk/s3-notifications:addS3TrustKeyPolicyForSnsSubscriptions": true,
7575
"@aws-cdk/aws-ec2:requirePrivateSubnetsForEgressOnlyInternetGateway": true,
76-
"@aws-cdk/aws-s3:publicAccessBlockedByDefault": true
76+
"@aws-cdk/aws-s3:publicAccessBlockedByDefault": true,
77+
"@aws-cdk/aws-lambda:useCdkManagedLogGroup": true
7778
}

0 commit comments

Comments
 (0)
0