View a markdown version of this page

努力实现持续现代化 - AWS 转换

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

努力实现持续现代化

来源管理

使用atx ct source命令连接存储库。支持的提供商: GitHub、 GitLab、Bitbucket、本地。

GitHub 组织

令牌:具有repo范围的个人访问令牌(经典)。 Read-only 用于分析,完整存储库用于补救。

atx ct source add --name name --provider github --org org --token pat

GitLab 群组和用户

令牌:具有api范围的个人访问令牌。

atx ct source add --name name --provider gitlab --org group-or-user --token pat # Self-hosted: atx ct source add --name name --provider gitlab --org group-or-user --token pat --url https://gitlab.example.com

Bitbucket 工作空间和项目

Bitbucket Cloud — 范围:read:repository:bitbucketwrite:repository:bitbucketread:pullrequest:bitbucketwrite:pullrequest:bitbucket。还需要--email--username.

atx ct source add --name name --provider bitbucket --org workspace --token api-token --email email --username username

Bitbucket 数据中心:

atx ct source add --name name --provider bitbucket --org project-key --token http-access-token --url https://bitbucket.example.com

本地存储库

atx ct source add --name name --provider local --path parent-directory
重要

--path必须指向包含 git repos 作为子目录的父目录,而不是指向单个存储库。

管理来源

atx ct source list atx ct source remove --name name

存储库发现和管理

atx ct discovery scan --source name atx ct discovery status --source name atx ct discovery scan --source name --path new-directory

发现后:

atx ct repository list atx ct repository list --source name atx ct repository list --labels "team:frontend,priority:high" atx ct repository update --source name --repo "source::repo" --labels "team:frontend,priority:high" atx ct repository update --source name --labels "migration:wave-1"

跑步分析

--type标志指定要运行的分析类型:

  • rapid-techdebt-analysis— 依赖关系过时,容易获胜。

  • tech-debt-comprehensive— 更深入的 AI-powered 分析,涵盖依赖关系、安全性、模式、性能、可维护性、架构、代码质量和基础架构调查结果。

  • security— 安全漏洞和暴露。

  • agentic-readiness— 您的存储库为 AI 代理(框架、API、文档)做好准备。

  • modernization-readiness— 基础架构、应用程序、数据、安全和运营方面的现代化机会。

atx ct analysis run --type type --source name [--repo source::repo] [--wait] atx ct analysis get --id id --json atx ct analysis list --json atx ct analysis list --status pending|running|complete|cancelled|failed --json atx ct analysis list --type type --json atx ct analysis cancel --id id atx ct analysis delete --id id [--cascade-findings]

自定义分析

atx ct analysis run --type custom --transformation-name name --source source --repo source::repo --wait

带有-g标志的配置:键值、JSON 或文件路径。

列出 TD:atx custom def list

管理调查发现

atx ct findings list --json atx ct findings list --repo source::repo --source name --severity high|medium|low --type analysis-type --status open|dismissed|obsolete --analysis-id id --fix-transform transform-name --json

查找状态

  • open— 活跃

  • dismissed— 手动解雇(需要理由)

  • obsolete— System-set 当重新分析不再产生结果时

atx ct findings update --id id --status dismissed --reason "reason" atx ct findings update --id id --status open atx ct findings batch-update --ids id1,id2 --status dismissed --reason "reason" atx ct findings get --id id atx ct findings delete --id id

寻找过时之处

Re-analysis 将已解决的发现标记为过时。无法重新打开。保留以供审计。

创建补救措施

三种模式:基于发现、TD 覆盖、直接 TD。

atx ct remediation create --ids id1,id2 --name "name" atx ct remediation create --ids id1,id2 --transformation-name TD atx ct remediation create --transformation-name TD --repo source::repo

按提供商划分的输出: GitHub PR、 GitLab MR、Bitbucket PR、本地分支机构。

注意

令牌必须具有写入权限才能 PR/MR 创建。

使用--local标志进行本地执行。

atx ct remediation create --transformation-name TD --repo source::repo -g "additionalPlanContext=Upgrade to Node.js 22" atx ct remediation list atx ct remediation status --id id atx ct remediation retry --id id atx ct remediation cancel --id id atx ct remediation delete --id id

远程执行

默认情况下,分析和修复在本地计算机上运行。对于更大的投资组合,您可以将工作转移到远程基础架构。您可以在无需预置的 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 --type type --mode aws-managed --sources name [--repos repo1,repo2] [--region region] # Poll the submission (there is no remote status command in this mode) atx ct analysis get --id id --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 --vpc vpc-id --json # Create a new VPC with private subnets, a NAT gateway, and a security group atx ct remote network create --cidr 10.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 --vpc vpc-id --subnets subnet-a,subnet-b atx ct remote provision --mode ec2 --vpc vpc-id --subnets subnet-a,subnet-b --execute --ack # Deploy a Batch stack atx ct remote provision --mode batch --vpc vpc-id --subnets subnet-a,subnet-b --securityGroup sg-id --execute --ack # Update an existing stack to the latest template, or tear it down atx ct remote update --mode ec2|batch --execute --ack atx ct remote teardown --mode ec2|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 --vpc vpc-id --subnets subnet-a,subnet-b --securityGroup sg-id --image-uri account-id.dkr.ecr.region.amazonaws.com/repo:tag --execute --ack # EC2: provision with a custom image atx ct remote provision --mode ec2 --vpc vpc-id --subnets subnet-a,subnet-b --image-uri account-id.dkr.ecr.region.amazonaws.com/repo:tag --execute --ack

存储源凭证

远程容器使用存储在 AWS 密钥管理器中的令牌克隆您的仓库。在运行远程分析或修复之前,为每个 SCM 来源注册一个令牌:

atx ct remote credentials --source name --token token atx ct remote credentials --source name --remove

远程运行

远程分析为每个存储库运行一个容器;远程修复为每个发现运行一个容器。使用--sources--repos、和--labels控制扇出和/ --stack-name 或选择--tags要使用的预置堆栈。

# Run analysis across a source on Batch atx ct remote analysis --type type --mode batch --sources name [--repos repo1,repo2] [--labels "team:frontend"] # Run remediation for specific findings on EC2 atx ct remote remediation --mode ec2 --ids id1,id2 atx ct remote remediation --mode ec2 --sources name --min-severity high

监控和管理运行

# Check whether infrastructure is deployed atx ct remote detect --mode ec2|batch # Track a submission (Batch by batch ID, EC2 by group ID) atx ct remote status --batch batch-id --stack-name name atx ct remote status --group ec2-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 --type type --mode batch --sources name --resume-incomplete --batch-name batch-id # Cancel a running submission atx ct remote cancel --mode batch --batch batch-id --stack-name name atx ct remote cancel --mode ec2 --group ec2-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值接受dailyweekly:DAY(例如,weekly:MONDAY),或monthly:N其中 N 1 到 28 之间的某一天。 AWS Transform-managed 基础设施计划以 UTC 运行。

# AWS Transform-managed schedule (no infrastructure; requires an execution role) atx ct schedule create --name name --mode aws-managed --execution-role role-arn --recurrence daily --type type --sources name [--repos repo1,repo2] # Customer-managed schedule (EventBridge Scheduler dispatching to your EC2 or Batch stack) atx ct schedule create --name name --mode ec2|batch --recurrence weekly:MONDAY --type type --sources name [--repos repo1,repo2] # Manage schedules of either type by their schedule ID (from schedule list) atx ct schedule list atx ct schedule get schedule-id atx ct schedule disable schedule-id atx ct schedule enable schedule-id atx ct schedule delete schedule-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 --name name --provider github --org org --token pat --tags team=platform,env=prod atx ct analysis run --type type --source name --tags team=platform atx ct remediation create --ids id1,id2 --tags team=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 应用程序,请完成以下步骤。

  1. 使用 AWS IAM 身份中心证书打开https://aws.amazon.com/transform/并登录。

  2. 如果未出现持续现代化改造,请改用 IAM 证书登录:

    1. 在 AWS 管理控制台中,打开 “ AWS 转换”,然后选择 “设置”

    2. 开启使用 IAM 证书进行访问 AWS 转换

    3. 复制 Web 应用程序 URL(使用 IAM)并将其粘贴到打开控制台的同一个浏览器窗口中。

  3. 打开左侧导航菜单并选择 “持续现代化”

基础设施模式

创建分析时,请选择以下基础架构模式之一:

  • AWS 管理 — 在由 T AWS ransform 管理的基础架构上运行。您无需预置任何基础设施。

  • 客户所有 — 自行在已部署的堆栈上运行 AWS 账户。当您需要控制计算、网络或安全配置时,请使用此模式。

注意

要运行安全分析,请使用客户拥有的基础架构。安全分析在您账户中部署的安全客户端上运行。

要使用客户拥有的基础架构,请打开 设置” 选项卡。使用 AWS CloudFormation 快速创建链接按顺序部署以下堆栈:

  1. AtxDispatcherStack— 消息调度器(始终是必需的)。

  2. 计算堆栈 —AtxInfrastructureStack(AWS 批处理)或atx-runner(亚马逊 EC2)。

  3. atx-scheduler— 需要定期进行定期分析。

  4. AtxSecurityAgentStack-<region>— 仅在安全分析时需要。

有关 CLI-based 配置和网络配置,请参阅远程执行

入门工作流

  1. 连接源 -打开源代码选项卡并添加来自GitHubGitLab、或的存储库Bitbucket。

  2. 运行或计划分析 -打开分析选项卡,选择存储库,选择分析类型,选择基础架构模式,然后选择运行。要按循环节奏(每天、每周或每月)运行,请改为选择 “计划”。

  3. 查看调查结果 -打开 调查结果” 选项卡,按严重程度查看结果。

  4. 创建补救措施 -选择调查结果并选择创建补救措施

  5. 查看拉取请求 — 打开 “修复” 选项卡以查看每个存储库生成的 PR 链接。

直接通过 Web 应用程序与 T AWS ransform 聊天,询问有关您的分析、发现或补救措施的问题。