> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-vortex-format.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 如何创建 AWS IAM 用户和 S3 存储桶

> 如何创建 AWS IAM 用户和 S3 存储桶。

export const Image = ({img, alt, size = "lg"}) => {
  const normalizedSize = ["sm", "md", "lg"].includes(size) ? size : "lg";
  return <div className={`ch-image-${normalizedSize}`}>
      <Frame>
        <img src={img} alt={alt} />
      </Frame>
    </div>;
};

> 本指南将向你展示如何在 AWS 中创建 IAM 用户和 S3 存储桶，
> 这是将备份保存到 S3 或将 ClickHouse 配置为
> 在 S3 上存储数据所需的前置步骤

<div id="create-an-aws-iam-user">
  ## 创建 AWS IAM 用户
</div>

在此过程中，我们将创建一个用于服务账号的用户，而不是登录用户。

1. 登录 AWS IAM 管理控制台。

2. 在 `Users` 选项卡中，选择 `Create user`

<Image size="lg" img="https://mintcdn.com/private-7c7dfe99-vortex-format/tee0vtC1xMN3cEIV/images/_snippets/s3/2025/s3-1.webp?fit=max&auto=format&n=tee0vtC1xMN3cEIV&q=85&s=24489adfdf390487a8b511420d7d8b1d" alt="AWS IAM 管理控制台 - 添加新用户" width="4040" height="1940" data-path="images/_snippets/s3/2025/s3-1.webp" />

3. 输入用户名

<Image size="lg" img="https://mintcdn.com/private-7c7dfe99-vortex-format/tee0vtC1xMN3cEIV/images/_snippets/s3/2025/s3-2.webp?fit=max&auto=format&n=tee0vtC1xMN3cEIV&q=85&s=f737f23768d96b91a409378c4e4e0a1a" alt="AWS IAM 管理控制台 - 添加新用户" width="4040" height="1408" data-path="images/_snippets/s3/2025/s3-2.webp" />

4. 选择 `Next`

<Image size="lg" img="https://mintcdn.com/private-7c7dfe99-vortex-format/tee0vtC1xMN3cEIV/images/_snippets/s3/2025/s3-3.webp?fit=max&auto=format&n=tee0vtC1xMN3cEIV&q=85&s=65703827e3f10db09594596d6e3d35f5" alt="AWS IAM 管理控制台 - 添加新用户" width="4040" height="1860" data-path="images/_snippets/s3/2025/s3-3.webp" />

5. 选择 `Next`

<Image size="lg" img="https://mintcdn.com/private-7c7dfe99-vortex-format/tee0vtC1xMN3cEIV/images/_snippets/s3/2025/s3-4.webp?fit=max&auto=format&n=tee0vtC1xMN3cEIV&q=85&s=d41dd4c0b5d067589e414f38db694232" alt="AWS IAM 管理控制台 - 添加新用户" width="4040" height="1850" data-path="images/_snippets/s3/2025/s3-4.webp" />

6. 选择 `Create user`

用户现已创建。
点击新创建的用户。

<Image size="lg" img="https://mintcdn.com/private-7c7dfe99-vortex-format/tee0vtC1xMN3cEIV/images/_snippets/s3/2025/s3-5.webp?fit=max&auto=format&n=tee0vtC1xMN3cEIV&q=85&s=24ef93acc68a605601356713d5169880" alt="AWS IAM 管理控制台 - 添加新用户" width="4040" height="792" data-path="images/_snippets/s3/2025/s3-5.webp" />

7. 选择 `Create access key`

<Image size="lg" img="https://mintcdn.com/private-7c7dfe99-vortex-format/tee0vtC1xMN3cEIV/images/_snippets/s3/2025/s3-6.webp?fit=max&auto=format&n=tee0vtC1xMN3cEIV&q=85&s=f82dd58b921a7392007ec046f7662e25" alt="AWS IAM 管理控制台 - 添加新用户" width="4040" height="1900" data-path="images/_snippets/s3/2025/s3-6.webp" />

8. 选择 `Application running outside AWS`

<Image size="lg" img="https://mintcdn.com/private-7c7dfe99-vortex-format/tee0vtC1xMN3cEIV/images/_snippets/s3/2025/s3-7.webp?fit=max&auto=format&n=tee0vtC1xMN3cEIV&q=85&s=0d09defe598f3ee22f158e4ad77a12a9" alt="AWS IAM 管理控制台 - 添加新用户" width="4040" height="1942" data-path="images/_snippets/s3/2025/s3-7.webp" />

9. 选择 `Create access key`

<Image size="lg" img="https://mintcdn.com/private-7c7dfe99-vortex-format/tee0vtC1xMN3cEIV/images/_snippets/s3/2025/s3-8.webp?fit=max&auto=format&n=tee0vtC1xMN3cEIV&q=85&s=70a885c0ce833983debde5b7f6a203a7" alt="AWS IAM 管理控制台 - 添加新用户" width="4040" height="1080" data-path="images/_snippets/s3/2025/s3-8.webp" />

10. 将 access key 和 secret 下载为 .csv 文件，以便稍后使用

<Image size="lg" img="https://mintcdn.com/private-7c7dfe99-vortex-format/tee0vtC1xMN3cEIV/images/_snippets/s3/2025/s3-9.webp?fit=max&auto=format&n=tee0vtC1xMN3cEIV&q=85&s=bd2cd2b2d15ab4e79f6acc37d7fb54d6" alt="AWS IAM 管理控制台 - 添加新用户" width="3912" height="2036" data-path="images/_snippets/s3/2025/s3-9.webp" />

<div id="create-an-s3-bucket">
  ## 创建 S3 存储桶
</div>

1. 在 S3 存储桶 部分，选择 **Create bucket**

<Image size="lg" img="https://mintcdn.com/private-7c7dfe99-vortex-format/tee0vtC1xMN3cEIV/images/_snippets/s3/2025/s3-10.webp?fit=max&auto=format&n=tee0vtC1xMN3cEIV&q=85&s=80ebf03184a2f06dfc4aaceb02224d50" alt="AWS IAM 管理控制台 - 添加新用户" width="4040" height="2518" data-path="images/_snippets/s3/2025/s3-10.webp" />

2. 输入存储桶 名称，其他选项保持默认即可

<Image size="lg" img="https://mintcdn.com/private-7c7dfe99-vortex-format/tee0vtC1xMN3cEIV/images/_snippets/s3/2025/s3-11.webp?fit=max&auto=format&n=tee0vtC1xMN3cEIV&q=85&s=fd90239626fc89bc318053e216a5722c" alt="AWS IAM 管理控制台 - 添加新用户" width="4040" height="1118" data-path="images/_snippets/s3/2025/s3-11.webp" />

<Note>
  存储桶 名称必须在整个 AWS 范围内唯一，而不只是组织内唯一，否则会报错。
</Note>

3. 保持 `Block all Public Access` 为启用状态；无需开启公共访问。

<Image size="lg" img="https://mintcdn.com/private-7c7dfe99-vortex-format/tee0vtC1xMN3cEIV/images/_snippets/s3/2025/s3-12.webp?fit=max&auto=format&n=tee0vtC1xMN3cEIV&q=85&s=b76c23d7e534079c093293fe3a150e3a" alt="AWS IAM 管理控制台 - 添加新用户" width="4040" height="1106" data-path="images/_snippets/s3/2025/s3-12.webp" />

4. 在页面底部选择 **Create Bucket**

<Image size="lg" img="https://mintcdn.com/private-7c7dfe99-vortex-format/tee0vtC1xMN3cEIV/images/_snippets/s3/2025/s3-13.webp?fit=max&auto=format&n=tee0vtC1xMN3cEIV&q=85&s=a380d4f43f51a0559cd42058c6eb5287" alt="AWS IAM 管理控制台 - 添加新用户" width="4040" height="1872" data-path="images/_snippets/s3/2025/s3-13.webp" />

5. 选择该链接，复制 ARN，并保存下来，以便在为存储桶 配置访问策略时使用

<Image size="lg" img="https://mintcdn.com/private-7c7dfe99-vortex-format/tee0vtC1xMN3cEIV/images/_snippets/s3/2025/s3-14.webp?fit=max&auto=format&n=tee0vtC1xMN3cEIV&q=85&s=e6a7199c1f3c437c3492595ea9b5960b" alt="AWS IAM 管理控制台 - 添加新用户" width="4040" height="934" data-path="images/_snippets/s3/2025/s3-14.webp" />

6. 存储桶 创建完成后，在 S3 buckets 列表中找到新建的 S3 存储桶，并选择其名称，这会进入如下所示的页面：

<Image size="lg" img="https://mintcdn.com/private-7c7dfe99-vortex-format/tee0vtC1xMN3cEIV/images/_snippets/s3/2025/s3-15.webp?fit=max&auto=format&n=tee0vtC1xMN3cEIV&q=85&s=2c0d6a76427e40a0bf696a6a1627a983" alt="AWS IAM 管理控制台 - 添加新用户" width="4040" height="1400" data-path="images/_snippets/s3/2025/s3-15.webp" />

7. 选择 `Create folder`

8. 输入一个文件夹名称，作为 ClickHouse S3 disk 或 Backup 的目标位置，然后在页面底部选择 `Create folder`

<Image size="lg" img="https://mintcdn.com/private-7c7dfe99-vortex-format/tee0vtC1xMN3cEIV/images/_snippets/s3/2025/s3-16.webp?fit=max&auto=format&n=tee0vtC1xMN3cEIV&q=85&s=7278bdaa08d0214a24e214d29a6cd2a9" alt="AWS IAM 管理控制台 - 添加新用户" width="3992" height="1352" data-path="images/_snippets/s3/2025/s3-16.webp" />

9. 该文件夹现在应已显示在存储桶 列表中

<Image size="lg" img="https://mintcdn.com/private-7c7dfe99-vortex-format/tee0vtC1xMN3cEIV/images/_snippets/s3/2025/s3-17.webp?fit=max&auto=format&n=tee0vtC1xMN3cEIV&q=85&s=65828c6ebd93b40b4484825e65b6af34" alt="AWS IAM 管理控制台 - 添加新用户" width="4040" height="1330" data-path="images/_snippets/s3/2025/s3-17.webp" />

10. 选中新文件夹对应的复选框，然后点击 `Copy URL`。保存该 URL，以便在下一节的 ClickHouse Storage configuration 中使用。

<Image size="lg" img="https://mintcdn.com/private-7c7dfe99-vortex-format/tee0vtC1xMN3cEIV/images/_snippets/s3/2025/s3-18.webp?fit=max&auto=format&n=tee0vtC1xMN3cEIV&q=85&s=51694277aca44488f5ca6b0c1a84e81f" alt="AWS IAM 管理控制台 - 添加新用户" width="4040" height="992" data-path="images/_snippets/s3/2025/s3-18.webp" />

11. 选择 **Permissions** 选项卡，并点击 **Bucket Policy** 部分中的 **Edit** 按钮

<Image size="lg" img="https://mintcdn.com/private-7c7dfe99-vortex-format/tee0vtC1xMN3cEIV/images/_snippets/s3/2025/s3-19.webp?fit=max&auto=format&n=tee0vtC1xMN3cEIV&q=85&s=7db02c381e08232e0c64d650be086419" alt="AWS IAM 管理控制台 - 添加新用户" width="4040" height="954" data-path="images/_snippets/s3/2025/s3-19.webp" />

12. 添加存储桶 策略，示例如下

```json theme={null}
{
    "Version": "2012-10-17",
    "Id": "Policy123456",
    "Statement": [
        {
            "Sid": "abc123",
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::782985192762:user/docs-s3-user"
            },
            "Action": "s3:*",
            "Resource": [
                "arn:aws:s3:::ch-docs-s3-bucket",
                "arn:aws:s3:::ch-docs-s3-bucket/*"
            ]
        }
    ]
}
```

<Note>
  上述策略允许对该存储桶执行所有操作
</Note>

| 参数        | 描述               | 示例值                                                                   |
| --------- | ---------------- | --------------------------------------------------------------------- |
| Version   | 策略语言版本，保持原样即可    | 2012-10-17                                                            |
| Sid       | 用户自定义的策略 ID      | abc123                                                                |
| Effect    | 用户请求是被允许还是被拒绝    | Allow                                                                 |
| Principal | 允许访问的账户或用户       | arn:aws:iam::782985192762:user/docs-s3-user                           |
| Action    | 存储桶上允许执行的操作      | s3:\*                                                                 |
| Resource  | 允许对存储桶中的哪些资源执行操作 | "arn:aws:s3:::ch-docs-s3-bucket", "arn:aws:s3:::ch-docs-s3-bucket/\*" |

<Note>
  您应与安全团队协作，确定要使用的权限；这些内容可作为起点。
  有关策略和设置的更多信息，请参阅 AWS 文档：
  [https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-policy-language-overview.html](https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-policy-language-overview.html)
</Note>

13. 保存策略配置
