

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

# 使用实现 CardDemo 大型机应用程序的现代化 AWS Transform
<a name="modernize-carddemo-mainframe-app"></a>

*Santosh Kumar Singh 和 Cheryl du Preez，Amazon Web Services*

## Summary
<a name="modernize-carddemo-mainframe-app-summary"></a>

[AWS Transform](https://docs.aws.amazon.com/transform/latest/userguide/what-is-service.html) 旨在加速大型机应用程序现代化。它借助生成式人工智能简化大型机现代化流程，可以自动执行复杂的任务，例如：遗留代码分析、大型机文档、业务规则提取、将单体应用程序分解到业务领域、代码重构。因为自动执行复杂的任务（例如应用程序分析和迁移顺序规划），现代化项目得以加快推进。在分解单体应用程序时，可以 AWS Transform 智能地排列大型机应用程序转换的顺序，这可以帮助您并行转换业务功能。 AWS Transform 可以加快决策制定，提高运营灵活性和迁移效率。

此模式提供了 step-by-step一些说明，可帮助您使用 AWS Transform 来测试大型机现代化功能 [CardDemo](https://github.com/aws-samples/aws-mainframe-modernization-carddemo)，这是开源大型机应用程序的示例。

## 先决条件和限制
<a name="modernize-carddemo-mainframe-app-prereqs"></a>

**先决条件**
+ 活跃的 AWS 账户
+ [已启用](https://docs.aws.amazon.com/singlesignon/latest/userguide/enable-identity-center.html)AWS IAM Identity Center
+ 允许管理员启用的@@ [权限](https://docs.aws.amazon.com/transform/latest/userguide/security_iam_id-based-policy-examples.html#id-based-policy-examples-admin-enable-transform) AWS Transform
+ 允许管理员接受 Web 应用程序的亚马逊简单存储服务 (Amazon S3) Semple Service 连接请求的@@ [AWS Transform 权限](https://docs.aws.amazon.com/transform/latest/userguide/security_iam_id-based-policy-examples.html#id-based-policy-examples-admin-connector)

**限制**
+ AWS Transform 仅在某些版本中可用 AWS 区域。有关支持区域的完整列表，请参阅 [AWS Transform支持的区域](https://docs.aws.amazon.com/transform/latest/userguide/regions.html)。
+ AWS Transform 支持代码分析、文档生成、业务规则提取、分解以及从面向业务的通用语言 (COBOL) 重构到 Java。有关更多信息，请参阅[功能和主要特性](https://docs.aws.amazon.com/transform/latest/userguide/transform-app-mainframe.html#transform-app-mainframe-features)以及[支持的大型机应用程序转换文件类型](https://docs.aws.amazon.com/transform/latest/userguide/transform-app-mainframe.html#transform-app-mainframe-supported-files)。
+  AWS Transform对大型机转换功能设有服务配额。有关更多信息，请参阅 [AWS Transform配额](https://docs.aws.amazon.com/transform/latest/userguide/transform-limits.html)。
+ 要在共享工作区上进行协作，所有用户都必须是与您 AWS IAM Identity Center 的 AWS Transform Web 应用程序实例关联的相同实例的注册用户。
+ Amazon S3 存储桶和 AWS Transform 必须位于相同的 AWS 账户 区域中。

## 架构
<a name="modernize-carddemo-mainframe-app-architecture"></a>

下图显示了此模式的构建架构。

![\[AWS Transform 可助力存储在 Amazon S3 存储桶中的大型机应用程序实现现代化。\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/images/pattern-img/0e539474-b733-452d-b0fb-6b3f4cbd5075/images/75be6d78-5b43-448c-ad07-bf74b9ae14ad.png)


下图显示了如下工作流：

1. AWS Transform 使用连接器访问存储在 Amazon S3 存储桶中的 CardDemo 大型机应用程序。

1. AWS Transform AWS IAM Identity Center 用于管理用户访问和身份验证。此系统实施了多层安全控制措施，涵盖身份验证、授权、加密及访问管理，以在处理过程中保护代码和构件的安全。用户通过聊天界面与 AWS Transform 代理互动。您可以用英语向人工智能代理发出有关特定任务的指令。有关更多信息，请参阅 AWS Transform 文档[中的人为循环 (HITL)](https://docs.aws.amazon.com/transform/latest/userguide/transform-app-mainframe.html#transform-app-mainframe-hitl)。

1. 人工智能代理解释用户的指令，创建作业计划，将作业划分为多个可执行的任务，然后自动采取相应行动。用户可以查看和批准转换。转换任务包括如下事项：
   + **代码分析** — AWS Transform 分析每个文件中的代码，了解文件名、文件类型、代码行及其路径等详细信息。代理分析源代码、运行分类、创建依赖关系映射并确定任何缺失的构件。同时会识别出重复的组件。
   + **文档生成**-为大型机应用程序 AWS Transform 生成文档。通过分析代码，它可以自动创建应用程序的详细文档，包括对遗留系统中存在的业务逻辑、流程、集成和依赖关系的描述。
   + **业务逻辑提取** — AWS Transform 分析 COBOL 程序以记录其核心业务逻辑，从而帮助您了解基本的业务逻辑。
   + **代码分解** — 将代码分 AWS Transform 解为考虑程序和组件之间依赖关系的域。将相关文件和程序归入同一域中，既可提升组织效率，又能确保在将应用程序拆解为更小组件时保持其逻辑结构的完整性。
   + **迁移浪潮规划** — 根据您在分解阶段创建的域， AWS Transform 生成带有建议现代化顺序的迁移浪潮计划。
   + **代码重构** — 将所有或选定域文件中的代码 AWS Transform 重构为 Java 代码。此步骤的目标是保留应用程序的关键业务逻辑，同时将其重构为经过云优化的现代化 Java 应用程序。

1. AWS Transform 将重构后的代码、生成的文档、关联的项目和运行时库存储在您的 Amazon S3 存储桶中。您可执行以下操作：
   + 访问 Amazon S3 存储桶中的运行时文件夹。
   + 按照文档中的 “构建和部署[现代化应用程序重构后” 来构建和部署应用程序](https://docs.aws.amazon.com/transform/latest/userguide/transform-app-mainframe-workflow-build-deploy.html)。 AWS Transform 
   + 通过聊天界面，索取并下载样本 AWS CloudFormation AWS Cloud Development Kit (AWS CDK)、或 Hashicorp Terraform 模板。这些模板可以帮助您部署支持重构后的应用程序所需的 AWS 资源。
   + 使用 [Reforge](https://docs.aws.amazon.com/transform/latest/userguide/transform-app-mainframe-workflow.html#transform-app-mainframe-workflow-refactor-code-reforge) 通过使用大型语言模型来提高重构代码的质量 ()。LLMs在将 COBOL 转换为 Java 代码时，重构引擎保留了 COBOL 的功能等效性。Reforge 是一个可选步骤，可在转换后执行。此步骤用于重构代码 LLMs ，使其与原生 Java 非常相似，这样可以提高可读性和可维护性。Reforge 还会添加易于理解的注释，帮助您理解代码，并采用现代编码模式和最佳实践。

## 工具
<a name="modernize-carddemo-mainframe-app-tools"></a>

**AWS 服务**
+ [AWS Transform](https://docs.aws.amazon.com/transform/latest/userguide/what-is-service.html)使用 agentic AI 来帮助您加快传统工作负载（例如.NET、大型机和工作负载）的现代化。 VMware 
+ [AWS IAM Identity Center](https://docs.aws.amazon.com/singlesignon/latest/userguide/what-is.html)帮助您集中管理对您的应用程序 AWS 账户 和云应用程序的单点登录 (SSO) 访问权限。
+ [Amazon Simple Storage Service（Amazon S3）](https://docs.aws.amazon.com/AmazonS3/latest/userguide/Welcome.html)是一项基于云的对象存储服务，可帮助您存储、保护和检索任意数量的数据。

**代码存储库 **

您可以将开源 AWS [CardDemo](https://github.com/aws-samples/aws-mainframe-modernization-carddemo)大型机应用程序用作示例应用程序，开始大型机现代化。

## 最佳实践
<a name="modernize-carddemo-mainframe-app-best-practices"></a>
+ **从小**处着手 — 从不太复杂的小代码（15,000—20,000 行代码）开始，以了解如何 AWS Transform 分析和转换大型机应用程序。
+ **与人类专业知识相结合** — AWS Transform 用作加速器，同时应用人类专业知识以获得最佳结果。
+ **彻底审查和测试** – 务必仔细审查转换后的代码，并运行全面测试以验证转换后功能的等效性。
+ **提供反馈**-要提供反馈和改进建议，请使用中的**发送反馈**按钮 AWS 管理控制台 或使用创建案例[AWS 支持](https://support.console.aws.amazon.com/)。有关更多信息，请参阅[创建支持案例](https://docs.aws.amazon.com/awssupport/latest/user/case-management.html)。您的意见对于改进服务和未来的产品开发非常宝贵。

## 操作说明
<a name="modernize-carddemo-mainframe-app-epics"></a>

### 准备大型机应用程序
<a name="prepare-the-mainframe-application"></a>


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 创建存储桶。 | 在启用该功能的相同 AWS 账户 区域中创建 Amazon S3 存储桶。 AWS Transform 您可以使用此存储桶存储大型机应用程序代码，并 AWS Transform 使用此存储桶存储生成的文档、重构后的代码以及与转换相关的其他文件。有关说明，请参阅 Amazon S3 文档中的[创建存储桶](https://docs.aws.amazon.com/AmazonS3/latest/userguide/create-bucket-overview.html)。 | 常规 AWS | 
| 准备大型机应用程序 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/modernize-carddemo-mainframe-app.html) | 应用程序开发者、 DevOps 工程师 | 

### 配置 IAM 身份中心和 AWS Transform
<a name="configure-sso-and-trn"></a>


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 将用户添加到 IAM Identity Center。 | 将您的潜在用户添加到 IAM Identity Center。按照 AWS Transform 文档中在 [IAM 身份中心添加用户中的](https://docs.aws.amazon.com/transform/latest/userguide/transform-user-management.html#transform-add-idc-users)说明进行操作。 | AWS 管理员 | 
| 启用 AWS Transform 和添加用户。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/modernize-carddemo-mainframe-app.html) | AWS 管理员 | 
| 配置用户对 AWS Transform Web 应用程序的访问权限。 | 每个用户都必须接受访问该 AWS Transform Web 应用程序的邀请。按照 AWS Transform 文档中[接受邀请中的](https://docs.aws.amazon.com/transform/latest/userguide/transform-user-onboarding.html#transform-user-invitation)说明进行操作。 | 应用程序开发人员、应用程序所有者 | 
| 登录 AWS Transform Web 应用程序。 | 按照[登录中的说明进行](https://docs.aws.amazon.com/transform/latest/userguide/transform-user-onboarding.html#transform-user-signin)操作 AWS Transform。 | 应用程序开发人员、应用程序所有者 | 
| 设置工作区。 | 设置一个用户可以在 AWS Transform Web 应用程序中进行协作的工作区。按照 AWS Transform 文档中[启动项目中的](https://docs.aws.amazon.com/transform/latest/userguide/transform-environment.html#start-workflow)说明进行操作。 | AWS 管理员 | 

### 转换大型机应用程序
<a name="transform-the-mainframe-application"></a>


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 创建转换作业。 | 创建转型任务以实现 CardDemo 大型机应用程序的现代化。有关说明，请参阅 AWS Transform 文档中的[创建和启动作业](https://docs.aws.amazon.com/transform/latest/userguide/transform-app-mainframe-workflow.html#transform-app-mainframe-workflow-start-job)。当要求你在 AWS Transform 聊天界面中设置目标时，选择**执行大型机现代化（IBM z/OS 到 AWS）**，然后选择**分析代码、生成技术文档、业务逻辑、分解代码、规划迁移顺序和将代码转换**为 Java。 | 应用程序开发人员、应用程序所有者 | 
| 设置连接器。 | 建立指向包含 CardDemo 大型机应用程序的 Amazon S3 存储桶的连接器。此连接器 AWS Transform 允许访问存储桶中的资源并执行连续的转换功能。有关说明，请参阅 AWS Transform 文档[中的设置连接器](https://docs.aws.amazon.com/transform/latest/userguide/transform-app-mainframe-workflow.html#transform-app-mainframe-workflow-setup-connector)。 | AWS 管理员 | 
| 执行代码分析。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/modernize-carddemo-mainframe-app.html)有关更多信息，请参阅 AWS Transform 文档中的[代码分析](https://docs.aws.amazon.com/transform/latest/userguide/transform-app-mainframe-workflow.html#transform-app-mainframe-workflow-code-analysis)。 | 应用程序开发人员、应用程序所有者 | 
| 生成技术文档。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/modernize-carddemo-mainframe-app.html)有关更多信息，请参阅[文档中的生成技术](https://docs.aws.amazon.com/transform/latest/userguide/transform-app-mainframe-workflow.html#transform-app-mainframe-workflow-generate-documentation) AWS Transform 文档。 | 应用程序开发人员、应用程序所有者 | 
| 提取业务逻辑。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/modernize-carddemo-mainframe-app.html)有关更多信息，请参阅 AWS Transform 文档中的[提取业务逻辑](https://docs.aws.amazon.com/transform/latest/userguide/transform-app-mainframe-workflow.html#transform-app-mainframe-workflow-extract-business-logic)。 | 应用程序开发人员、应用程序所有者 | 
| 分解代码。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/modernize-carddemo-mainframe-app.html)有关分解和种子的更多信息，请参阅文档中的[AWS Transform 分解](https://docs.aws.amazon.com/transform/latest/userguide/transform-app-mainframe-workflow.html#transform-app-mainframe-workflow-decomposition)。 | 应用程序开发人员、应用程序所有者 | 
| 规划迁移过程 | 规划 CardDemo 应用程序的迁移浪潮。按照 AWS Transform 文档中[迁移浪潮规划](https://docs.aws.amazon.com/transform/latest/userguide/transform-app-mainframe-workflow.html#transform-app-mainframe-workflow-wave-planning)中的说明查看和编辑波浪计划。 | 应用程序开发人员、应用程序所有者 | 
| 重构代码。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/modernize-carddemo-mainframe-app.html) | 应用程序开发人员、应用程序所有者 | 
| （可选）使用 Reforge 改进 Java 代码。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/modernize-carddemo-mainframe-app.html)有关更多信息，请参阅 AWS Transform 文档中的 [Reforge](https://docs.aws.amazon.com/transform/latest/userguide/transform-app-mainframe-workflow.html#transform-app-mainframe-workflow-refactor-code-reforge)。 | 应用程序开发人员、应用程序所有者 | 
| 简化部署。 | AWS Transform 可以为 CloudFormation、 AWS CDK或 Terraform 提供基础设施即代码 (IaC) 模板。这些模板可帮助部署核心组件，包括计算、数据库、存储和安全资源。[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/modernize-carddemo-mainframe-app.html)有关更多信息，请参阅 AWS Transform 文档中的[部署功能](https://docs.aws.amazon.com/transform/latest/userguide/transform-app-mainframe-workflow.html#transform-app-mainframe-features-deployment)。 | 应用程序开发人员、应用程序所有者 | 

## 问题排查
<a name="modernize-carddemo-mainframe-app-troubleshooting"></a>


| 问题 | 解决方案 | 
| --- | --- | 
| 您无法在 AWS Transform Web 应用程序中查看源代码或生成的文档。 | 在 Amazon S3 存储桶的 CORS 权限中添加一项策略以允许其 AWS Transform 作为源。有关更多信息，请参阅 AWS Transform 文档[中的 S3 存储桶 CORS 权限](https://docs.aws.amazon.com/transform/latest/userguide/transform-app-mainframe-workflow.html#transform-app-mainframe-workflow-setup-connector-s3)。 | 

## 相关资源
<a name="modernize-carddemo-mainframe-app-resources"></a>

**AWS 文档**
+ [大型机应用程序的转型](https://docs.aws.amazon.com/transform/latest/userguide/transform-app-mainframe-workflow.html)（AWS Transform 文档）

**其他 AWS 资源**
+ [使用 AI 代理加速您的大型机现代化之旅 AWS Transform](https://aws.amazon.com/blogs/migration-and-modernization/accelerate-your-mainframe-modernization-journey-using-ai-agents-with-aws-transform/)（AWS 博客文章）
+ [AWS Transform FAQs](https://aws.amazon.com/transform/faq/)
+ [AWS IAM Identity Center FAQs](https://aws.amazon.com/iam/identity-center/faqs/)

**视频和教程**
+ [Amazon Q 开发者简介：转型](https://explore.skillbuilder.aws/learn/courses/21893/aws-flash-introduction-to-amazon-q-developer-transform)（AWS 技能生成器）
+ [AWS re: Invent 2024-使用 Amazon Q Developer 更快地实现大型机应用程序的现代化](https://www.youtube.com/watch?v=pSi0XtYfY4o) () YouTube
+ [AWS re: Invent 2024-自动化迁移和现代化](https://www.youtube.com/watch?v=9FjxnEoH5wg)以加快转型 () YouTube
+ [AWS re: Invent 2024-丰田利用一代人工智能推动创新并提高运营效率](https://www.youtube.com/watch?v=_NXc1MJenw4) () YouTube

**注意**  
AWS Transform 以前被称为 *Amazon Q 大型机开发人员转换*。