本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
使用持續現代化
來源管理
使用 atx ct source 命令來連接儲存庫。支援的提供者:GitHub、GitLab、Bitbucket、local。
GitHub 組織
權杖:具有repo範圍的個人存取權杖 (傳統)。用於分析的唯讀、用於修復的完整儲存庫。
atx ct source add --namename--provider github --orgorg--tokenpat
GitLab 群組和使用者
權杖:具有api範圍的個人存取權杖。
atx ct source add --namename--provider gitlab --orggroup-or-user--tokenpat# Self-hosted: atx ct source add --namename--provider gitlab --orggroup-or-user--tokenpat--url https://gitlab.example.com
Bitbucket 工作空間和專案
Bitbucket Cloud — 範圍:read:repository:bitbucket、write:repository:bitbucket、read:pullrequest:bitbucket、write:pullrequest:bitbucket。也需要 --email和 --username。
atx ct source add --namename--provider bitbucket --orgworkspace--tokenapi-token--emailusername
Bitbucket 資料中心:
atx ct source add --namename--provider bitbucket --orgproject-key--tokenhttp-access-token--url https://bitbucket.example.com
本機儲存庫
atx ct source add --namename--provider local --pathparent-directory
重要
--path 必須指向包含 git 儲存庫的父目錄作為子目錄,而不是單一儲存庫。
管理來源
atx ct source list atx ct source remove --namename
儲存庫探索和管理
atx ct discovery scan --sourcenameatx ct discovery status --sourcenameatx ct discovery scan --sourcename--pathnew-directory
探索後:
atx ct repository list atx ct repository list --sourcenameatx ct repository list --labels "team:frontend,priority:high" atx ct repository update --sourcename--repo "source::repo" --labels "team:frontend,priority:high" atx ct repository update --sourcename--labels "migration:wave-1"
執行分析
--type 旗標指定要執行的分析類型:
rapid-techdebt-analysis– 過時的相依性和輕鬆獲勝。tech-debt-comprehensive– 更深入的 AI 驅動分析,涵蓋相依性、安全性、模式、效能、可維護性、架構、程式碼品質和基礎設施問題清單。security– 安全漏洞和暴露。agentic-readiness– AI 代理器儲存庫的準備程度 (架構、APIs、文件)。modernization-readiness– 跨基礎設施、應用程式、資料、安全性和操作維度的現代化機會。
atx ct analysis run --typetype--sourcename[--reposource::repo] [--wait] atx ct analysis get --idid--json atx ct analysis list --json atx ct analysis list --statuspending|running|complete|cancelled|failed--json atx ct analysis list --typetype--json atx ct analysis cancel --ididatx ct analysis delete --idid[--cascade-findings]
自訂分析
atx ct analysis run --type custom --transformation-namename--sourcesource--reposource::repo--wait
具有-g旗標的組態:鍵值、JSON 或檔案路徑。
列出 TDs: atx custom def list
管理調查結果
atx ct findings list --json atx ct findings list --reposource::repo--sourcename--severityhigh|medium|low--typeanalysis-type--statusopen|dismissed|obsolete--analysis-idid--fix-transformtransform-name--json
尋找狀態
open— 作用中dismissed— 手動關閉 (需要原因)obsolete— 重新分析不再產生問題清單時的系統集
atx ct findings update --idid--status dismissed --reason "reason" atx ct findings update --idid--status open atx ct findings batch-update --idsid1,id2--status dismissed --reason "reason" atx ct findings get --ididatx ct findings delete --idid
尋找過時
重新分析會將已解決的問題清單標記為過時。無法重新開啟。保留以供稽核。
建立修復
三種模式:以調查結果為基礎、TD 覆寫、直接 TD。
atx ct remediation create --idsid1,id2--name "name" atx ct remediation create --idsid1,id2--transformation-nameTDatx ct remediation create --transformation-nameTD--reposource::repo
提供者輸出:GitHub PR、GitLab MR、Bitbucket PR、Local 分支。
注意
權杖必須具有寫入存取權才能建立 PR/MR。
具有 --local 旗標的本機執行。
atx ct remediation create --transformation-nameTD--reposource::repo-g "additionalPlanContext=Upgrade to Node.js 22" atx ct remediation list atx ct remediation status --ididatx ct remediation retry --ididatx ct remediation cancel --ididatx ct remediation delete --idid
遠端執行
根據預設,分析和修復會在您的本機電腦上執行。對於較大的產品組合,您可以將工作卸載至遠端基礎設施。您可以在 AWS 轉換受管基礎設施上執行,無需佈建 (僅限分析),或是在您在 中佈建和管理的基礎設施上執行 AWS 帳戶,即持久性 Amazon EC2 執行個體或 AWS Batch (Fargate) 任務。atx ct remote 命令佈建、執行、監控和銷毀客戶受管基礎設施。無論執行在何處發生,您都會在 中建立所有資源, AWS 帳戶 而您的原始程式碼仍由您控制。
注意
佈建、更新和銷毀基礎設施會建立和修改 AWS CloudFormation 堆疊和 IAM 角色,且需要管理員許可。傳遞 --ack 以確認這一點,並略過互動式提示。在已佈建的基礎設施上執行分析和修復會使用最低權限的執行器政策 — 請參閱 中的 標記和存取控制 中涉及AWS 轉型持續現代化的運作方式的受管政策的運算選項。
在 AWS 轉換受管基礎設施上執行 (無佈建)
若要在遠端執行分析而不佈建任何內容,請使用 --mode aws-managed。提交會前往 AWS Transform,在 AWS Transform 受管基礎設施上執行分析。無需佈建堆疊、無需設定聯網,也無需在 AWS Secrets Manager 中存放登入資料。提交是執行。選擇工作負載使用 在 中執行 AWS 的區域--region。
# Run an analysis on AWS Transform-managed infrastructure atx ct remote analysis --typetype--mode aws-managed --sourcesname[--reposrepo1,repo2] [--regionregion] # Poll the submission (there is no remote status command in this mode) atx ct analysis get --idid--json
此模式只會執行分析。它不支援修復、custom分析類型或本機來源。由於沒有堆疊,因此 --stack-name、--existing-instance、 --tags和 --batch-name選項不適用。單一提交最多涵蓋 100 個儲存庫。若要涵蓋更大的範圍,請使用 將其分割為多個提交--repos。與 Amazon EC2 和 Batch 執行不同,您可以使用 atx ct analysis get而不是 來監控進度atx ct remote status。
聯網
遠端運算必須在私有子網路中執行。在佈建之前,探索現有的聯網或建立新的 VPC:
# List VPCs, private subnets, and security groups in the current account and Region atx ct remote network discover atx ct remote network discover --vpcvpc-id--json # Create a new VPC with private subnets, a NAT gateway, and a security group atx ct remote network create --cidr10.1.0.0/16--ack
佈建基礎設施
部署 Amazon EC2 或 Batch 堆疊。省略 --execute以預覽範本或變更集;新增 --execute以套用。
佈建會建立所選模式的運算堆疊,以及排程器堆疊:
批次: AWS 批次任務佇列和運算環境、具有持續現代化容器映像的任務定義、任務執行的 IAM 角色,以及任務提交的 Lambda 函數。批次需要安全群組。
Amazon EC2 — 具有 IAM 執行個體描述檔和安全群組的持久性 Amazon EC2 執行個體。如果您省略
--securityGroup,堆疊會建立沒有傳入規則的安全群組;存取是透過 SSM。排程器 — 經常性分析使用的
atx-scheduler堆疊 (Amazon EventBridge 排程器排程群組和調用角色)。傳遞--skip-scheduler以選擇退出。
# Preview, then deploy an EC2 stack atx ct remote provision --mode ec2 --vpcvpc-id--subnetssubnet-a,subnet-batx ct remote provision --mode ec2 --vpcvpc-id--subnetssubnet-a,subnet-b--execute --ack # Deploy a Batch stack atx ct remote provision --mode batch --vpcvpc-id--subnetssubnet-a,subnet-b--securityGroupsg-id--execute --ack # Update an existing stack to the latest template, or tear it down atx ct remote update --modeec2|batch--execute --ack atx ct remote teardown --modeec2|batch--execute --ack
容器映像
當您執行遠端分析和修復時,它們會在容器映像中執行。根據預設,當您佈建遠端環境時,它會使用公有 AWS 轉換映像 public.ecr.aws/d9h8z6l7/aws-transform:latest。Batch 將其設定為任務定義映像。Amazon EC2 使用它做為執行器映像。
若要執行不同的映像,例如,綁定其他語言或工具的私有 Amazon ECR 映像,請在佈建--image-uri時通過:
# Batch: provision with a custom image atx ct remote provision --mode batch --vpcvpc-id--subnetssubnet-a,subnet-b--securityGroupsg-id--image-uriaccount-id.dkr.ecr.region.amazonaws.com/repo:tag--execute --ack # EC2: provision with a custom image atx ct remote provision --mode ec2 --vpcvpc-id--subnetssubnet-a,subnet-b--image-uriaccount-id.dkr.ecr.region.amazonaws.com/repo:tag--execute --ack
儲存來源登入資料
遠端容器會使用存放在 AWS Secrets Manager 中的字符複製您的儲存庫。在執行遠端分析或修復之前,為每個 SCM 來源註冊權杖:
atx ct remote credentials --sourcename--tokentokenatx ct remote credentials --sourcename--remove
遠端執行
遠端分析會為每個儲存庫執行一個容器;遠端修復會為每個調查結果執行一個容器。使用 --sources、 --repos和 --labels來控制廣發功能,以及 --stack-name或 --tags 來選取要使用的佈建堆疊。
# Run analysis across a source on Batch atx ct remote analysis --typetype--mode batch --sourcesname[--reposrepo1,repo2] [--labels "team:frontend"] # Run remediation for specific findings on EC2 atx ct remote remediation --mode ec2 --idsid1,id2atx ct remote remediation --mode ec2 --sourcesname--min-severity high
監控和管理執行
# Check whether infrastructure is deployed atx ct remote detect --modeec2|batch# Track a submission (Batch by batch ID, EC2 by group ID) atx ct remote status --batchbatch-id--stack-namenameatx ct remote status --groupec2-group-id--wait # Resume a partially-failed Batch run (re-submits only incomplete repos). # On resume, --batch-name takes the existing batch ID reported by "remote status --batch". atx ct remote analysis --typetype--mode batch --sourcesname--resume-incomplete --batch-namebatch-id# Cancel a running submission atx ct remote cancel --mode batch --batchbatch-id--stack-namenameatx ct remote cancel --mode ec2 --groupec2-group-id
排程週期性分析
使用 atx ct schedule以定期自動執行分析。您可以排程分析,但無法修復。任務選項鏡射 atx ct remote analysis。排程會以兩種方式之一從遠端執行:
AWS 轉換受管 (
--mode aws-managed) - 在 AWS 轉換受管基礎設施上觸發分析的伺服器端排程。沒有 Amazon EventBridge 排程,也不需要佈建。它需要 AWS Transform 在每次執行時擔任的執行角色 (--execution-role) (請參閱 AWS 轉換受管排程的執行角色)。客戶受管 (
--mode ec2|batch) — 帳戶中的 Amazon EventBridge 排程器排程會將每個執行分派至您首先佈建的持久性 Amazon EC2 執行個體或 AWS 批次堆疊 (請參閱 遠端執行)。
此--recurrence值接受 daily、 weekly:(例如 DAYweekly:MONDAY) 或 ,monthly:其中 NN 是從 1 到 28 的一天。 AWS 轉換受管基礎設施在 UTC 中執行的排程。
# AWS Transform-managed schedule (no infrastructure; requires an execution role) atx ct schedule create --namename--mode aws-managed --execution-rolerole-arn--recurrencedaily--typetype--sourcesname[--reposrepo1,repo2] # Customer-managed schedule (EventBridge Scheduler dispatching to your EC2 or Batch stack) atx ct schedule create --namename--modeec2|batch--recurrenceweekly:MONDAY--typetype--sourcesname[--reposrepo1,repo2] # Manage schedules of either type by their schedule ID (from schedule list) atx ct schedule list atx ct schedule getschedule-idatx ct schedule disableschedule-idatx ct schedule enableschedule-idatx ct schedule deleteschedule-id
若要檢視排程已執行的分析,請使用 atx ct analysis list --schedule-id ,這會先傳回排程的觸發執行。schedule-id
若要移除客戶受管排程所使用的排程器角色和排程群組,請執行 atx ct schedule teardown --execute。
AWS 轉換受管排程的執行角色
使用 建立的排程--mode aws-managed需要 AWS 轉換在每次執行排程時擔任的 --execution-role ARN。設定角色,如下所示:
建立排程的身分必須具有執行角色的
iam:PassRole許可。角色的信任政策必須允許
transform-custom.amazonaws.com服務主體擔任該角色。角色至少必須AWSTransformCustomFullAccess連接 AWS 受管政策,加上 字
atx/*首下秘密的secretsmanager:GetSecretValue和secretsmanager:DescribeSecret許可,以便排程的執行可以擷取來源複製登入資料。
下列內嵌政策會授予已排程執行需要擷取來源複製憑證的 AWS Secrets Manager 存取權。將它與AWSTransformCustomFullAccess受管政策一起連接至執行角色,將區域和帳戶 ID 取代為執行排程 AWS 的區域和帳戶。
{ "Version": "2012-10-17", "Statement": [ { "Sid": "AtxSourceCredentials", "Effect": "Allow", "Action": [ "secretsmanager:GetSecretValue", "secretsmanager:DescribeSecret" ], "Resource": "arn:aws:secretsmanager:region:account-id:secret:atx/*" } ] }
標記和存取控制
您可以使用 --tags選項將標籤 (逗號分隔key=value組) 套用至來源、分析和修復。遠端基礎設施、儲存的登入資料和聯網資源也支援標籤。透過標籤,您可以組織資源。結合 IAM 標籤條件,標籤會實作屬性型存取控制 (ABAC),讓團隊只能存取帶有標籤的資源。
atx ct source add --namename--provider github --orgorg--tokenpat--tagsteam=platform,env=prodatx ct analysis run --typetype--sourcename--tagsteam=platformatx ct remediation create --idsid1,id2--tagsteam=platform
根據預設,資源會以您在 中定義的標籤進行標記~/.aws/atx/settings.json。新增您要套用至 下每個資源的標籤applyTags,它們會成為您的預設標籤。
{ "applyTags": [ { "team": "alpha" } ] }
注意
傳遞給 的標籤--tags會合併到任何設定的預設標籤上,並在這兩個位置為任何金鑰集--tags獲勝。
AWS 轉換 Web 應用程式
使用 AWS Transform Web 應用程式來建立和執行分析、檢閱問題清單、建立修復,以及追蹤整個程式碼來源產生的提取請求。
在使用 Web 應用程式之前,您的組織必須啟用您的使用者身分才能存取 AWS Transform。如需設定 AWS 轉換的詳細資訊,請參閱設定 AWS 轉換。
登入
若要存取 AWS Transform Web 應用程式,請完成下列步驟。
使用 AWS IAM Identity Center 登入資料開啟
https://aws.amazon.com/transform/並登入。如果持續現代化未出現,請改用 IAM 登入資料登入:
在 AWS 管理主控台中,開啟 AWS 轉換,然後選擇設定。
使用 IAM 登入資料開啟存取 AWS 轉換。
複製 Web 應用程式 URL (使用 IAM),並將其貼到開啟主控台的相同瀏覽器視窗。
開啟左側導覽選單,然後選擇持續現代化。
基礎設施模式
當您建立分析時,請選擇下列其中一個基礎設施模式:
AWS 受管 – 在由 AWS Transform 管理的基礎設施上執行。您不需要佈建任何基礎設施。
客戶擁有 – 在您自己的 中部署的堆疊上執行 AWS 帳戶。當您需要控制運算、聯網或安全組態時,請使用此模式。
注意
若要執行安全分析,請使用客戶擁有的基礎設施。安全分析會在您帳戶中部署的 Security Agent 上執行。
若要使用客戶擁有的基礎設施,請開啟設定索引標籤。使用 AWS CloudFormation 快速建立連結來依序部署下列堆疊:
AtxDispatcherStack– 訊息發送器 (一律為必要)。運算堆疊 –
AtxInfrastructureStack(AWS 批次) 或atx-runner(Amazon EC2)。atx-scheduler– 週期性排程分析的必要項目。AtxSecurityAgentStack-<region>– 僅適用於安全性分析。
如需 CLI 型佈建和聯網組態,請參閱 遠端執行。
開始使用工作流程
連接來源 – 開啟來源索引標籤,並從 GitHub、 GitLab或 新增儲存庫Bitbucket。
執行或排程分析 – 開啟分析索引標籤、選取儲存庫、選擇分析類型、選取基礎設施模式,然後選擇執行。若要定期執行 (每日、每週或每月),請改為選擇排程。
檢閱問題清單 – 開啟問題清單索引標籤,依嚴重性檢視結果。
建立修補:選取問題清單,然後選擇建立修補。
檢閱提取請求 – 開啟修復索引標籤,以檢視每個儲存庫產生的 PR 連結。
直接從 Web 應用程式與 AWS Transform 聊天,詢問有關分析、問題清單或修復的問題。