Skip to content

Commit

Permalink
fix: use @bifravst/aws-cdk-lambda-helpers
Browse files Browse the repository at this point in the history
which fixes the Memfault function not executing
  • Loading branch information
coderbyheart committed Apr 8, 2024
1 parent 0f125f4 commit 3ca6e26
Show file tree
Hide file tree
Showing 21 changed files with 543 additions and 891 deletions.
4 changes: 3 additions & 1 deletion cdk/BackendApp.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { App } from 'aws-cdk-lib'
import type { BackendLambdas } from './BackendLambdas.js'
import type { PackedLayer } from './packLayer.js'
import type { PackedLayer } from '@bifravst/aws-cdk-lambda-helpers/layer'
import { BackendStack } from './stacks/BackendStack.js'

export class BackendApp extends App {
Expand All @@ -16,8 +16,10 @@ export class BackendApp extends App {
super({
context: {
version: Date.now().toString(),
isTest: false,
},
})
console.log(lambdaSources)
new BackendStack(this, { lambdaSources, layer, assetTrackerStackName })
}
}
4 changes: 2 additions & 2 deletions cdk/BackendLambdas.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { PackedLambda } from './backend'
import type { PackedLambda } from '@bifravst/aws-cdk-lambda-helpers'

type BackendLambdas = {
publishToWebsocketClients: PackedLambda
Expand All @@ -13,6 +13,6 @@ type BackendLambdas = {
parseSinkMessages: PackedLambda
updatesToLwM2M: PackedLambda
publishLwM2MShadowsToJSON: PackedLambda
memfault: PackedLambda
memfaultPublishReboots: PackedLambda
memfaultPollForReboots: PackedLambda
}
31 changes: 4 additions & 27 deletions cdk/backend.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { mkdir } from 'node:fs/promises'
import path from 'node:path'
import { BackendApp } from './BackendApp.js'
import { packLambda } from './packLambda.js'
import { packLayer } from './packLayer.js'
import { ASSET_TRACKER_STACK_NAME } from './stacks/stackName.js'
export type PackedLambda = { lambdaZipFile: string; handler: string }
import { packLambdaFromPath } from '@bifravst/aws-cdk-lambda-helpers'
import { packLayer } from '@bifravst/aws-cdk-lambda-helpers/layer'

const packagesInLayer: string[] = [
'@nordicsemiconductor/from-env',
Expand All @@ -17,27 +14,7 @@ const packagesInLayer: string[] = [
'@protobuf-ts/runtime',
'p-retry',
]
const pack = async (
id: string,
handlerFunction = 'handler',
): Promise<PackedLambda> => {
try {
await mkdir(path.join(process.cwd(), 'dist', 'lambdas'), {
recursive: true,
})
} catch {
// Directory exists
}
const zipFile = path.join(process.cwd(), 'dist', 'lambdas', `${id}.zip`)
const { handler } = await packLambda({
sourceFile: path.join(process.cwd(), 'lambda', `${id}.ts`),
zipFile,
})
return {
lambdaZipFile: zipFile,
handler: handler.replace('.js', `.${handlerFunction}`),
}
}
const pack = async (id: string) => packLambdaFromPath(id, `lambda/${id}.ts`)

new BackendApp({
lambdaSources: {
Expand All @@ -52,7 +29,7 @@ new BackendApp({
onNetworkSurveyLocated: await pack('onNetworkSurveyLocated'),
parseSinkMessages: await pack('parseSinkMessages'),
updatesToLwM2M: await pack('updatesToLwM2M'),
memfault: await pack('memfault'),
memfaultPublishReboots: await pack('memfaultPublishReboots'),
memfaultPollForReboots: await pack('memfaultPollForReboots'),
// For hello.nrfcloud.com/map
publishLwM2MShadowsToJSON: await pack('publishLwM2MShadowsToJSON'),
Expand Down
28 changes: 0 additions & 28 deletions cdk/commonParent.spec.ts

This file was deleted.

16 changes: 0 additions & 16 deletions cdk/commonParent.ts

This file was deleted.

52 changes: 0 additions & 52 deletions cdk/findDependencies.ts

This file was deleted.

78 changes: 0 additions & 78 deletions cdk/packLambda.ts

This file was deleted.

102 changes: 0 additions & 102 deletions cdk/packLayer.ts

This file was deleted.

18 changes: 0 additions & 18 deletions cdk/resources/LambdaLogGroup.ts

This file was deleted.

Loading

0 comments on commit 3ca6e26

Please sign in to comment.