From a00fc566e93374acd4c8999443f4b48f79da05b9 Mon Sep 17 00:00:00 2001 From: mosle Date: Tue, 16 Jan 2024 17:39:34 +0900 Subject: [PATCH] feat(lambda-edge): Add Type to request for Lambda@Edge adapter to support S3 origin (#1991) --- src/adapter/lambda-edge/handler.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/adapter/lambda-edge/handler.ts b/src/adapter/lambda-edge/handler.ts index 42126dfc..96ad19b5 100644 --- a/src/adapter/lambda-edge/handler.ts +++ b/src/adapter/lambda-edge/handler.ts @@ -27,6 +27,17 @@ interface CloudFrontCustomOrigin { readTimeout: number sslProtocols: string[] } +// https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-event-structure.html +interface CloudFrontS3Origin { + authMethod: 'origin-access-identity' | 'none' + customHeaders: CloudFrontHeaders + domainName: string + path: string + region: string +} +type CloudFrontOrigin = + | { s3: CloudFrontS3Origin; custom?: never } + | { custom: CloudFrontCustomOrigin; s3?: never } export interface CloudFrontRequest { clientIp: string @@ -40,9 +51,7 @@ export interface CloudFrontRequest { encoding: string data: string } - origin?: { - custom: CloudFrontCustomOrigin - } + origin?: CloudFrontOrigin } export interface CloudFrontResponse {