今日は、AWS Transform を使って、AWS Lambda 関数のランタイムを自動でアップグレードしてみます。
AWS Transform とは
https://docs.aws.amazon.com/transform/latest/userguide/what-is-service.html
AWS Transform は、インフラ・アプリケーション・コードのモダナイズや移行を、AIエージェントを活用して加速・簡素化するサービスです。主な用途としては、IBMメインフレーム(z/OS)やFujitsu GS21のAWS移行、VMwareワークロードのEC2移行、.NETアプリケーションのLinux対応モダナイズ、そして移行準備状況のアセスメントなどに対応しています。
発見・計画・実行の各フェーズにわたる労力のかかる複雑な変換作業をAIエージェントに委ねることで、時間のかかるバージョンアップやライブラリの入れ替え作業を自動化することで労力を大幅に短縮させることができまsう。
AWS Transformの利用に追加料金は発生せず、無料で利用が可能です。
さっそくやってみる
AWSの公式ブログに、Lambda のランタイム を、Python 3.8ら 3.13へ自動でアップグレードするサンプルが出ていますのでやってみます。
1.IAMユーザーの準備
AWS Transform は CLI ツールです。このためAWS Credentials が必要となりますので、以下のポリシーが付与されたIAMユーザーとアクセスキーを準備しておきます。
{
"Version": "2012-10-17" ,
"Statement": [
{
"Effect": "Allow",
"Action": [
"transform-custom:*"
],
"Resource": "*"
}
]
}2. Git から Lambda プロジェクトをクローン
PythonベースのLambdaプロジェクトをクローンしておきます。
git clone https://github.com/aws-samples/sam-python-crud-sample.git cd sam-python-crud-sampleこのLambda関数はPython3.8を用いて作成されています。
3. AWS Transform のインストール
curl -fsSL https://transform-cli.awsstatic.com/install.sh | bashこちらのコマンドでインストールを行った後一度シェルを再起動します。その後インストールがされているかバージョン確認を実行しておきます。
atx --version4. テストの実行
AWS Transform を実行してアップグレードを行う前に、GitからクローンしたLambda関数が正しく動作するかどうかローカルでテストを行います。
uv venv --python 3.8 # uv will automatically download Python 3.8 if not already installed
source .venv/bin/activate
uv pip install -r requirements.txt
uv pip install -r requirements_dev.txt
uv pip install "moto[dynamodb]<3"
python -m pytest tests/ -v -o "addopts="5. AWS Transformの起動とアップグレード
いよいよ起動していきます。
atx -t
█████╗ ██╗ ██╗███████╗
██╔══██╗██║ ██║██╔════╝
███████║██║ █╗ ██║███████╗
██╔══██║██║███╗██║╚════██║
██║ ██║╚███╔███╔╝███████║
╚═╝ ╚═╝ ╚══╝╚══╝ ╚══════╝
████████╗██████╗ █████╗ ███╗ ██╗███████╗███████╗ ██████╗ ██████╗ ███╗ ███╗
╚══██╔══╝██╔══██╗██╔══██╗████╗ ██║██╔════╝██╔════╝██╔═══██╗██╔══██╗████╗ ████║
██║ ██████╔╝███████║██╔██╗ ██║███████╗█████╗ ██║ ██║██████╔╝██╔████╔██║
██║ ██╔══██╗██╔══██║██║╚██╗██║╚════██║██╔══╝ ██║ ██║██╔══██╗██║╚██╔╝██║
██║ ██║ ██║██║ ██║██║ ╚████║███████║██║ ╚██████╔╝██║ ██║██║ ╚═╝ ██║
╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═══╝╚══════╝╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝
┌──────────────────────────────────────────────────────────────────────────────┐
│ Region: us-east-1 │
└──────────────────────────────────────────────────────────────────────────────┘
┌──────────────────────────────────────────────────────────────────────────────┐
│ 🟡 All tools are now trusted. ATX will execute tools without asking for │
│ confirmation. │
└──────────────────────────────────────────────────────────────────────────────┘
Welcome to AWS Transform. You can discover, create, and execute transformations (AWS-managed or custom ones published to your registry). How can I help?list all the transformations availableと入力すると利用可能なツールの一覧が出てきます。
⋮
Found 10 transformation definitions
- 10 AWS Managed transformations
🏢 AWS Managed Transformations:
┌─────┬───────────────────────────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────┬────────────┐
│ # │ Transformation Name │ Description │ Version │
├─────┼───────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────┼────────────┤
│ 1 │ 🏢 AWS/java-aws-sdk-v1-to-v2 │ Upgrade the AWS SDK from V1 to V2 for Java projects using Maven or Gradle. │ 2025-10-16 │
│ │ │ │ │
├─────┼───────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────┼────────────┤
│ 2 │ 🏢 AWS/nodejs-aws-sdk-v2-to- │ Upgrade Node.js applications from AWS SDK for JavaScript v2 to v3 to leverage modular architectu │ 2025-10-16 │
│ │ v3 │ re, first-class TypeScript support, middleware stack, and improved performance while ensuring al │ │
│ │ │ l AWS service interactions continue to function correctly, without modifying the underlying Node │ │
│ │ │ .js version. │ │
├─────┼───────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────┼────────────┤
│ 3 │ 🏢 AWS/python-boto2-to-boto3 │ Migrate Python applications from boto2 to boto3, based on the official AWS migration documentati │ 2025-10-16 │
│ │ │ on │ │
├─────┼───────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────┼────────────┤
│ 4 │ 🏢 AWS/python-version-upgrad │ Migrate Python projects from Python 3.8/3.9 to Python 3.11/3.12/3.13, ensuring compatibility wit │ 2025-10-01 │
│ │ e │ h the latest Python features, security updates, and runtime while maintaining functionality and │ │
│ │ │ performance. You can specify your desired target Python version either through interactive chat │ │
│ │ │ with the agent, or by passing an additionalPlanContext configuration parameter (ex. atx custom d │ │
│ │ │ ef exec --configuration "additionalPlanContext=This is a Python app that should be upgraded to P │ │
│ │ │ ython 3.12"). You can also pass this in a configuration file (ex. atx custom def exec --configur │ │
│ │ │ ation 'file://config.json'). For an example configuration file, run atx custom def exec -h │ │
├─────┼───────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────┼────────────┤
│ 5 │ 🏢 AWS/nodejs-version-upgrad │ Upgrade NodeJS applications from any source NodeJS version to any target NodeJS version. You can │ 2026-02-20 │
│ │ e │ specify your desired target NodeJS version either through interactive chat with the agent, or b │ │
│ │ │ y passing an additionalPlanContext configuration parameter (ex. atx custom def exec --configurat │ │
│ │ │ ion "additionalPlanContext=This is a Node.js app that should be upgraded to Node.js 22"). You ca │ │
│ │ │ n also pass this in a configuration file (ex. atx custom def exec --configuration 'file://config │ │
│ │ │ .json'). For an example configuration file, run atx custom def exec -h │ │
├─────┼───────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────┼────────────┤
│ 6 │ 🏢 AWS/early-access-comprehe │ This transformation performs deep static analysis of codebases to generate hierarchical, cross-r │ 2026-02-16 │
│ │ nsive-codebase-analysis │ eferenced documentation covering all aspects of the system. It combines behavioral analysis, arc │ │
│ │ │ hitectural documentation, and business intelligence extraction to create a comprehensive knowled │ │
│ │ │ ge base organized for maximum usability and navigation. The transformation places special emphas │ │
│ │ │ is on technical debt analysis, providing prominent, actionable insights on outdated components, │ │
│ │ │ security vulnerabilities, and maintenance concerns at the root level. │ │
├─────┼───────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────┼────────────┤
│ 7 │ 🏢 AWS/java-version-upgrade │ Upgrade Java applications using any build system from any source JDK version to any target JDK v │ 2025-11-11 │
│ │ │ ersion with comprehensive dependency modernization including Jakarta EE migration, database driv │ │
│ │ │ ers, ORM frameworks, and Spring ecosystem updates. You can specify your desired target JDK versi │ │
│ │ │ on either through interactive chat with the agent, or by passing an additionalPlanContext config │ │
│ │ │ uration parameter (ex. atx custom def exec --configuration "additionalPlanContext=This is a Mave │ │
│ │ │ n app that should be upgraded to Java 21"). You can also pass this in a configuration file (ex. │ │
│ │ │ atx custom def exec --configuration 'file://config.json'). For an example configuration file, ru │ │
│ │ │ n atx custom def exec -h │ │
├─────┼───────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────┼────────────┤
│ 8 │ 🏢 AWS/early-access-java-x86 │ Validates Java application compatibility with Arm64 architecture for running on AWS Graviton Pro │ 2026-02-06 │
│ │ -to-graviton │ cessors. Identifies and resolves Arm64 incompatibilities by updating dependencies, detecting arc │ │
│ │ │ hitecture-specific code patterns, and recompiling native libraries when source code is available │ │
│ │ │ . Makes targeted code modifications necessary for Arm64 support (architecture detection, native │ │
│ │ │ library loading, etc.) but does not perform general code refactoring. Maintains current Java ver │ │
│ │ │ sion and JDK distribution and validates compatibility through build and test execution. For opti │ │
│ │ │ mal results, run in an Arm64-based environment. Note: Many modern Java applications are already │ │
│ │ │ Arm64-compatible. │ │
├─────┼───────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────┼────────────┤
│ 9 │ 🏢 AWS/early-access-angular- │ Transform an Angular application to React. │ 2026-02-20 │
│ │ to-react-migration │ │ │
├─────┼───────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────┼────────────┤
│ 10 │ 🏢 AWS/early-access-java-per │ Optimize Java application performance by analyzing JFR profiling data to detect CPU/memory hotsp │ 2026-02-20 │
│ │ formance-optimization │ ots and anti-patterns, then applying targeted code fixes to reduce resource usage and improve ef │ │
│ │ │ ficiency. Instructions on collecting JFR data can be found here - https://docs.oracle.com/javaco │ │
│ │ │ mponents/jmc-5-4/jfr-runtime-guide/run.htm. │ │
└─────┴───────────────────────────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────┴────────────┘
● Completed in 1.6s
> Here are the available transformations in the registry. There are 10 AWS Managed transformations and no user transformations currently.
You can select a transformation by entering either its number (e.g., "1", "2", "3") or its exact name (e.g., "AWS/java-aws-sdk-v1-to-v2").
Would you like to select one, or would you prefer to create a new custom transformation?Run AWS/python-version-upgrade on my projectと入力します。
I'd like to apply the AWS/python-version-upgrade transformation to your project. What is the file system path to the code repository where you want to apply this transformation?今までの手順ではプロジェクトフォルダで atx を起動していますので . と入力して作業を進めます。
あとは対話しながら作業を進めます。かなり長い出力がされますが最後に以下が表示されます。
FIXES APPLIED:
1. Updated README.md line 23: Changed "python 3.7" to "python 3.12" in the Prerequisites section to satisfy Criterion 4.
● Completed in 1ms
> **Validation successful — All exit criteria now pass: 5/5 exit criteria passed.**念のため本当に作業が完了したら尋ねると以下の様に出力されました。
> did you finish upgrade?
> Yes, the upgrade is complete. The migration of the sam-python-crud-sample project from Python 3.8 to Python 3.12 has been fully finished. Here's a summary of what was done:
**Configuration files updated:**
- **template.yaml**: All 5 Lambda function runtimes updated to `python3.12`
- **setup.py**: Classifier updated to `Python :: 3.12`
- **tox.ini**: envlist updated to `py312,flake8`
- **.github/workflows/pythonpackage.yml**: Python version matrix updated to `[3.12]`
- **README.md**: Prerequisites updated from "python 3.7" to "python 3.12" (fixed during this session)
**Validation results:**
- ✅ All 5 Lambda handler source files compile successfully on Python 3.12
- ✅ All 10 unit tests pass (100% pass rate maintained)
- ✅ All dependencies (boto3, pytest, moto, tox) are compatible and installed on Python 3.12
- ✅ All documentation updated to reflect Python 3.12
- ✅ All deployment scripts updated to use Python 3.12
All 5/5 exit criteria are passing. Do you have any other feedback or questions about the transformation execution?
