

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

# 使用 AWS Transform 和 Terraform 实现大型机应用程序的现代化和部署
<a name="modernize-mainframe-app-transform-terraform"></a>

*Mason Cahill、Polaris Jhandi、Prachi Khanna、Sivasubramanian Ramani 和 Santosh Kumar Singh，Amazon Web Services*

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

[AWS Transform](https://docs.aws.amazon.com/transform/latest/userguide/what-is-service.html)可以加速.NET、大型机和 VMware 工作负载的大规模现代化。它部署了专门的 AI 代理，可以自动执行评估、代码分析、重构、分解、依赖关系映射、验证、转型规划等复杂的任务。此模式演示了如何使用对大型机应用程序 AWS Transform 进行现代化改造，然后使用 [Hashic](https://developer.hashicorp.com/terraform/intro) orp Terraform 将其部署到 AWS 基础架构。这些 step-by-step说明可帮助您将开源大型机应用程序示例，从 COBOL 转换为[CardDemo](https://github.com/aws-samples/aws-mainframe-modernization-carddemo)现代 Java 应用程序。

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

**先决条件**
+ 活跃的 AWS 账户
+ 创建 AWS 资源和部署应用程序的管理权限
+ [已配置](https://developer.hashicorp.com/terraform/tutorials/aws-get-started?utm_source=WEBSITE&utm_medium=WEB_IO&utm_offer=ARTICLE_PAGE&utm_content=DOCS) Terraform 版本 1.5.7 或更高版本
+ AWS [Terraform 的提供者，已配置](https://registry.terraform.io/providers/hashicorp/aws/2.36.0/docs#authentication)
+ [已启用](https://docs.aws.amazon.com/singlesignon/latest/userguide/enable-identity-center.html)AWS IAM Identity Center
+ [已启用](https://docs.aws.amazon.com/transform/latest/userguide/getting-started.html)AWS Transform
+ [已加入 AWS Transform 工作空间的](https://docs.aws.amazon.com/transform/latest/userguide/transform-user-management.html)用户，其参与者角色可以运行转换作业

**限制**
+ AWS Transform 仅在某些版本中可用 AWS 区域。有关支持区域的完整列表，请参阅 [AWS Transform支持的区域](https://docs.aws.amazon.com/transform/latest/userguide/regions.html)。
+  AWS Transform对大型机转换功能设有服务配额。有关更多信息，请参阅 [AWS Transform配额](https://docs.aws.amazon.com/transform/latest/userguide/transform-limits.html)。
+ 要在共享工作区上进行协作，所有用户都必须是与您 AWS IAM Identity Center 的 AWS Transform Web 应用程序实例关联的相同实例的注册用户。
+ 亚马逊简单存储服务 (Amazon S3) Semple Storage Service 存储桶 AWS Transform 必须位于 AWS 账户 相同的区域中。

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

下图显示了旧版应用程序的 end-to-end现代化以及部署到的过程 AWS Cloud。应用程序和数据库凭证存储在中 AWS Secrets Manager，Amazon CloudWatch 提供监控和记录功能。

![\[AWS Transform 通过 Terraform 实现大型机应用程序和部署现代化。\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/images/pattern-img/78bc1e6e-cd3d-4c6d-ae4b-0675a6898fd9/images/332ccf35-f55a-449e-a05d-7e321b3867b7.png)


下图显示了如下工作流：

1. 通过 AWS IAM Identity Center，用户在中进行身份验证和访问 AWS Transform 。 AWS 账户

1. 用户将 COBOL 大型机代码上传到 Amazon S3 存储桶，然后在 AWS Transform中启动转换。

1. AWS Transform 将 COBOL 代码现代化为云原生 Java 代码，并将现代化的代码存储在 Amazon S3 存储桶中。

1. Terraform 创建用于部署现代化应用程序 AWS 的基础设施，包括应用程序负载均衡器、亚马逊弹性计算云 (Amazon EC2) 实例和亚马逊关系数据库服务 (Amazon RDS) 数据库。Terraform 将现代化代码部署到 Amazon EC2 实例。

1. VSAM 文件上传到 Amazon EC2，然后从 Amazon EC2 迁移到 Amazon RDS 数据库。

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

**AWS 服务**
+ [Amazon Elastic Compute Cloud（Amazon EC2）](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/concepts.html)在 AWS Cloud中提供可扩展的计算容量。您可以根据需要启动任意数量的虚拟服务器，并快速纵向扩展或缩减这些服务器。在此模式中，SQL Server 失效转移集群实例安装在 Amazon EC2 实例上。
+ [AWS IAM Identity Center](https://docs.aws.amazon.com/singlesignon/latest/userguide/what-is.html)帮助您集中管理对您的应用程序 AWS 账户 和云应用程序的单点登录 (SSO) 访问权限。
+ [Amazon Relational Database Service（Amazon RDS）](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Welcome.html)可帮助您在 AWS Cloud中设置、操作和扩展关系数据库。
+ [AWS Secrets Manager](https://docs.aws.amazon.com/secretsmanager/latest/userguide/intro.html) 可帮助您将代码中的硬编码凭证（包括密码）替换为对 Secrets Manager 进行的 API 调用，以便以编程方式检索此密钥。
+ [Amazon Simple Storage Service（Amazon S3）](https://docs.aws.amazon.com/AmazonS3/latest/userguide/Welcome.html)是一项基于云的对象存储服务，可帮助您存储、保护和检索任意数量的数据。
+ [AWS Transform](https://docs.aws.amazon.com/transform/latest/userguide/what-is-service.html)使用 agentic AI 来帮助您加快传统工作负载（例如.NET、大型机和工作负载）的现代化。 VMware 

**其他工具**
+ [Apache Maven](https://maven.apache.org/) 是一款适用于 Java 项目的开源软件项目管理和构建自动化工具。
+ [Apache Tomcat](https://tomcat.apache.org/) 是一款开源 Servlet 容器和用于 Java 代码的 Web 服务器。
+ [HashiCorp Terraform](https://www.terraform.io/docs) 是一款基础设施即代码（IaC）工具，可帮助您使用代码来预调配和管理云基础设施和资源。
+ [Spring Boot](https://spring.io/projects/spring-boot) 是一个开源框架，以 Java 的 Spring 框架为基础构建。

**代码存储库**

此模式的代码可在 GitHub [大型机转换 E2E](https://github.com/aws-samples/sample-mainframe-transformation-e2e) 存储库中找到。此模式使用开源 AWS [CardDemo](https://github.com/aws-samples/aws-mainframe-modernization-carddemo)大型机应用程序作为示例应用程序。

## 最佳实践
<a name="modernize-mainframe-app-transform-terraform-best-practices"></a>
+ 分配要迁移的代码和资源的全部所有权。
+ 先开发并测试概念验证，再全面迁移。
+ 确保得到所有利益相关者的承诺。
+ 建立清晰的沟通渠道。
+ 定义并记录最简可行产品（MVP）要求。
+ 设定明确的成功标准。

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

### 准备并上传大型机应用程序代码
<a name="prepare-and-upload-the-mainframe-application-code"></a>


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 创建存储桶。 | 在已启用的相同 AWS 账户 区域中创建 Amazon S3 存储桶。 AWS Transform 您可以使用此存储桶存储构建和运行应用程序所需的大型机应用程序代码、数据和其他脚本。 AWS Transform 使用此存储桶存储重构后的代码和其他与转换相关的文件。有关说明，请参阅 Amazon S3 文档中的[创建存储桶](https://docs.aws.amazon.com/AmazonS3/latest/userguide/create-bucket-overview.html)。 | 常规 AWS、AWS 管理员 | 
| 设置存储桶的 CORS 权限。 | 在设置存储桶以进行 AWS Transform 访问时，您需要为存储桶配置跨源资源共享 (CORS)。如果设置不正确，可能无法使用 AWS Transform的内联查看或文件比较功能。有关如何为存储桶配置 CORS 的说明，请参阅 Amazon S3 存储桶中的[使用跨域资源共享](https://docs.aws.amazon.com/AmazonS3/latest/userguide/cors.html)。有关策略，请参阅 AWS Transform 文档[中的 S3 存储桶 CORS 权限](https://docs.aws.amazon.com/transform/latest/userguide/transform-app-mainframe-workflow.html#transform-app-mainframe-workflow-setup-connector-s3)。 | 常规 AWS、AWS 管理员 | 
| 准备大型机应用程序代码示例。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/modernize-mainframe-app-transform-terraform.html) | 常规 AWS，应用程序开发人员 | 

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


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 设置作 AWS Transform 业。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/modernize-mainframe-app-transform-terraform.html) | 应用程序开发人员、应用程序所有者 | 
| 设置连接器。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/modernize-mainframe-app-transform-terraform.html) | 应用程序开发人员、应用程序所有者 | 
| 转换代码。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/modernize-mainframe-app-transform-terraform.html) | 应用程序开发人员、应用程序所有者 | 

### 通过 Terraform 部署基础设施
<a name="deploy-the-infrastructure-through-terraform"></a>


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 更新模板。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/modernize-mainframe-app-transform-terraform.html)对于生产或类似于生产的环境，请配置其他安全组件。例如，启用[针对应用程序负载均衡器的AWS WAF 保护](https://aws.amazon.com/about-aws/whats-new/2024/02/aws-application-load-balancer-one-click-waf-integrations/)。 | 常规 AWS、AWS 管理员 | 
| 部署基础设施。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/modernize-mainframe-app-transform-terraform.html) | Terraform | 

### 在 Amazon EC2 实例上安装和配置 Apache Tomcat
<a name="install-and-configure-apache-tomcat-on-the-ec2-instance"></a>


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 安装所需软件： | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/modernize-mainframe-app-transform-terraform.html) | 应用程序开发人员、迁移工程师 | 
| 验证软件安装。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/modernize-mainframe-app-transform-terraform.html) | 应用程序开发人员、迁移工程师 | 

### 编译并打包完成现代化的应用程序代码
<a name="compile-and-package-the-modernized-application-code"></a>


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 下载并解压生成的代码。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/modernize-mainframe-app-transform-terraform.html) | 应用程序开发人员、迁移工程师 | 
| 构建现代化的应用程序。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/modernize-mainframe-app-transform-terraform.html) | 应用程序开发人员、迁移工程师 | 

### 迁移数据库
<a name="migrate-the-database"></a>


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 创建数据库和 JICS 架构。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/modernize-mainframe-app-transform-terraform.html) | 应用程序开发人员、迁移工程师 | 
| 验证数据库创建。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/modernize-mainframe-app-transform-terraform.html) | 应用程序开发人员、迁移工程师 | 
| 将数据迁移到 JICS 数据库。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/modernize-mainframe-app-transform-terraform.html) | 应用程序开发人员、迁移工程师 | 

### 安装现代化的应用程序
<a name="install-the-modernized-application"></a>


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 在 Amazon EC2 实例上安装现代化的应用程序 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/modernize-mainframe-app-transform-terraform.html) | 应用程序开发人员、云架构师 | 
| 重新启动 Tomcat 服务器。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/modernize-mainframe-app-transform-terraform.html) | 应用程序开发人员、云架构师 | 
| 迁移 VSAM 数据集。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/modernize-mainframe-app-transform-terraform.html) | 应用程序开发人员、迁移工程师 | 
| 更新 Groovy 脚本中的参数。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/modernize-mainframe-app-transform-terraform.html) | 应用程序开发人员 | 

### 测试应用程序
<a name="test-the-application"></a>


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 测试现代化的应用程序。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/modernize-mainframe-app-transform-terraform.html) | 应用程序开发人员、测试工程师 | 
| 验证批处理脚本。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/modernize-mainframe-app-transform-terraform.html) | 应用程序开发人员、测试工程师 | 

### 清理
<a name="clean-up"></a>


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 准备删除基础设施。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/modernize-mainframe-app-transform-terraform.html) | 常规 AWS | 
| 删除基础设施。 | 这些步骤将永久删除您的资源。在继续之前，请确保您已备份所有重要数据。[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/modernize-mainframe-app-transform-terraform.html) | 常规 AWS | 

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


| 问题 | 解决方案 | 
| --- | --- | 
| Terraform 身份验证 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/modernize-mainframe-app-transform-terraform.html) | 
| Tomcat 相关错误 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/modernize-mainframe-app-transform-terraform.html) | 
| URL 名称未加载 | 确保在入站规则中，应用程序负载均衡器安全组将您的 IP 地址作为源。 | 
| Tomcat 日志中存在身份验证问题 | 确认中的数据库密钥密码 AWS Secrets Manager 和 **server.xml** 中的密码匹配。 | 

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

**AWS 规范性指导**
+ [使用 AWS Transform 实现 CardDemo 大型机应用程序的现代化](https://docs.aws.amazon.com/prescriptive-guidance/latest/patterns/modernize-carddemo-mainframe-app.html)

**AWS 服务文档**
+ [AWS Blu Age Blusam 管理控制台](https://docs.aws.amazon.com/m2/latest/userguide/ba-shared-bac-userguide.html)
+ [AWS Blu Age Runtime（非托管）的基础架构设置要求](https://docs.aws.amazon.com/m2/latest/userguide/ba-infrastructure-setup.html)
+ [入门 AWS Blu Age 运行时](https://docs.aws.amazon.com/m2/latest/userguide/ba-runtime-setup-onboard.html)
+ [大型机应用程序的现代化](https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/transform-app-mainframe.html)
+ [为 AWS Blu Age Runtime 设置配置](https://docs.aws.amazon.com/m2/latest/userguide/ba-runtime-config.html)

**AWS 博客文章**
+ [使用 AI 代理加速您的大型机现代化之旅 AWS Transform](https://aws.amazon.com/blogs/migration-and-modernization/accelerate-your-mainframe-modernization-journey-using-ai-agents-with-aws-transform/)