Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CloudFrontResponseEvent, CloudFrontResponse } from "aws-lambda";
import { S3 } from "aws-sdk"; // Lambda comes pre-bundled with SDK v2, so use that instead of v3 for now
import { GetObjectCommand, S3Client } from "@aws-sdk/client-s3";

const s3 = new S3();
const s3 = new S3Client({});

const CSP_OBJECT = process.env.CSP_OBJECT;
const S3_BUCKET = process.env.S3_BUCKET;
Expand Down Expand Up @@ -32,18 +32,15 @@ export const handler = async (
throw new Error("CSP_FILE or S3_BUCKET environment variable is missing");
}

const params: S3.GetObjectRequest = {
Bucket: S3_BUCKET,
Key: CSP_OBJECT,
};
const params = { Bucket: S3_BUCKET, Key: CSP_OBJECT };

const s3Object = await s3.getObject(params).promise();
const s3Object = await s3.send(new GetObjectCommand(params));

if (!s3Object.Body) {
throw new Error("CSP file is empty or missing");
}

csp += s3Object.Body.toString("utf-8");
csp += s3Object.Body.toString();

console.log("CSP file retrieved:", csp);

Expand Down
3 changes: 2 additions & 1 deletion packages/static-hosting/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aligent/cdk-static-hosting",
"version": "2.4.0",
"version": "2.7.1",
"main": "index.js",
"license": "GPL-3.0-only",
"homepage": "https://github.com/aligent/aws-cdk-static-hosting-stack#readme",
Expand All @@ -24,6 +24,7 @@
"typescript": "^5.3.2"
},
"dependencies": {
"@aws-sdk/client-s3": "^3.787.0",
"source-map-support": "^0.5.21"
},
"peerDependencies": {
Expand Down
Loading