Skip to content

Commit

Permalink
fix(cdk): migrate to separate log group
Browse files Browse the repository at this point in the history
  • Loading branch information
coderbyheart committed Feb 23, 2024
1 parent 40ae922 commit a85856b
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions cdk/resources/LwM2M.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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', {
Expand Down
6 changes: 3 additions & 3 deletions cdk/resources/NRPlusGateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -95,7 +95,7 @@ export class NRPlusGateway extends Construct {
resources: ['*'],
}),
],
logRetention: Logs.RetentionDays.ONE_WEEK,
...new LambdaLogGroup(this, 'parseSinkMessagesFnLogs'),
reservedConcurrentExecutions: 1,
},
)
Expand Down Expand Up @@ -133,7 +133,7 @@ export class NRPlusGateway extends Construct {
resources: ['*'],
}),
],
logRetention: Logs.RetentionDays.ONE_DAY,
...new LambdaLogGroup(this, 'nrplusGatewayScanFnLogs'),
},
)

Expand Down
4 changes: 2 additions & 2 deletions cdk/resources/PublishSummaries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -77,7 +77,7 @@ export class PublishSummaries extends Construct {
resources: ['*'],
}),
],
logRetention: Logs.RetentionDays.ONE_WEEK,
...new LambdaLogGroup(this, 'lambdaLogs'),
})

websocketAPI.connectionsTable.grantFullAccess(lambda)
Expand Down
6 changes: 3 additions & 3 deletions cdk/resources/ResolveCellLocation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -66,7 +66,7 @@ export class ResolveCellLocation extends Construct {
resources: ['*'],
}),
],
logRetention: Logs.RetentionDays.ONE_WEEK,
...new LambdaLogGroup(this, 'resolveCellLocationLogs'),
},
)

Expand Down Expand Up @@ -172,7 +172,7 @@ export class ResolveCellLocation extends Construct {
}),
],
layers: [baseLayer],
logRetention: Logs.RetentionDays.ONE_WEEK,
...new LambdaLogGroup(this, 'onCellGeoLocationResolvedLambdaLogs'),
},
)
websocketAPI.connectionsTable.grantFullAccess(onCellGeoLocationResolved)
Expand Down
6 changes: 3 additions & 3 deletions cdk/resources/ResolveNetworkSurveyGeoLocation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -112,7 +112,7 @@ export class ResolveNetworkSurveyGeoLocation extends Construct {
}),
],
layers: [baseLayer],
logRetention: Logs.RetentionDays.ONE_WEEK,
...new LambdaLogGroup(this, 'onNetworkSurveyLocatedLogs'),
},
)
websocketAPI.connectionsTable.grantFullAccess(onNetworkSurveyLocated)
Expand Down
10 changes: 5 additions & 5 deletions cdk/resources/WebsocketAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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'],
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -283,7 +283,7 @@ export class WebsocketAPI extends Construct {
}),
],
layers: [baseLayer],
logRetention: Logs.RetentionDays.ONE_WEEK,
...new LambdaLogGroup(this, 'publishToWebsocketClientsLogs'),
},
)

Expand Down

0 comments on commit a85856b

Please sign in to comment.