Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
byrne-greg opened this issue Jan 22, 2024 · 6 comments · Fixed by #28783
Closed

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

byrne-greg opened this issue Jan 22, 2024 · 6 comments · Fixed by #28783
Labels
@aws-cdk/aws-logs Related to Amazon CloudWatch Logs bug This issue is a bug. p1

Comments

@byrne-greg
Copy link

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

@byrne-greg byrne-greg added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jan 22, 2024
@github-actions github-actions bot added the @aws-cdk/aws-logs Related to Amazon CloudWatch Logs label Jan 22, 2024
@byrne-greg
Copy link
Author

Similar issue to #28806

@mrgrain
Copy link
Contributor

mrgrain commented Jan 22, 2024

Thanks for reporting. This will be fixed in #28783

@mrgrain mrgrain added p1 and removed needs-triage This issue or PR still needs to be triaged. labels Jan 22, 2024
@mergify mergify bot closed this as completed in #28783 Jan 22, 2024
@mergify mergify bot closed this as completed in ea34c89 Jan 22, 2024
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

1 similar comment
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@saurabhmarwaha
Copy link

saurabhmarwaha commented Feb 15, 2024

@mrgrain Any solution or workaround to this yet?

I didn't understand what to do based on

[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:

declare const myLogGroup: logs.LogGroup;
myLogGroup.logGroupName;

@mrgrain
Copy link
Contributor

mrgrain commented Feb 15, 2024

@saurabhmarwaha see #28783 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-logs Related to Amazon CloudWatch Logs bug This issue is a bug. p1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants