Skip to content

❗NOTICE (aws-lambda): Lambda cdk managed log group duplicates #34612

Closed
@mjgoble

Description

@mjgoble

Please add your +1 👍 to let us know you have encountered this

Status: IN-PROGRESS

Overview:

The addition of cdk managed log group to lambda function breaks any lambda function being deployed(new or existing) as the default value of the feature flag : USE_CDK_MANAGED_LAMBDA_LOGGROUP (@aws-cdk/aws-lambda:useCdkManagedLogGroup) is set to true

Regression Issue

  • Select this option if this issue appears to be a regression.

Complete Error Message:

CDK deployment fails with errors similar to

10:27:37 AM | CREATE_FAILED        | AWS::Logs::LogGroup        | OnFailureExtractorLambdaLogGroup...
Resource handler returned message: "Resource of type 'AWS::Logs::LogGroup' with identifier '{"/properties/LogGroupName":"/aws/lambda/OnFailureExt
ractorLambda-OnFailureExtractorLambda6-..."}' already exists." (RequestToken: ... , HandlerErrorCode: Al
readyExists)

❌  OnFailureExtractorLambda failed: _ToolkitError: The stack named OnFailureExtractorLambda failed to deploy: UPDATE_ROLLBACK_COMPLETE: Resource handler returned message: "Resource of type 'AWS::Logs::LogGroup' with identifier '{"/properties/LogGroupName":"/aws/lambda/OnFailureExtractorLambda-OnFailureExtractorLambda6-..."}' already exists." (RequestToken: ..., HandlerErrorCode: AlreadyExists)

Workaround:

As a workaround, one can pass the feature flag @aws-cdk/aws-lambda:useCdkManagedLogGroup value as false

new App({
  context: {
    '@aws-cdk/aws-lambda:useCdkManagedLogGroup': false,
  },
});

Further details can be found in below links :

Solution:

Upgrading to patch version v2.200.1 should resolve this issue for existing lambdas

Describe the bug

When upgrading to aws-cdk-lib 2.200.0 cdk is trying to create log groups for the custom resource provider framework lambdas, however the already exist and is causing the stack deployment to fail

Last Known Working CDK Library Version

2.199.0

Expected Behavior

CDK deployment should not change anything

Current Behavior

Additional LogGroups are created, and when deploying, fails due to

Resource of type 'AWS::Logs::LogGroup' with identifier '{"/properties/LogGroupName":"/
aws/lambda/my-cr-provider-function"}' already exists."

Reproduction Steps

CDK deploy a stack with a custom resource using < 2.200.0

Try again with v 2.200.0

Possible Solution

No response

Additional Information/Context

No response

AWS CDK Library version (aws-cdk-lib)

2.200.0

AWS CDK CLI version

2.1017.1

Node.js Version

n/a

OS

Linux

Language

Python

Language Version

3.12

Other information

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions