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

CustomResourceConfig: Logging retention not set for CR when "autoDeleteObjects: true" is added to S3 Bucket #33116

Open
1 task
eodeyemi14 opened this issue Jan 24, 2025 · 2 comments
Labels
@aws-cdk/aws-s3 Related to Amazon S3 bug This issue is a bug. feature-request A feature should be added or improved. p2

Comments

@eodeyemi14
Copy link

Describe the bug

When "autoDeleteObjects: true" is added to an S3 bucket, CDK creates a Custom Resource to delete objects from the S3 Bucket. However, retention policy is not set on the created CloudWatch log group even with the CustomResourceConfig module is used. I suspect there may be other construct types that this configuration does not currently work for either.

Here's a sample of the code

import * as cdk from 'aws-cdk-lib';
import { Construct } from 'constructs';
import * as s3 from 'aws-cdk-lib/aws-s3';
import * as lambda from 'aws-cdk-lib/aws-lambda';
import * as logs from 'aws-cdk-lib/aws-logs';
import { App } from 'aws-cdk-lib';
import { CustomResourceConfig } from 'aws-cdk-lib/custom-resources';


export class CdkStack extends cdk.Stack {
  constructor(scope: Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);

   CustomResourceConfig.of(this).addLogRetentionLifetime(logs.RetentionDays.TWO_WEEKS);

   const bucket = new s3.Bucket(this, 'testBucket', {
     versioned: true,
     autoDeleteObjects: true,
     removalPolicy: cdk.RemovalPolicy.DESTROY,
   });
 }
}

Regression Issue

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

Last Known Working CDK Version

No response

Expected Behavior

The CloudWatch log group created by the custom resource should have retention policy set.

Current Behavior

CloudWatch log group created by the custom resource does not have retention policy set.

Reproduction Steps

  • Create an S3 bucket with "autoDeleteObjects: true" property set
  • Add CustomResourceConfig module to set log retention policy on log group

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.176.0

Framework Version

No response

Node.js Version

v20.17.0

OS

MacOS

Language

TypeScript

Language Version

No response

Other information

No response

@eodeyemi14 eodeyemi14 added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jan 24, 2025
@github-actions github-actions bot added the @aws-cdk/aws-s3 Related to Amazon S3 label Jan 24, 2025
@pahud
Copy link
Contributor

pahud commented Jan 27, 2025

related to #33025 (comment)

I think we a custom resource is implicitly created, which user can't disable that, we still should allow user to have a freedom to customize the log retention period for the custom resource provider lambda function logs.

Making this a feature request and I will bring this to the team for visibility.

@pahud pahud added feature-request A feature should be added or improved. p2 and removed needs-triage This issue or PR still needs to be triaged. labels Jan 27, 2025
@pahud
Copy link
Contributor

pahud commented Jan 27, 2025

Hi @eodeyemi14 I just created #33196 to capture similar requests and include this issue there.

Can you take a look on #33196 and let me know if you have different thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-s3 Related to Amazon S3 bug This issue is a bug. feature-request A feature should be added or improved. p2
Projects
None yet
Development

No branches or pull requests

3 participants