Skip to content

Commit c012f9c

Browse files
committed
feat: add VPC Lattice event types
1 parent 38e1e32 commit c012f9c

2 files changed

Lines changed: 40 additions & 2 deletions

File tree

‎src/types.ts‎

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export type LambdaEvent = LambdaRequestEvent | LambdaTriggerEvent
4141
/**
4242
* Union of events that are request-based
4343
*/
44-
export type LambdaRequestEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2 | ALBEvent
44+
export type LambdaRequestEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2 | ALBEvent | LatticeProxyEventV2
4545

4646
/**
4747
* Union of events that are internal trigger-based
@@ -59,3 +59,38 @@ export interface CommonTriggerEventsMap {
5959
'source': AmplifyGraphQlResolverEvent | CloudWatchAlarmEvent | CodePipelineCloudWatchEvent | EventBridgeEvent<any, any> | EventBridgeEvent<S3NotificationEvent['detail-type'], S3NotificationEvent['detail']>
6060
'triggerSource': CreateAuthChallengeTriggerEvent | CustomEmailSenderTriggerEvent | CustomMessageTriggerEvent | CustomSMSSenderTriggerEvent | DefineAuthChallengeTriggerEvent | PostAuthenticationTriggerEvent | PostConfirmationTriggerEvent | PreAuthenticationTriggerEvent | PreSignUpTriggerEvent | PreTokenGenerationV2TriggerEvent | PreTokenGenerationTriggerEvent | UserMigrationTriggerEvent | VerifyAuthChallengeResponseTriggerEvent
6161
}
62+
63+
/**
64+
* Amazon VPC Lattice v2 event.
65+
* Not yet available in `@types/aws-lambda`, so defined locally.
66+
*/
67+
export interface LatticeRequestContextV2 {
68+
serviceNetworkArn: string
69+
serviceArn: string
70+
targetGroupArn: string
71+
region: string
72+
timeEpoch: string
73+
identity: {
74+
sourceVpcArn?: string
75+
type?: string
76+
principal?: string
77+
principalOrgID?: string
78+
sessionName?: string
79+
x509IssuerOu?: string
80+
x509SanDns?: string
81+
x509SanNameCn?: string
82+
x509SanUri?: string
83+
x509SubjectCn?: string
84+
}
85+
}
86+
87+
export interface LatticeProxyEventV2 {
88+
version: string
89+
path: string
90+
method: string
91+
headers: Record<string, string[] | undefined>
92+
queryStringParameters: Record<string, string[] | undefined>
93+
body: string | null
94+
isBase64Encoded: boolean
95+
requestContext: LatticeRequestContextV2
96+
}

‎src/utils.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,12 @@ export function eventMethodUrl(event: LambdaRequestEvent): [string, string] {
5858
if ('rawPath' in event) {
5959
return [event.requestContext.http.method, event.rawPath]
6060
}
61-
else if ('path' in event) {
61+
else if ('httpMethod' in event) {
6262
return [event.httpMethod, event.path]
6363
}
64+
else if ('method' in event) {
65+
return [event.method, event.path]
66+
}
6467
else {
6568
throw new Error('Invalid event')
6669
}

0 commit comments

Comments
 (0)