

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

# 使用微软 Excel 和 Python 为 AWS DMS 任务创建 AWS CloudFormation 模板
<a name="create-aws-cloudformation-templates-for-aws-dms-tasks-using-microsoft-excel-and-python"></a>

*Venkata Naveen Koppula，Amazon Web Services*

## Summary
<a name="create-aws-cloudformation-templates-for-aws-dms-tasks-using-microsoft-excel-and-python-summary"></a>

此模式概述了使用微软 Excel 和 Python 自动为 [AWS 数据库迁移服务](https://aws.amazon.com/dms/) (AWS DMS) 创建 AWS CloudFormation 模板的步骤。

使用 AWS DMS 迁移数据库通常涉及创建 AWS CloudFormation 模板来配置 AWS DMS 任务。以前，创建 AWS CloudFormation 模板需要了解 JSON 或 YAML 编程语言。借助这一工具，您只需要了解 Excel 的基本知识以及如何使用终端或命令窗口运行 Python 脚本即可。

作为输入，该工具采用一个 Excel 工作簿，其中包括要迁移的表的名称、AWS DMS 终端节点的 Amazon 资源名称 (ARNs) 以及 AWS DMS 复制实例。然后，该工具会为所需的 AWS DMS 任务生成 AWS CloudFormation 模板。

有关详细步骤和背景信息，请参阅 [AWS 数据库博客中的博客文章使用 Microsoft Excel 为 AWS DMS 任务创建 AWS CloudFormation 模板](https://aws.amazon.com/blogs/database/create-aws-cloudformation-templates-for-aws-dms-tasks-using-microsoft-excel/)。

## 先决条件和限制
<a name="create-aws-cloudformation-templates-for-aws-dms-tasks-using-microsoft-excel-and-python-prereqs"></a>

**先决条件**
+ 一个有效的 Amazon Web Services account
+ Microsoft Excel 版本 2016 或更高版本。
+ Python（2.7 或更高版本）
+ **xlrd** Python 模块(在命令提示符下安装，命令为：**pip install xlrd**)
+ AWS DMS 源端点和目标端点以及 AWS DMS 复制实例

**限制**
+ 架构、表和关联列的名称将在目标端点处转换为小写字符。
+ 此工具不涉及 AWS DMS 端点和复制实例的创建。
+ 目前，该工具仅支持每个 AWS DMS 任务使用一个架构。

## 架构
<a name="create-aws-cloudformation-templates-for-aws-dms-tasks-using-microsoft-excel-and-python-architecture"></a>

**源技术堆栈**
+ 本地数据库
+ Microsoft Excel

**目标技术堆栈**
+ AWS CloudFormation 模板
+ Amazon Web Services Cloud 中的数据库 

**架构**

![使用 Excel 和 Python 自动为 AWS DMS 创建 CloudFormation 模板的工作流程。](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/images/pattern-img/778c7c1e-2647-496f-8afd-52ff1ef02489/images/8fe1550d-8966-41aa-a480-5f7bef20629f.png)


## 工具
<a name="create-aws-cloudformation-templates-for-aws-dms-tasks-using-microsoft-excel-and-python-tools"></a>
+ [Pycharm IDE](https://aws.amazon.com/pycharm/) 或任何支持 Python 版本 3.6 的集成式开发环境(IDE)
+ Microsoft Office 2016（适用于 Microsoft Excel）

## 操作说明
<a name="create-aws-cloudformation-templates-for-aws-dms-tasks-using-microsoft-excel-and-python-epics"></a>

### 配置网络、AWS DMS 复制实例和端点
<a name="configure-the-network-aws-dms-replication-instance-and-endpoints"></a>


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 如有必要，可请求增加服务配额。 | 如有需要，可请求增加 AWS DMS 任务的服务限额。 | 常规 AWS | 
| 配置 AWS 区域、虚拟私有云 (VPCs)、CIDR 范围、可用区和子网。 |  | 常规 AWS | 
| 配置 AWS DMS 复制实例。 | AWS DMS 复制实例可以连接到本地数据库和 AWS 数据库。 | 常规 AWS | 
| 配置 AWS DMS 端点。 | 为源数据库和目标数据库配置端点。 | 常规 AWS | 

### 为 AWS DMS 任务和标签准备工作表
<a name="prepare-the-worksheets-for-aws-dms-tasks-and-tags"></a>


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 配置表列表。 | 列出迁移中涉及的所有表。 | 数据库 | 
| 准备任务工作表。 | 使用您配置的表列表准备 Excel 工作表。 | 常规 AWS、Microsoft Excel | 
| 准备标签工作表。 | 详述附加到 AWS DMS 任务的 AWS 资源标签。 | 常规 AWS、Microsoft Excel | 

### 下载并运行工具
<a name="download-and-run-the-tool"></a>


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 从 GitHub 存储库下载并提取模板生成工具。 | GitHub 存储库: https://github.com/aws-samples/dms-cloudformation-templates-generator/ |  | 
| 运行工具。 | 请按照“参考和帮助”下列出的博客文章中的详细说明进行操作。 |  | 

## 相关资源
<a name="create-aws-cloudformation-templates-for-aws-dms-tasks-using-microsoft-excel-and-python-resources"></a>
+ [使用微软 Excel 为 AWS DMS 任务创建 AWS CloudFormation 模板（博客文章）](https://aws.amazon.com/blogs/database/create-aws-cloudformation-templates-for-aws-dms-tasks-using-microsoft-excel/)
+ [DMS CloudFormation 模板生成器（GitHub 存储库）](https://github.com/aws-samples/dms-cloudformation-templates-generator/tree/v1.0)
+ [Python 文档](https://www.python.org/)
+ [XLRD 说明和下载](https://pypi.org/project/xlrd/)
+ [AWS DMS 文档](https://docs.aws.amazon.com/dms/latest/userguide/)
+ [AWS CloudFormation 文档](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/)