Upgrade to Pro — share decks privately, control downloads, hide ads and more …

AWS Transform Custom さわってみた

Avatar for SPA SPA
December 13, 2025

AWS Transform Custom さわってみた

JAWS-UG京都 Kiroワークショップで仕様駆動開発を体験+re:Invent re:Cap
https://jawsug-kyoto.connpass.com/event/377642/

Avatar for SPA

SPA

December 13, 2025

More Decks by SPA

Other Decks in Technology

Transcript

  1. AWS Transform Custom って何? ・AWS Transform (2025年5月GA)の追加機能 ・re:Invent 2025 で発表(2025年12月1日GA)

    > "AWS Transform のカスタム変換エージェントは、構築済みのソリューション とカスタムソリューションの両方を提供します。Python や Node.js のランタイム アップグレード、Lambda 関数のモダナイズ、複数言語にまたがる AWS SDK の更新、Java 8 から 17 へのアップグレード (Gradle や Maven を含むあらゆ るビルドシステムをサポート) など、一般的なシナリオに対応する変換をすぐに 利用できます。" 出典: AWS What's New 3
  2. AWS Transform Custom って何? ・エージェンティック AI による大規模なモダナイゼーション ・多様なシナリオに対応 - 言語バージョンのアップグレード

    - フレームワークのアップグレードと移行 - コードのリファクタリング - 組織固有の変革 ・2025年12月現在、US East (N. Virginia) リージョンで利用可能 4
  3. AWS Transform Custom って何? ・主な機能/特徴 ・変換ルールを定義できる - 自然言語で独自の変換を定義 ・エージェントが自動実行 -

    Executor + Debuggerで継続学習 ・Git統合で安全に作業 - ワンライナーCLIコマンドで実行 ・AWS管理の変換 - 一般的なシナリオに適用できる、 AWSが検証した変換を利用可能 - Java ランタイムのバージョンアップグレード - Python ランタイムのバージョンアップグレード  ← 今回はコレ - Node.js ランタイムのバージョンアップグレード - Java AWS SDK バージョン 1 から v2 へのバージョンアップグレード - Python AWS SDK バージョンのアップグレード (boto2 → boto3) - Node.js AWS SDK v2 から v3 へのバージョンアップグレード 5
  4. 今回の移行対象 ・プロジェクト: 自作 IoTドアホンアプリ(自宅のインターホンの通知をスマホに飛ばす) ・規模 & 移行内容: ・技術スタック: PyAudio /

    OpenCV / numpy / scipy 項目 内容 ファイル数 6ファイル 総行数 414行 移行内容 Python 3.7 → 3.13.10 (本来は3.8以上 → 3.13以下が対象) 6
  5. 8

  6. 9

  7. 10

  8. 雑な作業フロー 1. インストール & 起動  Windowsの場合、 WSL必須。コマンド一発で 1秒でインストール。  spa@SPA-LAPTOP-01:~/doorphone$ curl

    -fsSL https://desktop-release.transform.us-east-1.api.aws/install.sh | bash  spa@SPA-LAPTOP-01:~/doorphone$ atx █████╗ ██╗ ██╗███████╗ ██╔══██╗██║ ██║██╔════╝ ███████║██║ █╗ ██║███████╗ ██╔══██║██║███╗██║╚════██║ ██║ ██║╚███╔███╔╝███████║ ╚═╝ ╚═╝ ╚══╝╚══╝ ╚══════╝ ████████╗██████╗ █████╗ ███╗ ██╗███████╗███████╗ ██████╗ ██████╗ ███╗ ███╗ ╚══██╔══╝██╔══██╗██╔══██╗████╗ ██║██╔════╝██╔════╝██╔═══██╗██╔══██╗████╗ ████║ ██║ ██████╔╝███████║██╔██╗ ██║███████╗█████╗ ██║ ██║██████╔╝██╔████╔██║ ██║ ██╔══██╗██╔══██║██║╚██╗██║╚════██║██╔══╝ ██║ ██║██╔══██╗██║╚██╔╝██║ ██║ ██║ ██║██║ ██║██║ ╚████║███████║██║ ╚██████╔╝██║ ██║██║ ╚═╝ ██║ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═══╝╚══════╝╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ 11
  9. 雑な作業フロー 2. 簡単な対話  非対話モードと対話モードを選べる。今回は対話モード。  選択肢から選んだり、簡単な質問に答えたり …。(全部英語) ┌─────┬───────────────────────────────────┬──────────────────────────────────────────────────┬────────────┐ │ # │

    Transformation Name │ Description │ Version │ ├─────┼───────────────────────────────────┼──────────────────────────────────────────────────┼────────────┤ │ 1 │ 🏢 AWS/java-aws-sdk-v1-to-v2 │ Upgrade the AWS SDK from V1 to V2 for Java proje │ 2025-10-16 │ │ │ │ cts using Maven or Gradle. │ │ ├─────┼───────────────────────────────────┼──────────────────────────────────────────────────┼────────────┤ │ 2 │ 🏢 AWS/nodejs-aws-sdk-v2-to- │ Upgrade Node.js applications from AWS SDK for Ja │ 2025-10-16 │ │ │ v3 │ vaScript v2 to v3 to leverage modular architectu │ │ │ │ │ re, first-class TypeScript support, middleware s │ │ ---------------------------------- Would you like to provide any additional guidance (e.g., specific target Python version like 3.11, 3.12, or 3.13, or specific libraries to prioritize) before I generate a plan? > 3.13 12
  10. 雑な作業フロー 2.5. 日本語で頼む …! Welcome to AWS Transform. You can

    discover, create, and execute transformations (AWS-managed or custom ones published to your registry). How can I help? > 日本語で 📝 Conversation log: /home/spa/.aws/atx/custom/20251213_054638_74cec1e2/logs/2025-12-13T05-46-41-conversation.log 📊 Monitor progress: tail -f /home/spa/.aws/atx/custom/20251213_054638_74cec1e2/logs/2025-12-13T05-46-41-conversation.log If interrupted, you can resume this conversation by running: atx --conversation-id 20251213_054638_74cec1e2 > 申し訳ございませんが、AWS Transform CLIは現在英語のみでのサポートとなっております。英語でお手伝いさせていただけますでしょうか ? Would you like to create a new custom transformation, or access an existing one? > ダメでした 13
  11. 雑な作業フロー 3. 分析~プラン策定を待つ  Toolを利用してよいか許可を求められる。  trustの(t)を選ぶとドンドコ分析してくれる。 > Thank you for specifying

    Python 3.13 as the target version. Let me analyze the codebase and create a detailed transformation plan. 🛠 Using tool: editor (requested) ⋮ • Path: /home/spa/doorphone/doorphone.py • Command: view Allow tool execution? (y)es/(n)o/(t)rust or provide feedback: t 14
  12. > Perfect! I've created a comprehensive transformation plan for migrating

    this Python doorphone application from Python 3.10 to Python 3.13. Let me present the plan to you: ## Transformation Plan Summary I've analyzed the codebase at `/home/spa/doorphone/` and created a 5-step migration plan to Python 3.13. ### Codebase Analysis: - **Current Version**: Python 3.10.12 - **Target Version**: Python 3.13 - **Project Type**: IoT doorphone monitoring application with audio processing, image capture, and API integrations - **Key Dependencies Identified**: - **pyaudio** - Audio capture and processing - **numpy** - Numerical operations and FFT - **scipy** - Signal processing (argrelmax) - **opencv-python (cv2)** - Image capture and processing - **requests** - HTTP API calls to LINE Messaging API and SwitchBot ### Python Files in Scope: 1. `doorphone.py` - Main application with audio processing and frequency detection 2. `get_image.py` - Camera image capture functionality 3. `get_mic_channel.py` - Microphone device enumeration 4. `line_messaging_api.py` - LINE messaging integration 5. `notify.py` - LINE notification service 6. `switchbot.py` - SwitchBot API integration with HMAC authentication ### Migration Plan Overview: **Step 1: Setup Python 3.13 Virtual Environment and Analyze Dependencies** - Create Python 3.13 virtual environment in /tmp - Create requirements.txt with Python 3.13 compatible versions - Document compatible versions: numpy>=1.26.0, scipy>=1.11.0, opencv-python>=4.8.0, PyAudio>=0.2.13, requests>=2.31.0 **Step 2: Install Dependencies in Python 3.13 Virtual Environment** - Install pytest and all dependencies - Validate successful installation of packages with C extensions - Test imports to ensure compatibility **Step 3: Update Core Application Code for Python 3.13 Compatibility** - Modernize doorphone.py, get_mic_channel.py, get_image.py - Update type hints, exception handling, and string formatting - Ensure NumPy, SciPy, OpenCV, and PyAudio APIs are compatible - Replace bare except clauses with specific exception types **Step 4: Update API Integration Modules for Python 3.13** - Update line_messaging_api.py, notify.py, switchbot.py - Ensure requests library patterns are modern - Update encoding/decoding in HMAC operations - Add type hints and improve exception handling **Step 5: Comprehensive Validation with Python 3.13 Virtual Environment** - Run syntax validation using Python 3.13 py_compile - Test all imports and verify dependency compatibility - Check for deprecation warnings - Validate main entry points load correctly ### Key Considerations: - No existing test suite found, so validation focuses on syntax checking and import verification - Binary dependencies (PyAudio, NumPy, SciPy, OpenCV) require careful version selection for Python 3.13 - The application uses real-time audio processing, so performance must be maintained - API integrations with sensitive tokens (will maintain security best practices) Please review the plan at `~/.aws/atx/custom/20251206_074945_62d89bf3/artifacts/plan.json` and let me know if you would like me to proceed with the transformation, or you can provide feedback and I will adjust the plan. > ok 待つこと10分ほど。 以下のSTEPをやるぜ。と言ってくる 1. 仮想環境セットアップ & 依存関係分析 2. Python 3.13依存関係インストール 3. コアコード更新 4. API統合モジュール更新 5. 包括的検証 15
  13. 雑な作業フロー 4. なんか変換してるのを眺めながら「 ok」「ok」言うてるうちに完成する  Stepごとに勝手に Gitでコミットしてくれる commit 30d6ac4674467417f778212027cd3853bd558dab Date: Sat

    Dec 6 17:33:15 2025 +0900 Step 6: Debug Phase Validation - No Errors Found Build status: Success commit 1ff36ac8071234cb7acf24d121b88243dc137896 Date: Sat Dec 6 17:27:18 2025 +0900 Step 5: Comprehensive Validation with Python 3.13 Virtual Environment Build status: Success ~~中略~~ commit e85416cb8f4d29a4c9865da39daf0791d147f039 Date: Sat Dec 6 17:16:22 2025 +0900 Step 1: Setup Python 3.13 Virtual Environment and Analyze Dependencies Build status: Success 16
  14. 自動で実施されたこと ・(幸か不幸か)ライブラリの使い方に破壊的な変更がなかったせいで、  内部処理についての改修は発生しなかった   ⇒ 気を利かせてコード品質向上 をやってくれた。 1. 型ヒント追加 - `from

    __future__ import annotations` など 2. 例外処理の改善 - bare except → 特定の例外 3. 依存関係の互換性確認と更新 - Python 3.13対応の最新バージョンに自動更新 19