From 762e9196b169ecda150ebee58b18b6b37c408093 Mon Sep 17 00:00:00 2001 From: svozza Date: Mon, 19 Jan 2026 12:29:53 +0000 Subject: [PATCH 1/2] chore(ci): update layer script to include event-handler --- layers/src/layer-publisher-stack.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/layers/src/layer-publisher-stack.ts b/layers/src/layer-publisher-stack.ts index c61fea4882..024dc81b96 100644 --- a/layers/src/layer-publisher-stack.ts +++ b/layers/src/layer-publisher-stack.ts @@ -66,6 +66,7 @@ export class LayerPublisherStack extends Stack { // the name is the same as the npm workspace name const utilities = [ 'commons', + 'event-handler', 'jmespath', 'logger', 'metrics', From 8df66ad2cba52ac4ae01abce16c7923131c34df5 Mon Sep 17 00:00:00 2001 From: Andrea Amorosi Date: Wed, 28 Jan 2026 12:38:30 +0100 Subject: [PATCH 2/2] tests: add evt handler to tests --- .../layerPublisher.class.test.functionCode.ts | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/layers/tests/e2e/layerPublisher.class.test.functionCode.ts b/layers/tests/e2e/layerPublisher.class.test.functionCode.ts index ed6b0f2d8e..8b68e56a75 100644 --- a/layers/tests/e2e/layerPublisher.class.test.functionCode.ts +++ b/layers/tests/e2e/layerPublisher.class.test.functionCode.ts @@ -1,6 +1,7 @@ import { readFile } from 'node:fs/promises'; import { join } from 'node:path'; import { BatchProcessor, EventType } from '@aws-lambda-powertools/batch'; +import { Router } from '@aws-lambda-powertools/event-handler/http'; import { DynamoDBPersistenceLayer } from '@aws-lambda-powertools/idempotency/dynamodb'; import { Logger } from '@aws-lambda-powertools/logger'; import { Metrics } from '@aws-lambda-powertools/metrics'; @@ -13,6 +14,7 @@ import { AppConfigDataClient } from '@aws-sdk/client-appconfigdata'; import { DynamoDBClient } from '@aws-sdk/client-dynamodb'; import { SecretsManagerClient } from '@aws-sdk/client-secrets-manager'; import { SSMClient } from '@aws-sdk/client-ssm'; +import type { Context } from 'aws-lambda'; const logger = new Logger({ logLevel: 'DEBUG', @@ -45,9 +47,12 @@ new AppConfigProvider({ environment: 'foo', awsSdkV3Client: appconfigClient }); new DynamoDBProvider({ tableName: 'foo', awsSdkV3Client: ddbClient }); -// Instantiating the BatchProcessor will confirm that the utility can be used new BatchProcessor(EventType.SQS); +const app = new Router({ + logger: { error: () => {}, debug: () => {}, info: () => {}, warn: () => {} }, +}); + const layerPath = process.env.LAYERS_PATH || '/opt/nodejs/node_modules'; const expectedVersion = process.env.POWERTOOLS_PACKAGE_VERSION || '0.0.0'; @@ -79,7 +84,7 @@ const getVersionFromModule = async (moduleName: string): Promise => { return moduleVersion; }; -export const handler = async (_event: unknown): Promise => { +export const handler = async (_event: unknown, context: Context) => { // Check that the packages version matches the expected one for (const moduleName of [ 'commons', @@ -90,6 +95,7 @@ export const handler = async (_event: unknown): Promise => { 'idempotency', 'batch', 'parser', + 'event-handler', ]) { const moduleVersion = await getVersionFromModule(moduleName); if (moduleVersion !== expectedVersion) { @@ -116,4 +122,15 @@ export const handler = async (_event: unknown): Promise => { // the presence of a log will indicate that the logger is working // while the content of the log will indicate that the tracer is working logger.debug('subsegment', { subsegment: subsegment.format() }); + + // Since we're passing an invalid event, the event handler will throw + // an InvalidEventError. This will prove that the event-handler layer + // is working as expected without us having to resolve a full event + try { + await app.resolve({}, context); + } catch (error) { + if ((error as Error).name !== 'InvalidEventError') { + throw error; + } + } };