> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-mintlify-3a82795f.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}) => {
  return <Frame>
      <img src={img} alt={alt} />
    </Frame>;
};

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

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

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

1. 登录 AWS IAM Management Console。

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

<Image size="lg" img="https://mintcdn.com/private-7c7dfe99-mintlify-3a82795f/aRvsybqUpVR5ZXyi/images/_snippets/s3/2025/s3-1.png?fit=max&auto=format&n=aRvsybqUpVR5ZXyi&q=85&s=8e1fc26dbb4dab887a7fce6bf32aa1c8" alt="AWS IAM Management Console - 添加新用户" width="4040" height="1940" data-path="images/_snippets/s3/2025/s3-1.png" />

3. 输入用户名

<Image size="lg" img="https://mintcdn.com/private-7c7dfe99-mintlify-3a82795f/aRvsybqUpVR5ZXyi/images/_snippets/s3/2025/s3-2.png?fit=max&auto=format&n=aRvsybqUpVR5ZXyi&q=85&s=b94e71736dbd437cd3be4cc377b805a0" alt="AWS IAM Management Console - 添加新用户" width="4040" height="1408" data-path="images/_snippets/s3/2025/s3-2.png" />

4. 选择 `Next`

<Image size="lg" img="https://mintcdn.com/private-7c7dfe99-mintlify-3a82795f/aRvsybqUpVR5ZXyi/images/_snippets/s3/2025/s3-3.png?fit=max&auto=format&n=aRvsybqUpVR5ZXyi&q=85&s=271d5cb6b2674368406b415e5936cdb5" alt="AWS IAM Management Console - 添加新用户" width="4040" height="1860" data-path="images/_snippets/s3/2025/s3-3.png" />

5. 选择 `Next`

<Image size="lg" img="https://mintcdn.com/private-7c7dfe99-mintlify-3a82795f/aRvsybqUpVR5ZXyi/images/_snippets/s3/2025/s3-4.png?fit=max&auto=format&n=aRvsybqUpVR5ZXyi&q=85&s=78f7e7d9676a3973d11580ccbeab4974" alt="AWS IAM Management Console - 添加新用户" width="4040" height="1850" data-path="images/_snippets/s3/2025/s3-4.png" />

6. 选择 `Create user`

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

<Image size="lg" img="https://mintcdn.com/private-7c7dfe99-mintlify-3a82795f/aRvsybqUpVR5ZXyi/images/_snippets/s3/2025/s3-5.png?fit=max&auto=format&n=aRvsybqUpVR5ZXyi&q=85&s=90b1b7102b468021f6703a6c24cd5ca2" alt="AWS IAM Management Console - 添加新用户" width="4040" height="792" data-path="images/_snippets/s3/2025/s3-5.png" />

7. 选择 `Create access key`

<Image size="lg" img="https://mintcdn.com/private-7c7dfe99-mintlify-3a82795f/aRvsybqUpVR5ZXyi/images/_snippets/s3/2025/s3-6.png?fit=max&auto=format&n=aRvsybqUpVR5ZXyi&q=85&s=c712c6d0dc6e815e63bcc535dbd89fd0" alt="AWS IAM Management Console - 添加新用户" width="4040" height="1900" data-path="images/_snippets/s3/2025/s3-6.png" />

8. 选择 `Application running outside AWS`

<Image size="lg" img="https://mintcdn.com/private-7c7dfe99-mintlify-3a82795f/aRvsybqUpVR5ZXyi/images/_snippets/s3/2025/s3-7.png?fit=max&auto=format&n=aRvsybqUpVR5ZXyi&q=85&s=5e187a64490aee58eb968752bdaee182" alt="AWS IAM Management Console - 添加新用户" width="4040" height="1942" data-path="images/_snippets/s3/2025/s3-7.png" />

9. 选择 `Create access key`

<Image size="lg" img="https://mintcdn.com/private-7c7dfe99-mintlify-3a82795f/aRvsybqUpVR5ZXyi/images/_snippets/s3/2025/s3-8.png?fit=max&auto=format&n=aRvsybqUpVR5ZXyi&q=85&s=130c79d48a3f60719361bd63053da19b" alt="AWS IAM Management Console - 添加新用户" width="4040" height="1080" data-path="images/_snippets/s3/2025/s3-8.png" />

10. 将访问密钥和 secret 下载为 .csv 文件，供稍后使用

<Image size="lg" img="https://mintcdn.com/private-7c7dfe99-mintlify-3a82795f/aRvsybqUpVR5ZXyi/images/_snippets/s3/2025/s3-9.png?fit=max&auto=format&n=aRvsybqUpVR5ZXyi&q=85&s=d125ef53e3046c53c4a4ff2540e04486" alt="AWS IAM Management Console - 添加新用户" width="3912" height="2036" data-path="images/_snippets/s3/2025/s3-9.png" />

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

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

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

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

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

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

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

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

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

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

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

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

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

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

7. 选择 `Create folder`

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

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

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

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

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

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

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

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

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. 保存策略配置
