Skip to content
This repository has been archived by the owner on Aug 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request #223 from JupiterOne/int-10954-update-aws-sdk
Browse files Browse the repository at this point in the history
Update aws-sdk v2 to v3
  • Loading branch information
Nick-NCSU authored May 14, 2024
2 parents b800224 + ed7674a commit 5ce25b6
Show file tree
Hide file tree
Showing 5 changed files with 1,038 additions and 189 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ docker-compose.yml
.eslintcache
tsconfig.tsbuildinfo
.npmrc
.idea/
.idea/
.DS_Store
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"postversion": "cp package.json ./dist/package.json"
},
"dependencies": {
"aws-sdk": "^2.184.0",
"@aws-sdk/client-s3": "^3.574.0",
"dotenv": "^10.0.0",
"jira-client": "^7.1.0",
"lodash": "^4.17.21",
Expand Down
13 changes: 7 additions & 6 deletions src/actions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
14 changes: 6 additions & 8 deletions src/actions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { S3 } from 'aws-sdk';
import { S3 } from '@aws-sdk/client-s3';
import {
Issue,
IssueFields,
Expand Down Expand Up @@ -150,19 +150,17 @@ async function getStoredActionData(
if (!jupiteroneEnv) {
throw new Error('Environment variable JUPITERONE_ENVIRONMENT must be set.');
}
const { Body: s3ObjectBody } = await s3Client
.getObject({
Bucket: `${jupiteroneEnv}-${jiraActionsBucket}`,
Key: actionDataS3Key,
})
.promise();
const { Body: s3ObjectBody } = await s3Client.getObject({
Bucket: `${jupiteroneEnv}-${jiraActionsBucket}`,
Key: actionDataS3Key,
});

if (!s3ObjectBody) {
throw new Error('Could not fetch action data.');
}

const actionProperties = JSON.parse(
s3ObjectBody.toString('utf-8'),
await s3ObjectBody.transformToString('utf-8'),
) as unknown;
if (!isValidCreateIssueActionProperties(actionProperties)) {
throw new Error(
Expand Down
Loading

0 comments on commit 5ce25b6

Please sign in to comment.