Migrate AWS SDK for JavaScript v2 to v3

Proprietary

Moves code from aws-sdk (v2) to the modular @aws-sdk/* v3 packages the way AWS's aws-sdk-js-codemod does by default: each v2 client becomes the v3 client class of the same shape (new S3(...), await s3.getObject(...)), so call sites change minimally (ReplaceAwsSdkV2Clients). A lock group (a workspace root with its members, or a standalone package.json) is migrated whole or left unchanged. What has no mechanical v3 equivalent (global AWS.config, AWS.Request and its events, credential classes, $response, an S3 Body read as a Buffer, waiters, an exported client another file still calls as v2, ...) keeps its file on v2 and is listed in the AwsSdkManualMigrationSteps data table (FindAwsSdkV2ManualMigrations). Its lock group then keeps every source, package.json and lock as it was, and is listed in the AwsSdkSkippedLockGroups data table with the files that hold it back. In a group that migrates, each package.json declaring aws-sdk gets the @aws-sdk/* packages its sources import (AddAwsSdkV3Dependencies) and loses aws-sdk, with the lock file regenerated (RemoveUnusedAwsSdkV2Dependency). Migrate what the tables list by hand, then run the recipe again for the rest. Current v3 releases require Node.js 20 or later: a group whose oldest declared Node.js (engines.node, .nvmrc, .node-version, a Lambda runtime in serverless.yml, a SAM or CloudFormation template, CDK's Runtime.NODEJS_18_X or a 'nodejs18.x' literal) is 18 or 19 gets the last releases that support it (>=3.723.0 <3.968.0), and an older one is left on v2 and listed in AwsSdkSkippedLockGroups. Each migrated group is listed in AwsSdkLockGroupNodeVersions, flagged where it declares no Node.js.

org.openrewrite.node.migrate.aws-sdk-v3.migrate-aws-sdk-v2-to-v3

Optional

The version range to declare for each added @aws-sdk/* package. A lock group whose oldest declared Node.js can't run the newest release it admits is left on v2.

mod run . --recipe=org.openrewrite.node.migrate.aws-sdk-v3.migrate-aws-sdk-v2-to-v3

Install it once, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.