

 从补丁 198 开始，Amazon Redshift 将不再支持创建新的 Python UDF。现有的 Python UDF 将继续正常运行至 2026 年 6 月 30 日。有关更多信息，请参阅[博客文章](https://www.amazonaws.cn/blogs/big-data/amazon-redshift-python-user-defined-functions-will-reach-end-of-support-after-june-30-2026/)。

# 设置 Amazon Redshift CLI
<a name="setting-up-rs-cli"></a>

本部分介绍如何设置和运行用于管理 Amazon Redshift 的 Amazon CLI 命令行工具。Amazon Redshift 命令行工具在 Amazon Command Line Interface (Amazon CLI) 上运行，而后者使用 Python ([https://www.python.org/](https://www.python.org))。Amazon CLI 可在支持 Python 的所有操作系统上运行。

## 安装 Amazon Command Line Interface
<a name="setting-up.installing-the-tools"></a>

要开始使用 Amazon Redshift 命令行工具，首先要设置 Amazon CLI，然后添加用于定义 Amazon Redshift CLI 选项的配置文件。

如果您已为其他 Amazon CLI 服务安装并配置 Amazon，则可跳过该程序。

**安装 Amazon Command Line Interface**

1. 请转到[安装或更新到最新版本的 Amazon CLI](https://docs.amazonaws.cn/cli/latest/userguide/cli-chap-getting-set-up.html)，然后按照说明安装 Amazon CLI。

   要进行 CLI 访问，您需要访问密钥 ID 和秘密访问密钥。如果可能，请使用临时凭证代替长期访问密钥。临时凭证包括访问密钥 ID、秘密访问密钥，以及一个指示凭证何时到期的安全令牌。有关更多信息，请参阅《IAM 用户指南》**中的[将临时凭证用于 Amazon 资源](https://docs.amazonaws.cn/IAM/latest/UserGuide/id_credentials_temp_use-resources.html)。

1. 创建包含访问密钥、默认区域和命令输出格式等配置信息的文件。然后，设置 `AWS_CONFIG_FILE` 环境变量以引用该文件。有关详细说明，请转到 Amazon Command Line Interface 用户指南中的[配置 Amazon 命令行界面](https://docs.amazonaws.cn/cli/latest/userguide/cli-chap-getting-started.html)。

1. 运行一个测试命令以确认 Amazon CLI 界面可正常工作。例如，以下命令应该显示有关 Amazon CLI 的帮助信息：

   ```
   aws help
   ```

   以下命令应该显示有关 Amazon Redshift 的帮助信息：

   ```
   aws redshift help
   ```

有关 Amazon Redshift CLI 命令的参考资料，请转至 Amazon CLI 参考中的 [Amazon Redshift](https://docs.amazonaws.cn/cli/latest/reference/redshift/index.html)。