re:Invent2025に参加しており、ラスベガス生活も数日経過しました。サーバーワークスの今野です。
さて、今回のブログでは「Opening Keynote with Matt Garman (KEY001)」でもご紹介がありました、AWS Transform customについて試してみた内容をご紹介したいと思います!
概要
本ブログでは、Node.js 14からNode.js 22へモダナイズすることを想定し、AWS Transform customをどう活用出来そうか検証してみました。
前提
変換対象:Node.js 14
CommonJSベースでかかれたサンプルコードを下記の通り用意しました。
// server.js
// CommonJS形式の読み込み
var express = require('express');
var app = express();
var port = 3000;
// ダミーのデータ取得関数(コールバック形式)
function getUserData(id, callback) {
setTimeout(function() {
if (id === 1) {
callback(null, { id: 1, name: "Taro", role: "Admin" });
} else {
callback("User not found", null);
}
}, 500);
}
// ルートエンドポイント
app.get('/', function(req, res) {
res.send('Hello from Legacy Node.js!');
});
// ユーザー情報取得エンドポイント
app.get('/user/:id', function(req, res) {
var userId = parseInt(req.params.id);
// コールバックによる処理
getUserData(userId, function(err, data) {
if (err) {
res.status(404).send(err);
} else {
res.json(data);
}
});
});
app.listen(port, function() {
console.log('Server is running on port ' + port);
});
事前準備
変換作業を実行するための準備として、下記AWS公式ドキュメントを参考にしてAWS Transform CLI のインストールを実施しました。
Gitリポジトリも前提として必要であることが留意事項です。
Git - 変換を実行するには、Gitがインストールされており、作業ディレクトリが有効なGitリポジトリである必要があります。実行するgit init; git add .; git commit -m "Initial commit"と、作業ディレクトリにGitリポジトリが初期化されます。
$ curl -fsSL https://desktop-release.transform.us-east-1.api.aws/install.sh | bash Setting up CLI... ℹ Installing latest version: 1.0.0 ℹ Installing atx CLI version 1.0.0 for darwin-arm64... ℹ Checking dependencies... ✔ Node.js version 25.2.1 detected (>= 20) ℹ Setting up directories... ℹ Release date: 2025-11-26T22:38:02Z ℹ Archive name: atx.zip ℹ Downloading atx CLI... ✔ Checksum verification passed ℹ Extracting atx CLI... ℹ 📋 CHANGELOG.md available at: ~/.local/share/atx/1.0.0/CHANGELOG.md ℹ Creating symlink... ✔ atx successfully installed! Version: 1.0.0 Location: ~/.local/bin/atx Next: Run atx --help to get started ✔ Installation complete! bash-5.2$ atx --version Version: 1.0.0
ブログ執筆時点(公開直後)では、バージョンが1.0.0となっています。
さて、インストールも出来たところなので、atxコマンドを実行していきます。
実行後、下記の画面が表示されてAWS Transformエージェントと事前言語で会話が出来るようになります。
$ atx █████╗ ██╗ ██╗███████╗ ██╔══██╗██║ ██║██╔════╝ ███████║██║ █╗ ██║███████╗ ██╔══██║██║███╗██║╚════██║ ██║ ██║╚███╔███╔╝███████║ ╚═╝ ╚═╝ ╚══╝╚══╝ ╚══════╝ ████████╗██████╗ █████╗ ███╗ ██╗███████╗███████╗ ██████╗ ██████╗ ███╗ ███╗ ╚══██╔══╝██╔══██╗██╔══██╗████╗ ██║██╔════╝██╔════╝██╔═══██╗██╔══██╗████╗ ████║ ██║ ██████╔╝███████║██╔██╗ ██║███████╗█████╗ ██║ ██║██████╔╝██╔████╔██║ ██║ ██╔══██╗██╔══██║██║╚██╗██║╚════██║██╔══╝ ██║ ██║██╔══██╗██║╚██╔╝██║ ██║ ██║ ██║██║ ██║██║ ╚████║███████║██║ ╚██████╔╝██║ ██║██║ ╚═╝ ██║ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═══╝╚══════╝╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ┌──────────────────────────────────────────────────────────────────────────────┐ │ Trusted Tools │ │ │ │ Built-in Trusted Tools │ │ Configuration: Built-in read-only tools │ │ • file_read │ │ • get_transformation_from_registry │ │ • list_available_transformations_from_registry │ │ • document_manager (add operations only) │ └──────────────────────────────────────────────────────────────────────────────┘ Welcome to AWS Transform. You can discover, create, and execute transformations (AWS-managed or custom ones published to your registry). How can I help? >
変換する際に変換定義(=transformation definitions)を指定しますので、Transformation Registryから、transformation definitionsを参照しておきます。
※後ほどの実行コマンドでバージョンを明示的に指定するので控えておきます。
$ atx custom def list Listing available transformation definitions... Found 8 transformations: - 8 AWS Managed transformations 🏢 AWS Managed Transformations: ┌──────────────────────────────┬───────────────────────────────────┬──────────────────┐ │ Transformation Name │ Description │ Version │ ├──────────────────────────────┼───────────────────────────────────┼──────────────────┤ │ 🏢 AWS/java-aws-sdk-v1- │ Upgrade the AWS SDK from V1 to V2 │ 2025-10-16 │ │ to-v2 │ for Java projects using Maven or │ │ │ │ Gradle. │ │ ├──────────────────────────────┼───────────────────────────────────┼──────────────────┤ │ 🏢 AWS/nodejs-aws-sdk-v │ Upgrade Node.js applications from │ 2025-10-16 │ │ 2-to-v3 │ AWS SDK for JavaScript v2 to v3 │ │ │ │ to leverage modular architecture, │ │ │ │ first-class TypeScript support, │ │ │ │ middleware stack, and improved pe │ │ │ │ rformance while ensuring all AWS │ │ │ │ service interactions continue to │ │ │ │ function correctly, without modif │ │ │ │ ying the underlying Node.js versi │ │ │ │ on. │ │ ├──────────────────────────────┼───────────────────────────────────┼──────────────────┤ │ 🏢 AWS/python-boto2-to- │ Migrate Python applications from │ 2025-10-16 │ │ boto3 │ boto2 to boto3, based on the offi │ │ │ │ cial AWS migration documentation │ │ ├──────────────────────────────┼───────────────────────────────────┼──────────────────┤ │ 🏢 AWS/python-version-u │ Migrate Python projects from Pyth │ 2025-10-01 │ │ pgrade │ on 3.8/3.9 to Python 3.11/3.12/3. │ │ │ │ 13, ensuring compatibility with t │ │ │ │ he latest Python features, securi │ │ │ │ ty updates, and runtime while mai │ │ │ │ ntaining functionality and perfor │ │ │ │ mance. You can specify your desir │ │ │ │ ed target Python version either t │ │ │ │ hrough interactive chat with the │ │ │ │ agent, or by passing an additiona │ │ │ │ lPlanContext configuration parame │ │ │ │ ter (ex. atx custom def exec --co │ │ │ │ nfiguration "additionalPlanContex │ │ │ │ t=This is a Python app that shoul │ │ │ │ d be upgraded to Python 3.12"). Y │ │ │ │ ou can also pass this in a config │ │ │ │ uration file (ex. atx custom def │ │ │ │ exec --configuration 'file://conf │ │ │ │ ig.json'). For an example configu │ │ │ │ ration file, run atx custom def e │ │ │ │ xec -h │ │ ├──────────────────────────────┼───────────────────────────────────┼──────────────────┤ │ 🏢 AWS/nodejs-version-u │ Upgrade NodeJS applications from │ 2025-11-04 │ │ pgrade │ any source NodeJS version to any │ │ │ │ target NodeJS version. You can sp │ │ │ │ ecify your desired target NodeJS │ │ │ │ version either through interactiv │ │ │ │ e chat with the agent, or by pass │ │ │ │ ing an additionalPlanContext conf │ │ │ │ iguration parameter (ex. atx cust │ │ │ │ om def exec --configuration "addi │ │ │ │ tionalPlanContext=This is a Node. │ │ │ │ js app that should be upgraded to │ │ │ │ Node.js 22"). You can also pass │ │ │ │ this in a configuration file (ex. │ │ │ │ atx custom def exec --configurat │ │ │ │ ion 'file://config.json'). For an │ │ │ │ example configuration file, run │ │ │ │ atx custom def exec -h │ │ ├──────────────────────────────┼───────────────────────────────────┼──────────────────┤ │ 🏢 AWS/early-access-com │ This transformation performs deep │ 2025-11-11 │ │ prehensive-codebase-analysis │ static analysis of codebases to │ │ │ │ generate hierarchical, cross-refe │ │ │ │ renced documentation covering all │ │ │ │ aspects of the system. It combin │ │ │ │ es behavioral analysis, architect │ │ │ │ ural documentation, and business │ │ │ │ intelligence extraction to create │ │ │ │ a comprehensive knowledge base o │ │ │ │ rganized for maximum usability an │ │ │ │ d navigation. The transformation │ │ │ │ places special emphasis on techni │ │ │ │ cal debt analysis, providing prom │ │ │ │ inent, actionable insights on out │ │ │ │ dated components, security vulner │ │ │ │ abilities, and maintenance concer │ │ │ │ ns at the root level. │ │ ├──────────────────────────────┼───────────────────────────────────┼──────────────────┤ │ 🏢 AWS/java-version-upg │ Upgrade Java applications using a │ 2025-11-11 │ │ rade │ ny build system from any source J │ │ │ │ DK version to any target JDK vers │ │ │ │ ion with comprehensive dependency │ │ │ │ modernization including Jakarta │ │ │ │ EE migration, database drivers, O │ │ │ │ RM frameworks, and Spring ecosyst │ │ │ │ em updates. You can specify your │ │ │ │ desired target JDK version either │ │ │ │ through interactive chat with th │ │ │ │ e agent, or by passing an additio │ │ │ │ nalPlanContext configuration para │ │ │ │ meter (ex. atx custom def exec -- │ │ │ │ configuration "additionalPlanCont │ │ │ │ ext=This is a Maven app that shou │ │ │ │ ld be upgraded to Java 21"). You │ │ │ │ can also pass this in a configura │ │ │ │ tion file (ex. atx custom def exe │ │ │ │ c --configuration 'file://config. │ │ │ │ json'). For an example configurat │ │ │ │ ion file, run atx custom def exec │ │ │ │ -h │ │ ├──────────────────────────────┼───────────────────────────────────┼──────────────────┤ │ 🏢 AWS/early-access-jav │ Perform Java compatibility analys │ 2025-11-19 │ │ a-x86-to-graviton │ is and migration of existing code │ │ │ │ to support execution on Arm64 ar │ │ │ │ chitecture for running on Gravito │ │ │ │ n EC2 instances │ │ └──────────────────────────────┴───────────────────────────────────┴──────────────────┘
詳細は、AWS公式ドキュメントをご確認ください。
変換実行(Node.js 14 => Node.js 22)
いよいよ実行です。
> atx custom def exec -n "AWS/nodejs-version-upgrade" --tv "2025-11-04" -p . 📝 Conversation log: xxxx 📊 Monitor progress: xxx If interrupted, you can resume this conversation by running: atx --conversation-id xxxx > I can help you apply the AWS-managed transformation "AWS/nodejs-version-upgrade" to your code repository. To proceed, I need the code repository path where you want to apply this transformation. What is the file system path to the code repository? > node server.js
「Thinking...」と表示され、どのファイルの変換をしたいか聞かれたので教えてあげます。
Would you like to provide any additional guidance (e.g. specific language versions or libraries to use) before I generate a plan?
For example:
- What is the target Node.js version you want to upgrade to? (e.g., Node.js 18, Node.js 20, Node.js 22)
- Are there any specific dependencies or frameworks that need special attention?
- Any other constraints or requirements I should consider?
> Target: Node.js 22.
Please strictly apply the following modernizations:
1. Convert CommonJS ("require") to ES Modules ("import").
2. Refactor callback-style functions to use "async/await".
3. Replace "var" with "const" or "let".
4. Update code comments to reflect the modern syntax (e.g., change descriptions from "CommonJS" to "ES Modules", or "callback" to "Async/Await").
次に、どのバージョンにアップグレードするか聞かれたのでNode.js 22としました。また、モダナイズする際にお願いしたいことを箇条書きの通り指示しました。
その後、操作実行の際に、実行して良いかを確認されますので確認しつつ進めていきます。(非対話モードも設定が可能ですが今回は挙動を見たかったこともあり様子見で序盤は都度確認するようにしてました。)
実行結果
結果として、下記のように変換することが出来ました。
序盤、利用しているツールをひと通り確認しつつ進めてからツールの利用を信用しましたが、変換の所用時間は30分程度でした。
また、指示した内容は概ね反映されていそうです。
// server.js
// ES Modules (ESM) 形式の読み込み
import express from 'express';
const app = express();
const port = 3000;
// ダミーのデータ取得関数 (Promise形式)
function getUserData(id) {
return new Promise((resolve, reject) => {
setTimeout(() => {
if (id === 1) {
resolve({ id: 1, name: "Taro", role: "Admin" });
} else {
reject("User not found");
}
}, 500);
});
}
// ルートエンドポイント
app.get('/', (req, res) => {
res.send('Hello from Modernized Node.js!');
});
// ユーザー情報取得エンドポイント
app.get('/user/:id', async (req, res) => {
let userId = parseInt(req.params.id);
// Async/Await と try-catch による非同期処理
try {
const data = await getUserData(userId);
res.json(data);
} catch (err) {
res.status(404).send(err);
}
});
app.listen(port, () => {
console.log('Server is running on port ' + port);
});
差分(ご参考)
$ git diff <Legacy> <Modernized> server.js
diff --git a/server.js b/server.js
index xxxx..xxxx 100644
--- a/server.js
+++ b/server.js
@@ -1,41 +1,40 @@
-// server.js
+// server.js (Legacy)
-// ES Modules (ESM) 形式の読み込み
-import express from 'express';
-const app = express();
-const port = 3000;
+// 古い: CommonJS形式の読み込み
+var express = require('express');
+var app = express();
+var port = 3000;
-// ダミーのデータ取得関数 (Promise形式)
-function getUserData(id) {
- return new Promise((resolve, reject) => {
- setTimeout(() => {
- if (id === 1) {
- resolve({ id: 1, name: "Taro", role: "Admin" });
- } else {
- reject("User not found");
- }
- }, 500);
- });
+// ダミーのデータ取得関数(コールバック形式)
+function getUserData(id, callback) {
+ setTimeout(function() {
+ if (id === 1) {
+ callback(null, { id: 1, name: "Taro", role: "Admin" });
+ } else {
+ callback("User not found", null);
+ }
+ }, 500);
}
// ルートエンドポイント
-app.get('/', (req, res) => {
- res.send('Hello from Modernized Node.js!');
+app.get('/', function(req, res) {
+ res.send('Hello from Legacy Node.js!');
});
-// ユーザー情報取得エンドポイント
-app.get('/user/:id', async (req, res) => {
- let userId = parseInt(req.params.id);
+// ユーザー情報取得エンドポイント(古い書き方)
+app.get('/user/:id', function(req, res) {
+ var userId = parseInt(req.params.id);
- // Async/Await と try-catch による非同期処理
- try {
- const data = await getUserData(userId);
- res.json(data);
- } catch (err) {
- res.status(404).send(err);
- }
+ // 古い: コールバックによる処理
+ getUserData(userId, function(err, data) {
+ if (err) {
+ res.status(404).send(err);
+ } else {
+ res.json(data);
+ }
+ });
});
-app.listen(port, () => {
+app.listen(port, function() {
console.log('Server is running on port ' + port);
});
\ No newline at end of file
動作
ちゃんと想定通り挙動をしてくれました!
$ curl http://localhost:3000 Hello from Modernized Node.js!
おまけ(GUIでの操作)
今回の検証では、CLIで実施しましたが、GUIでの操作もサポートされているようです。 ただ、公式ドキュメントを見る限り複数のリポジトリにまたがるような大規模変換を監視する色彩が強いとのことなので、シンプルなコードであればCLIの実行が無難かと思いました。個人的にはCLIの方が操作しやすいと感じました。
※操作するためにはIAM Identity Center経由のSSOが前提となっていることからもマルチアカウント環境での大規模変換が想定されているのかな?と思いました。
The AWS Transform web application is an optional interface for monitoring large-scale transformation campaigns across multiple repositories.
おまけ(変換見積もり時間について)
AWS Transformのワークショップ(Modernize .NET Framework workloads with containers and AWS Transform (CNS326))を今回のRe:Inventで受けた際に登壇側と会話する機会があり、「変換時間の見積もり表示するような機能はないの?」と聞いてみましたが、コード量等の環境に起因するのでなんとも言えず、機能としても実装していないとのことでした。(.NET Frameworkの変換のワークショップでしたが、今回でたAWS Transform customに関しても同様とのこと。)
ここは今後に期待です!
さいごに
このブログが、脆弱性などに怯える日々を過ごす皆さまの参考になったら幸いです!

以上、ラスベガスからお届けしました!次回のブログでお会いしましょう!
今野 祐靖(執筆記事の一覧)
2024年4月中途入社 年間約300日ととのうサウナー