Skip to content

Commit

Permalink
up runtime and update deploy script for sdk v3
Browse files Browse the repository at this point in the history
  • Loading branch information
agnesgaroux committed Dec 9, 2024
1 parent 963cd44 commit 591bd6a
Show file tree
Hide file tree
Showing 6 changed files with 1,228 additions and 114 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM public.ecr.aws/docker/library/node:16-slim
FROM public.ecr.aws/docker/library/node:20-slim

RUN apt-get update && apt-get install -yq --no-install-recommends zip

Expand Down
34 changes: 21 additions & 13 deletions cloudfront/iiif.wellcomecollection.org/edge-lambda/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,35 @@ const s3Bucket = 'wellcomecollection-edge-lambdas'
const s3Key = 'iiif/dlcs_path_rewrite.zip'
const roleArn = 'arn:aws:iam::760097843905:role/platform-ci'

const AWS = require('aws-sdk');
const fs = require('fs');
const { S3Client, PutObjectCommand } = require("@aws-sdk/client-s3")
const { fromTemporaryCredentials } = require("@aws-sdk/credential-providers")
const fs = require("fs")

const roleCredentials = new AWS.ChainableTemporaryCredentials({params: {RoleArn: roleArn}});
const s3 = new AWS.S3({ apiVersion: '2006-03-01' , credentials: roleCredentials});
const s3Client = new S3Client({
region: "us-east-1",
credentials: fromTemporaryCredentials({
params: {
RoleArn: roleArn,
},
clientConfig: { region: "us-east-1" },
}),
});

try {
const data = fs.readFileSync(zipLocation);
const data = fs.readFileSync(zipLocation)

const params = {
Body: data,
const command = new PutObjectCommand({
Bucket: s3Bucket,
Key: s3Key,
Body: data,
ACL: 'private',
ContentType: 'application/zip',
};
ContentType: 'application/zip'
})

s3.putObject(params, function(err, data) {
if (err) console.log(err, err.stack);
else console.log('Finished uploading ' + zipLocation + ' to s3://' + s3Bucket + '/' + s3Key);
});
s3Client.send(command, function(err, data) {
if (err) console.log(err, err.stack)
else console.log(`Finished uploading ${zipLocation} to s3://${s3Bucket}/${s3Key}`)
})

} catch (e) {
console.log('Error:', e.stack);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "1.0.0",
"main": "index.js",
"engines": {
"node": "16.*.*"
"node": "20.*.*"
},
"license": "MIT",
"scripts": {
Expand All @@ -23,6 +23,7 @@
"typescript": "^4.1.3"
},
"dependencies": {
"aws-sdk": "^2.836.0"
"@aws-sdk/client-s3": "3.703.0",
"@aws-sdk/credential-providers": "^3.699.0"
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
CloudFrontRequestHandler,
} from 'aws-lambda';
import {CloudFrontRequest} from "aws-lambda/common/cloudfront";
import { CloudFrontRequest } from "aws-lambda/common/cloudfront";

export const request: CloudFrontRequestHandler = (event, context, callback) => {
const request: CloudFrontRequest = event.Records[0].cf.request;
Expand Down
Loading

0 comments on commit 591bd6a

Please sign in to comment.