Skip to content

chore: migrate AWS SDK for JavaScript v2 APIs to v3#11890

Closed
trivikr wants to merge 4 commits intointel:syclfrom
trivikr:aws-sdk-js-codemod
Closed

chore: migrate AWS SDK for JavaScript v2 APIs to v3#11890
trivikr wants to merge 4 commits intointel:syclfrom
trivikr:aws-sdk-js-codemod

Conversation

@trivikr
Copy link
Copy Markdown

@trivikr trivikr commented Nov 15, 2023

From AWS SDK for JavaScript v2 README:

We are formalizing our plans to make the Maintenance Announcement (Phase 2) for AWS SDK for JavaScript v2 in 2023.

This PR migrates AWS SDK for JavaScript v2 APIs to v3 using aws-sdk-js-codemod.

$ npx aws-sdk-js-codemod@0.28.2 -t v2-to-v3 devops/actions/**/*.js

@trivikr trivikr marked this pull request as ready for review November 15, 2023 10:22
@trivikr trivikr requested a review from a team as a code owner November 15, 2023 10:22
params.BlockDeviceMappings = [ {DeviceName: items[0], Ebs: {VolumeSize: items[1]}} ];
}
const result = await ec2.runInstances(params).promise();
const result = await ec2.runInstances(params);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for (const instance of reservation.Instances) {
try {
await ec2.terminateInstances({ InstanceIds: [ instance.InstanceId ] }).promise();
await ec2.terminateInstances({ InstanceIds: [ instance.InstanceId ] });
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try {
instances = await ec2.describeInstances({
Filters: [ { Name: "tag:Label", Values: [ label ] } ]
}).promise();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// starts AWS EC2 instance that will spawn Github runner for a given label
async function start(param_type, param_label, param_ami, param_spot, param_disk, param_timebomb, param_onejob) {
const ec2 = new AWS.EC2();
const ec2 = new EC2({
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move this code for ec2 object creation outside this function (ideally it should be only called only once before start ort stop function call) since this function can be called in the loop and creating several copies of this EC2 object is not the best practice I guess.

// last error that will be thrown in case something will break here
let last_error;
const ec2 = new AWS.EC2();
const ec2 = new EC2({
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please try to avoid this code duplication with start function and pass ec2 as start/stop function param.

const core = require('@actions/core');
const github = require('@actions/github');
const AWS = require('aws-sdk');
const { EC2, waitUntilInstanceRunning } = require('@aws-sdk/client-ec2');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was you able to test these changes in your own repo or it can potentially break stuff?

@trivikr
Copy link
Copy Markdown
Author

trivikr commented Nov 17, 2023

@apstasen This PR (and others on public GitHub repos) is meant to be a proof of concept for v2 to v3 migration. The changes are minimal and mostly use codemod, i.e. use v2 style of making API calls and don't add any optimization.

Can it be merged after testing, and improvements taken up separately? The API calls have been tested since v3 dev-preview since 2018, and v3 has been GA since Dec 2020.

@trivikr
Copy link
Copy Markdown
Author

trivikr commented Mar 11, 2024

AWS SDK for JavaScript v2 will enter maintenance mode on September 8, 2024 and reach end-of-support on September 8, 2025.

For more information, check blog post at https://a.co/cUPnyil

@github-actions
Copy link
Copy Markdown
Contributor

This pull request is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be automatically closed in 30 days.

@github-actions github-actions Bot added the Stale label Sep 13, 2024
@trivikr
Copy link
Copy Markdown
Author

trivikr commented Sep 13, 2024

AWS SDK for JavaScript v2 has entered maintenance mode. It will reach end-of-support on September 8, 2025.

For more information, check blog post at a.co/cUPnyil

@github-actions github-actions Bot removed the Stale label Sep 14, 2024
@github-actions
Copy link
Copy Markdown
Contributor

This pull request is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be automatically closed in 30 days.

@github-actions github-actions Bot added the Stale label Mar 13, 2025
@github-actions
Copy link
Copy Markdown
Contributor

This pull request was closed because it has been stalled for 30 days with no activity.

@github-actions github-actions Bot closed this Apr 12, 2025
@trivikr trivikr deleted the aws-sdk-js-codemod branch April 13, 2025 02:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants