Skip to content

Commit 3c7227a

Browse files
author
Eugene Cheung
authored
feat: replace deprecated logRetention usages with explicit Lambda log groups (#656)
--- _By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license_
1 parent 5880e64 commit 3c7227a

File tree

5 files changed

+48
-430
lines changed

5 files changed

+48
-430
lines changed

lib/dashboard/widget/BitmapWidget.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as path from "path";
22

3-
import { Duration, Tags } from "aws-cdk-lib";
3+
import { Duration, RemovalPolicy, Tags } from "aws-cdk-lib";
44
import { IWidget } from "aws-cdk-lib/aws-cloudwatch";
55
import { Effect, PolicyStatement } from "aws-cdk-lib/aws-iam";
66
import {
@@ -9,7 +9,7 @@ import {
99
Function,
1010
IFunction,
1111
} from "aws-cdk-lib/aws-lambda";
12-
import { RetentionDays } from "aws-cdk-lib/aws-logs";
12+
import { LogGroup, RetentionDays } from "aws-cdk-lib/aws-logs";
1313
import { Construct } from "constructs";
1414

1515
import { CustomWidget } from "./CustomWidget";
@@ -41,7 +41,10 @@ export class BitmapWidgetRenderingSupport extends Construct {
4141
memorySize: 128,
4242
runtime: determineLatestNodeRuntime(this),
4343
timeout: Duration.seconds(60),
44-
logRetention: RetentionDays.ONE_DAY,
44+
logGroup: new LogGroup(this, "LambdaLogs", {
45+
retention: RetentionDays.ONE_DAY,
46+
removalPolicy: RemovalPolicy.RETAIN_ON_UPDATE_OR_DELETE,
47+
}),
4548
});
4649

4750
this.handler.addToRolePolicy(

lib/monitoring/aws-secretsmanager/SecretsManagerMetricsPublisher.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as path from "path";
22

3-
import { Duration, Names } from "aws-cdk-lib";
3+
import { Duration, Names, RemovalPolicy } from "aws-cdk-lib";
44
import { Rule, RuleTargetInput, Schedule } from "aws-cdk-lib/aws-events";
55
import { LambdaFunction } from "aws-cdk-lib/aws-events-targets";
66
import { Effect, PolicyStatement } from "aws-cdk-lib/aws-iam";
@@ -10,7 +10,7 @@ import {
1010
Function,
1111
IFunction,
1212
} from "aws-cdk-lib/aws-lambda";
13-
import { RetentionDays } from "aws-cdk-lib/aws-logs";
13+
import { LogGroup, RetentionDays } from "aws-cdk-lib/aws-logs";
1414
import { ISecret } from "aws-cdk-lib/aws-secretsmanager";
1515
import { Construct } from "constructs";
1616

@@ -41,7 +41,10 @@ export class SecretsManagerMetricsPublisher extends Construct {
4141
memorySize: 128,
4242
runtime: determineLatestNodeRuntime(this),
4343
timeout: Duration.seconds(60),
44-
logRetention: RetentionDays.ONE_DAY,
44+
logGroup: new LogGroup(this, "LambdaLogs", {
45+
retention: RetentionDays.ONE_DAY,
46+
removalPolicy: RemovalPolicy.RETAIN_ON_UPDATE_OR_DELETE,
47+
}),
4548
});
4649

4750
this.lambda.addToRolePolicy(

test/dashboard/widget/__snapshots__/BitmapWidget.test.ts.snap

Lines changed: 9 additions & 106 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/facade/__snapshots__/MonitoringAspect.test.ts.snap

Lines changed: 9 additions & 106 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)