diff --git a/cdk/resources/LwM2M.ts b/cdk/resources/LwM2M.ts index 97d5a6a..568b369 100644 --- a/cdk/resources/LwM2M.ts +++ b/cdk/resources/LwM2M.ts @@ -5,9 +5,9 @@ import { aws_iot as IoT, aws_lambda as Lambda, Stack, - aws_logs as Logs, } from 'aws-cdk-lib' import type { PackedLambda } from '../backend' +import { LambdaLogGroup } from './LambdaLogGroup.js' /** * Contains resources that provide LwM2M based data for devices @@ -46,7 +46,7 @@ export class LwM2M extends Construct { resources: ['*'], }), ], - logRetention: Logs.RetentionDays.ONE_WEEK, + ...new LambdaLogGroup(this, 'updatesToLwM2MLogs'), }) const ruleRole = new IAM.Role(this, 'ruleRole', { diff --git a/cdk/resources/NRPlusGateway.ts b/cdk/resources/NRPlusGateway.ts index cde98f4..dfc98d8 100644 --- a/cdk/resources/NRPlusGateway.ts +++ b/cdk/resources/NRPlusGateway.ts @@ -6,9 +6,9 @@ import Iot from 'aws-cdk-lib/aws-iot' import Kinesis, { StreamMode } from 'aws-cdk-lib/aws-kinesis' import Lambda, { StartingPosition } from 'aws-cdk-lib/aws-lambda' import { KinesisEventSource } from 'aws-cdk-lib/aws-lambda-event-sources' -import Logs from 'aws-cdk-lib/aws-logs' import { Construct } from 'constructs' import type { PackedLambda } from '../backend' +import { LambdaLogGroup } from './LambdaLogGroup.js' export class NRPlusGateway extends Construct { constructor( @@ -95,7 +95,7 @@ export class NRPlusGateway extends Construct { resources: ['*'], }), ], - logRetention: Logs.RetentionDays.ONE_WEEK, + ...new LambdaLogGroup(this, 'parseSinkMessagesFnLogs'), reservedConcurrentExecutions: 1, }, ) @@ -133,7 +133,7 @@ export class NRPlusGateway extends Construct { resources: ['*'], }), ], - logRetention: Logs.RetentionDays.ONE_DAY, + ...new LambdaLogGroup(this, 'nrplusGatewayScanFnLogs'), }, ) diff --git a/cdk/resources/PublishSummaries.ts b/cdk/resources/PublishSummaries.ts index bc55236..f8c58e3 100644 --- a/cdk/resources/PublishSummaries.ts +++ b/cdk/resources/PublishSummaries.ts @@ -4,12 +4,12 @@ import { aws_iam as IAM, aws_lambda as Lambda, Duration, - aws_logs as Logs, } from 'aws-cdk-lib' import type { IPrincipal } from 'aws-cdk-lib/aws-iam/index.js' import { Construct } from 'constructs' import type { PackedLambda } from '../backend.js' import type { WebsocketAPI } from './WebsocketAPI.js' +import { LambdaLogGroup } from './LambdaLogGroup.js' /** * Publish the summary statistics for the devices @@ -77,7 +77,7 @@ export class PublishSummaries extends Construct { resources: ['*'], }), ], - logRetention: Logs.RetentionDays.ONE_WEEK, + ...new LambdaLogGroup(this, 'lambdaLogs'), }) websocketAPI.connectionsTable.grantFullAccess(lambda) diff --git a/cdk/resources/ResolveCellLocation.ts b/cdk/resources/ResolveCellLocation.ts index 6231de0..6679179 100644 --- a/cdk/resources/ResolveCellLocation.ts +++ b/cdk/resources/ResolveCellLocation.ts @@ -6,11 +6,11 @@ import { aws_iot as IoT, aws_lambda as Lambda, Stack, - aws_logs as Logs, } from 'aws-cdk-lib' import { Construct } from 'constructs' import type { PackedLambda } from '../backend.js' import type { WebsocketAPI } from './WebsocketAPI.js' +import { LambdaLogGroup } from './LambdaLogGroup.js' export class ResolveCellLocation extends Construct { public constructor( @@ -66,7 +66,7 @@ export class ResolveCellLocation extends Construct { resources: ['*'], }), ], - logRetention: Logs.RetentionDays.ONE_WEEK, + ...new LambdaLogGroup(this, 'resolveCellLocationLogs'), }, ) @@ -172,7 +172,7 @@ export class ResolveCellLocation extends Construct { }), ], layers: [baseLayer], - logRetention: Logs.RetentionDays.ONE_WEEK, + ...new LambdaLogGroup(this, 'onCellGeoLocationResolvedLambdaLogs'), }, ) websocketAPI.connectionsTable.grantFullAccess(onCellGeoLocationResolved) diff --git a/cdk/resources/ResolveNetworkSurveyGeoLocation.ts b/cdk/resources/ResolveNetworkSurveyGeoLocation.ts index 19973ed..8104f0d 100644 --- a/cdk/resources/ResolveNetworkSurveyGeoLocation.ts +++ b/cdk/resources/ResolveNetworkSurveyGeoLocation.ts @@ -6,11 +6,11 @@ import { aws_iam as IAM, aws_lambda as Lambda, aws_lambda_event_sources as LambdaEvents, - aws_logs as Logs, } from 'aws-cdk-lib' import { Construct } from 'constructs' import type { PackedLambda } from '../backend' import type { WebsocketAPI } from './WebsocketAPI' +import { LambdaLogGroup } from './LambdaLogGroup.js' /** * Notify clients about resolved neighboring cell location reports geo locations @@ -66,7 +66,7 @@ export class ResolveNetworkSurveyGeoLocation extends Construct { resources: [websocketAPI.websocketAPIArn], }), ], - logRetention: Logs.RetentionDays.ONE_WEEK, + ...new LambdaLogGroup(this, 'onNewNetworkSurveyLogs'), }) websocketAPI.connectionsTable.grantFullAccess(onNewNetworkSurvey) @@ -112,7 +112,7 @@ export class ResolveNetworkSurveyGeoLocation extends Construct { }), ], layers: [baseLayer], - logRetention: Logs.RetentionDays.ONE_WEEK, + ...new LambdaLogGroup(this, 'onNetworkSurveyLocatedLogs'), }, ) websocketAPI.connectionsTable.grantFullAccess(onNetworkSurveyLocated) diff --git a/cdk/resources/WebsocketAPI.ts b/cdk/resources/WebsocketAPI.ts index dff3a5f..88ca09c 100644 --- a/cdk/resources/WebsocketAPI.ts +++ b/cdk/resources/WebsocketAPI.ts @@ -8,10 +8,10 @@ import { Duration, RemovalPolicy, Stack, - aws_logs as Logs, } from 'aws-cdk-lib' import { Construct } from 'constructs' import type { PackedLambda } from '../backend.js' +import { LambdaLogGroup } from './LambdaLogGroup.js' export class WebsocketAPI extends Construct { public readonly websocketURI: string @@ -89,7 +89,7 @@ export class WebsocketAPI extends Construct { }, initialPolicy: [], layers: [baseLayer], - logRetention: Logs.RetentionDays.ONE_WEEK, + ...new LambdaLogGroup(this, 'onConnectLogs'), }) this.connectionsTable.grantWriteData(onConnect) @@ -135,7 +135,7 @@ export class WebsocketAPI extends Construct { ), }, layers: [baseLayer], - logRetention: Logs.RetentionDays.ONE_WEEK, + ...new LambdaLogGroup(this, 'onMessageLogs'), initialPolicy: [ new IAM.PolicyStatement({ actions: ['iot:Publish'], @@ -201,7 +201,7 @@ export class WebsocketAPI extends Construct { }, initialPolicy: [], layers: [baseLayer], - logRetention: Logs.RetentionDays.ONE_WEEK, + ...new LambdaLogGroup(this, 'onDisconnectLogs'), }) this.connectionsTable.grantWriteData(onDisconnect) @@ -283,7 +283,7 @@ export class WebsocketAPI extends Construct { }), ], layers: [baseLayer], - logRetention: Logs.RetentionDays.ONE_WEEK, + ...new LambdaLogGroup(this, 'publishToWebsocketClientsLogs'), }, )