@@ -8,11 +8,13 @@ import { AppConfigProvider } from '@aws-lambda-powertools/parameters/appconfig';
8
8
import { DynamoDBProvider } from '@aws-lambda-powertools/parameters/dynamodb' ;
9
9
import { SecretsProvider } from '@aws-lambda-powertools/parameters/secrets' ;
10
10
import { SSMProvider } from '@aws-lambda-powertools/parameters/ssm' ;
11
+ import { EventBridgeSchema } from '@aws-lambda-powertools/parser/schemas' ;
11
12
import { Tracer } from '@aws-lambda-powertools/tracer' ;
12
13
import { AppConfigDataClient } from '@aws-sdk/client-appconfigdata' ;
13
14
import { DynamoDBClient } from '@aws-sdk/client-dynamodb' ;
14
15
import { SecretsManagerClient } from '@aws-sdk/client-secrets-manager' ;
15
16
import { SSMClient } from '@aws-sdk/client-ssm' ;
17
+ import { z } from 'zod' ;
16
18
17
19
const logger = new Logger ( {
18
20
logLevel : 'DEBUG' ,
@@ -48,6 +50,10 @@ new DynamoDBProvider({ tableName: 'foo', awsSdkV3Client: ddbClient });
48
50
// Instantiating the BatchProcessor will confirm that the utility can be used
49
51
new BatchProcessor ( EventType . SQS ) ;
50
52
53
+ const testSchema = z . object ( { instance_id : z . string ( ) , state : z . string ( ) } ) ;
54
+
55
+ const testEventSchema = EventBridgeSchema . extend ( { detail : testSchema } ) ;
56
+
51
57
const layerPath = process . env . LAYERS_PATH || '/opt/nodejs/node_modules' ;
52
58
const expectedVersion = process . env . POWERTOOLS_PACKAGE_VERSION || '0.0.0' ;
53
59
@@ -79,7 +85,7 @@ const getVersionFromModule = async (moduleName: string): Promise<string> => {
79
85
return moduleVersion ;
80
86
} ;
81
87
82
- export const handler = async ( ) : Promise < void > => {
88
+ export const handler = async ( event : unknown ) : Promise < void > => {
83
89
// Check that the packages version matches the expected one
84
90
for ( const moduleName of [
85
91
'commons' ,
@@ -89,6 +95,7 @@ export const handler = async (): Promise<void> => {
89
95
'parameters' ,
90
96
'idempotency' ,
91
97
'batch' ,
98
+ 'parser' ,
92
99
] ) {
93
100
const moduleVersion = await getVersionFromModule ( moduleName ) ;
94
101
if ( moduleVersion !== expectedVersion ) {
@@ -115,4 +122,7 @@ export const handler = async (): Promise<void> => {
115
122
// the presence of a log will indicate that the logger is working
116
123
// while the content of the log will indicate that the tracer is working
117
124
logger . debug ( 'subsegment' , { subsegment : subsegment . format ( ) } ) ;
125
+
126
+ // Check that the parser is working
127
+ testEventSchema . parse ( event ) ;
118
128
} ;
0 commit comments