Open trivikr opened 1 year ago
The codemod defaults to making minimal changes to the customer code to move from v2 to v3. And the code written in v2 will never use command style of calling APIs, as it was introduced in v3.
A better solution could be to write a different transform which converts application code which uses v3 aggregated client to v3 barebones client. That transform can be written separately, but used by default in v2-to-v3
.
Example (transform name is assumed to be to-bare-bones-client
):
$ cat example.ts
import { DynamoDB } from "@aws-sdk/client-dynamodb";
const region = "us-west-2";
const client = new DynamoDB({ region });
const response = await client.listTables();
$ npx aws-sdk-js-codemod -t to-bare-bones-client example.ts
$ cat example.ts
import { DynamoDB, ListTablesCommand } from "@aws-sdk/client-dynamodb";
const region = "us-west-2";
const client = new DynamoDB({ region });
const response = await client.send(new ListTablesCommand({}));
In https://github.com/awslabs/aws-sdk-js-codemod/issues/480#issuecomment-1480352172, the name api-to-command
was recommended for transformer which updates JS SDK v3 code to use commands.
We discussed the naming during scrum on 2023-08-15, we decided to stick with to-command-syntax
name for the transformer.
We discussed the naming during scrum on 2023-08-15, we decided to stick with
to-command-syntax
name for the transformer.
Are there any updates to this? Are there any known community provided transformers out there? We're actively migrating now so this would be a huge win.
Self-service
Template name
v2-to-v3
Input code
Expected Output
Existing output
Recommended output
Additional context
Reference blog post: https://www.10printiamcool.com/updating-to-nodejs-18-and-aws-javascript-sdk-v3-part-1