Skip to content

aws-s3-deployment: logRetention is deprecated warnings #28809

@byrne-greg

Description

@byrne-greg

Describe the bug

We use a custom shared cdk-lib built on top of aws-cdk used by 100's of applications. Part of this library uses aws-s3-deployment and the BucketDeployment construct.

Since upgrading and the deprecation of logRetention, our logs are contain deprecation warnings from the bucket-deployment that continues to use the deprecated field.

console.warn
      [WARNING] aws-cdk-lib.aws_lambda.FunctionOptions#logRetention is deprecated.
        instead create a fully customizable log group with `logs.LogGroup` and use the `logGroup` property to instruct the Lambda function to send logs to it.
      Migrating from `logRetention` to `logGroup` will cause the name of the log group to change.
      Users and code and referencing the name verbatim will have to adjust.
      
      In AWS CDK code, you can access the log group name directly from the LogGroup construct:
      ```ts
      declare const myLogGroup: logs.LogGroup;
      myLogGroup.logGroupName;
      ```
        This API will be removed in the next major release.

      at print (node_modules/aws-cdk-lib/.warnings.jsii.js:5:146)
      at Object.aws_cdk_lib_aws_lambda_SingletonFunctionProps (node_modules/aws-cdk-lib/.warnings.jsii.js:1:1056448)
      at new SingletonFunction (node_modules/aws-cdk-lib/aws-lambda/lib/singleton-lambda.js:1:753)
      at new BucketDeploymentSingletonFunction (node_modules/aws-cdk-lib/custom-resource-handlers/dist/aws-s3-deployment/bucket-deployment-provider.generated.js:1:386)
      at new BucketDeployment (node_modules/aws-cdk-lib/aws-s3-deployment/lib/bucket-deployment.js:1:2900)
      at UploadDocs.upload (node_modules/my-shared-cdk-lib/src/uploadDocs/uploadDocs.ts:*:*)
      at UploadDocs.uploadDocs (node_modules/my-shared-cdk-lib/src/uploadDocs/uploadDocs.ts:*:*)
      at new UploadDocs (node_modules/my-shared-cdk-lib/src/uploadDocs/uploadDocs.ts:*:*)
      at new AbstractFargateService (node_modules/my-shared-cdk-lib/src/fargate/abstractFargateService.ts:*:*)
      at new FargateService (node_modules/my-shared-cdk-lib/src/fargate/fargateService.ts:*:*)
      at new Stack (cdk/stack.ts:*:*)
      at Object.<anonymous> (cdk/__tests__/stack.test.ts:*:*)

Expected Behavior

No warning logs

Current Behavior

console.warn
      [WARNING] aws-cdk-lib.aws_lambda.FunctionOptions#logRetention is deprecated.
        instead create a fully customizable log group with `logs.LogGroup` and use the `logGroup` property to instruct the Lambda function to send logs to it.
      Migrating from `logRetention` to `logGroup` will cause the name of the log group to change.
      Users and code and referencing the name verbatim will have to adjust.
      
      In AWS CDK code, you can access the log group name directly from the LogGroup construct:
      ```ts
      declare const myLogGroup: logs.LogGroup;
      myLogGroup.logGroupName;
      ```
        This API will be removed in the next major release.

      at print (node_modules/aws-cdk-lib/.warnings.jsii.js:5:146)
      at Object.aws_cdk_lib_aws_lambda_SingletonFunctionProps (node_modules/aws-cdk-lib/.warnings.jsii.js:1:1056448)
      at new SingletonFunction (node_modules/aws-cdk-lib/aws-lambda/lib/singleton-lambda.js:1:753)
      at new BucketDeploymentSingletonFunction (node_modules/aws-cdk-lib/custom-resource-handlers/dist/aws-s3-deployment/bucket-deployment-provider.generated.js:1:386)
      at new BucketDeployment (node_modules/aws-cdk-lib/aws-s3-deployment/lib/bucket-deployment.js:1:2900)
      at UploadDocs.upload (node_modules/my-shared-cdk-lib/src/uploadDocs/uploadDocs.ts:*:*)
      at UploadDocs.uploadDocs (node_modules/my-shared-cdk-lib/src/uploadDocs/uploadDocs.ts:*:*)
      at new UploadDocs (node_modules/my-shared-cdk-lib/src/uploadDocs/uploadDocs.ts:*:*)
      at new AbstractFargateService (node_modules/my-shared-cdk-lib/src/fargate/abstractFargateService.ts:*:*)
      at new FargateService (node_modules/my-shared-cdk-lib/src/fargate/fargateService.ts:*:*)
      at new Stack (cdk/stack.ts:*:*)
      at Object.<anonymous> (cdk/__tests__/stack.test.ts:*:*)

Reproduction Steps

Create a stack with the latest BucketDeployment

Possible Solution

  1. Upgrade custom-resource-handlers/BucketDeploymentSingletonFunction lambda to use LogGroups and remove logRetention
  2. Upgrade bucket-deployment.ts to accept LogGroups instead of logRetention

Additional Information/Context

No response

CDK CLI Version

2.122.0

Framework Version

No response

Node.js Version

20

OS

OSX

Language

TypeScript

Language Version

TypeScript (5.3.3)

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-logsRelated to Amazon CloudWatch LogsbugThis issue is a bug.p1

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions