本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
努力实现持续现代化
来源管理
使用atx ct source命令连接存储库。支持的提供商: GitHub、 GitLab、Bitbucket、本地。
GitHub 组织
令牌:具有repo范围的个人访问令牌(经典)。 Read-only 用于分析,完整存储库用于补救。
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 repos 作为子目录的父目录,而不是指向单个存储库。
管理来源
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-powered 分析,涵盖依赖关系、安全性、模式、性能、可维护性、架构、代码质量和基础架构调查结果。security— 安全漏洞和暴露。agentic-readiness— 您的存储库为 AI 代理(框架、API、文档)做好准备。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 或文件路径。
列出 TD: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— System-set 当重新分析不再产生结果时
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
寻找过时之处
Re-analysis 将已解决的发现标记为过时。无法重新打开。保留以供审计。
创建补救措施
三种模式:基于发现、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、本地分支机构。
注意
令牌必须具有写入权限才能 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 Transform-managed 基础设施上运行(仅限分析),也可以在您的 Amazon EC2 永久实例或 AWS 批处理(Fargate)任务中预置和管理的基础设施上运行。 AWS 账户这些atx ct remote命令配置、运行、监控和拆除客户管理的基础架构。无论执行发生在何处,您都可以在自己的资源中创建所有资源, AWS 账户 并且源代码仍在您的控制之下。
注意
配置、更新和拆除基础设施会创建和修改 AWS CloudFormation
堆栈和 IAM 角色,并且需要管理员权限。传递--ack即可确认这一点,然后跳过交互式提示。在已配置的基础架构上运行分析和修复使用最低权限执行器策略——有关所涉及的托管策略,请参阅标记和访问控制和中的计算选项。操作方法 AWS 改造持续现代化工作
继续运行 AWS Transform-managed 基础架构(未配置)
要在不进行任何配置的情况下远程运行分析,请使用--mode aws-managed。提交给T AWS ransform,负责对 AWS Transform-managed 基础设施进行分析。无需预置堆栈,无需配置网络,也没有证书可以存储在 S AWS ecrets 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--tags、--existing-instance、和--batch-name选项不适用。一次提交最多可覆盖 100 个存储库。要涵盖更大的范围,请将它们分成多个提交--repos。与 Amazon EC2 和批量运行不同,您可以使用atx ct analysis get而不是来监控进度atx ct remote status。
Networking
远程计算必须在私有子网中运行。在配置之前发现现有网络或创建新的 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 或批处理堆栈。省略--execute预览模板或变更集;添加--execute即可应用。
配置将为您选择的模式创建计算堆栈以及调度器堆栈:
Batch — AWS 批处理任务队列和计算环境、包含持续现代化容器镜像的任务定义、用于执行任务的 IAM 角色以及用于提交任务的 Lambda 函数。批处理需要安全组。
亚马逊 EC2 — 具有 IAM 实例配置文件和安全组的永久亚马逊 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
容器映像
当您运行远程分析和修复时,它们会在容器映像内执行。默认情况下,当您预置远程环境时,它使用公共的 T AWS ransform 镜像public.ecr.aws/d9h8z6l7/aws-transform:latest。批量将其设置为作业定义图像。亚马逊 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 密钥管理器中的令牌克隆您的仓库。在运行远程分析或修复之前,为每个 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 Transform-managed(
--mode aws-managed) — 启动 AWS Transform-managed 基础架构分析的服务器端时间表。没有亚马逊 EventBridge 的时间表,也没有什么可预置的。它需要一个执行角色 (--execution-role),T AWS ransform 在每次运行时都要扮演这个角色(参见的执行角色 AWS Transform-managed 时间表)。Customer-managed(
--mode ec2|batch) — 您的账户中的 Amazon EventBridge 调度器计划会将每次运行调度到您首先预置的永久性 Amazon EC2 实例或 AWS 批处理堆栈中(请参阅)。远程执行
该--recurrence值接受daily,weekly:(例如,DAYweekly:MONDAY),或monthly:其中 NN 1 到 28 之间的某一天。 AWS Transform-managed 基础设施计划以 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 Transform-managed 时间表
使用创建的计划--mode aws-managed需要一个 --execution-role ARN,T AWS ransform 每次运行计划时都会采用该ARN。按如下方式配置角色:
创建时间表的身份必须具有执行角色的
iam:PassRole权限。该角色的信任策略必须允许
transform-custom.amazonaws.com服务主体承担该角色。该角色至少必须AWSTransformCustomFullAccess附加 AWS 托管策略,
secretsmanager:GetSecretValue并在atx/*前缀下加上对密钥的secretsmanager:DescribeSecret权限,以便计划运行可以检索源克隆证书。
以下内联策略向 AWS Secrets Manager 授予计划运行检索源克隆凭据所需的访问权限。将其与AWSTransformCustomFullAccess托管策略一起附加到执行角色,用运行时间表的 AWS 区域和账户替换region和。account-id
{ "Version": "2012-10-17", "Statement": [ { "Sid": "AtxSourceCredentials", "Effect": "Allow", "Action": [ "secretsmanager:GetSecretValue", "secretsmanager:DescribeSecret" ], "Resource": "arn:aws:secretsmanager:region:account-id:secret:atx/*" } ] }
标记和访问控制
您可以使用该选项将标签(以逗号分隔的key=value对)应用于来源、分析和补救措施。--tags远程基础架构、存储的凭证和网络资源也支持标签。使用标签,您可以组织资源。与 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 应用程序
使用 T AWS ransform Web 应用程序创建和运行分析、审查调查结果、创建补救措施以及跟踪代码源中生成的拉取请求。
在使用 Web 应用程序之前,您的组织必须启用您的用户身份才能访问 T AWS ransform。有关设置 AWS 转换的更多信息,请参阅设置 AWS 转换。
登录
要访问 AWS 转换 Web 应用程序,请完成以下步骤。
使用 AWS IAM 身份中心证书打开
https://aws.amazon.com/transform/并登录。如果未出现持续现代化改造,请改用 IAM 证书登录:
在 AWS 管理控制台中,打开 “ AWS 转换”,然后选择 “设置” 。
开启使用 IAM 证书进行访问 AWS 转换。
复制 Web 应用程序 URL(使用 IAM)并将其粘贴到打开控制台的同一个浏览器窗口中。
打开左侧导航菜单并选择 “持续现代化” 。
基础设施模式
创建分析时,请选择以下基础架构模式之一:
AWS 管理 — 在由 T AWS ransform 管理的基础架构上运行。您无需预置任何基础设施。
客户所有 — 自行在已部署的堆栈上运行 AWS 账户。当您需要控制计算、网络或安全配置时,请使用此模式。
注意
要运行安全分析,请使用客户拥有的基础架构。安全分析在您账户中部署的安全客户端上运行。
要使用客户拥有的基础架构,请打开 “设置” 选项卡。使用 AWS CloudFormation 快速创建链接按顺序部署以下堆栈:
AtxDispatcherStack— 消息调度器(始终是必需的)。计算堆栈 —
AtxInfrastructureStack(AWS 批处理)或atx-runner(亚马逊 EC2)。atx-scheduler— 需要定期进行定期分析。AtxSecurityAgentStack-<region>— 仅在安全分析时需要。
有关 CLI-based 配置和网络配置,请参阅远程执行。
入门工作流
连接源 -打开源代码选项卡并添加来自GitHubGitLab、或的存储库Bitbucket。
运行或计划分析 -打开分析选项卡,选择存储库,选择分析类型,选择基础架构模式,然后选择运行。要按循环节奏(每天、每周或每月)运行,请改为选择 “计划”。
查看调查结果 -打开 “调查结果” 选项卡,按严重程度查看结果。
创建补救措施 -选择调查结果并选择创建补救措施。
查看拉取请求 — 打开 “修复” 选项卡以查看每个存储库生成的 PR 链接。
直接通过 Web 应用程序与 T AWS ransform 聊天,询问有关您的分析、发现或补救措施的问题。