Fix ServiceDeployer LogGroup conflict with useCdkManagedLogGroup feature flag#92
Merged
Conversation
3587c96 to
a0c9b82
Compare
…ure flag When the @aws-cdk/aws-lambda:useCdkManagedLogGroup feature flag is enabled (recommended default since CDK 2.200.0), the Lambda construct automatically creates a CloudFormation LogGroup. ServiceDeployer was creating a second one with the same name, causing a conflict during deployment. Fix: check the feature flag via cdk.FeatureFlags before creating the explicit LogGroup. Users who want custom retention with the flag enabled can pass a logGroup via props (already supported). Fixes #90
a0c9b82 to
7e5ebe5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@aws-cdk/aws-lambda:useCdkManagedLogGroupis enabled (recommended default since CDK 2.200.0), the Lambda construct automatically creates aAWS::Logs::LogGroupresource.ServiceDeployerwas also explicitly creating one with the same name, causing CloudFormation to fail with "already exists in stack".cdk.FeatureFlags.of(this).isEnabled(cx_api.USE_CDK_MANAGED_LAMBDA_LOGGROUP)before creating the explicit log group — skip it when CDK is managing log group creation.Test plan
ServiceDeployerwith the feature flag enabled viaAppcontext, asserts exactly oneAWS::Logs::LogGroupresource exists (the CDK-managed one from Lambda)