From 156d076923233306e056abeb5c59cbf5270c8ace Mon Sep 17 00:00:00 2001 From: Nick-ncsu Date: Fri, 10 May 2024 15:46:57 -0400 Subject: [PATCH] Update aws-sdk v2 to v3 --- src/actions.test.ts | 13 +++++++------ src/actions.ts | 14 ++++++-------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/actions.test.ts b/src/actions.test.ts index c290ed9..2ab7a27 100644 --- a/src/actions.test.ts +++ b/src/actions.test.ts @@ -63,12 +63,13 @@ describe.each([[{ storedActionData: false }], [{ storedActionData: true }]])( mockJiraClient.findIssue = jest.fn().mockResolvedValueOnce(foundIssue); mockJiraClient.addAttachmentOnIssue = jest.fn().mockResolvedValueOnce({}); - mockS3Client.getObject = jest.fn().mockImplementation(() => ({ - promise: () => - Promise.resolve({ - Body: JSON.stringify(actionProperties), - }), - })); + mockS3Client.getObject = jest.fn().mockImplementation(() => { + return { + Body: { + transformToString: () => JSON.stringify(actionProperties), + }, + }; + }); actionProperties = { classification: 'Task', diff --git a/src/actions.ts b/src/actions.ts index e3b2f90..0fc703e 100644 --- a/src/actions.ts +++ b/src/actions.ts @@ -1,4 +1,4 @@ -import { GetObjectCommand, S3, S3Client } from '@aws-sdk/client-s3'; +import { S3 } from '@aws-sdk/client-s3'; import { Issue, IssueFields, @@ -144,18 +144,16 @@ function isValidCreateIssueActionProperties( } async function getStoredActionData( - s3Client: S3Client, + s3Client: S3, actionDataS3Key: string, ): Promise { if (!jupiteroneEnv) { throw new Error('Environment variable JUPITERONE_ENVIRONMENT must be set.'); } - const { Body: s3ObjectBody } = await s3Client.send( - new GetObjectCommand({ - Bucket: `${jupiteroneEnv}-${jiraActionsBucket}`, - Key: actionDataS3Key, - }), - ); + const { Body: s3ObjectBody } = await s3Client.getObject({ + Bucket: `${jupiteroneEnv}-${jiraActionsBucket}`, + Key: actionDataS3Key, + }); if (!s3ObjectBody) { throw new Error('Could not fetch action data.');