File tree Expand file tree Collapse file tree 3 files changed +1910
-2760
lines changed
Expand file tree Collapse file tree 3 files changed +1910
-2760
lines changed Original file line number Diff line number Diff line change 11import { CloudFrontResponseEvent , CloudFrontResponse } from "aws-lambda" ;
2- import { S3 } from "aws-sdk" ; // Lambda comes pre-bundled with SDK v2, so use that instead of v3 for now
2+ import { GetObjectCommand , S3Client } from "@ aws-sdk/client-s3" ;
33
4- const s3 = new S3 ( ) ;
4+ const s3 = new S3Client ( { } ) ;
55
66const CSP_OBJECT = process . env . CSP_OBJECT ;
77const S3_BUCKET = process . env . S3_BUCKET ;
@@ -32,18 +32,15 @@ export const handler = async (
3232 throw new Error ( "CSP_FILE or S3_BUCKET environment variable is missing" ) ;
3333 }
3434
35- const params : S3 . GetObjectRequest = {
36- Bucket : S3_BUCKET ,
37- Key : CSP_OBJECT ,
38- } ;
35+ const params = { Bucket : S3_BUCKET , Key : CSP_OBJECT } ;
3936
40- const s3Object = await s3 . getObject ( params ) . promise ( ) ;
37+ const s3Object = await s3 . send ( new GetObjectCommand ( params ) ) ;
4138
4239 if ( ! s3Object . Body ) {
4340 throw new Error ( "CSP file is empty or missing" ) ;
4441 }
4542
46- csp += s3Object . Body . toString ( "utf-8" ) ;
43+ csp += s3Object . Body . toString ( ) ;
4744
4845 console . log ( "CSP file retrieved:" , csp ) ;
4946
Original file line number Diff line number Diff line change 11{
22 "name" : " @aligent/cdk-static-hosting" ,
3- "version" : " 2.4.0 " ,
3+ "version" : " 2.7.1 " ,
44 "main" : " index.js" ,
55 "license" : " GPL-3.0-only" ,
66 "homepage" : " https://github.com/aligent/aws-cdk-static-hosting-stack#readme" ,
2424 "typescript" : " ^5.3.2"
2525 },
2626 "dependencies" : {
27+ "@aws-sdk/client-s3" : " ^3.787.0" ,
2728 "source-map-support" : " ^0.5.21"
2829 },
2930 "peerDependencies" : {
You can’t perform that action at this time.
0 commit comments