huawei-cloud-obs-bucket-create
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseHuawei Cloud OBS Bucket Create Skill
华为云OBS存储桶创建Skill
Overview
概述
This skill is used for creating buckets on Huawei Cloud Object Storage Service (OBS). It provides a simple, interactive bucket creation process, including bucket name validation, region selection, access permission configuration, and other advanced options.
Applicable Scenarios:
- Creating new buckets on Huawei Cloud OBS
- Setting bucket access permissions and policies
- Configuring bucket region and storage class
- Validating bucket names against specifications
- Batch creation of multiple buckets
本Skill用于在华为云对象存储服务(OBS)上创建存储桶。它提供了简单的交互式存储桶创建流程,包括存储桶名称验证、区域选择、访问权限配置及其他高级选项。
适用场景:
- 在华为云OBS上创建新存储桶
- 设置存储桶访问权限与策略
- 配置存储桶区域与存储类别
- 根据规范验证存储桶名称
- 批量创建多个存储桶
Prerequisites
前提条件
1. Huawei Cloud CLI Tool Installed
1. 已安装华为云CLI工具
Required check: Huawei Cloud CLI (hcloud / KooCLI) >= 3.2.0
bash
undefined需检查:华为云CLI(hcloud / KooCLI)版本 >= 3.2.0
bash
undefinedCheck if installed
检查是否安装
hcloud version
If not installed, or version is lower than 3.2.0, refer to [cli-installation-guide.md](references/cli-installation-guide.md) for KooCLI installation.
KooCLI has built-in obsutil tool, if KooCLI version check passes, obsutil check can be skipped.hcloud version
如果未安装或版本低于3.2.0,请参考[cli-installation-guide.md](references/cli-installation-guide.md)进行KooCLI安装。KooCLI内置obsutil工具,若KooCLI版本检查通过,可跳过obsutil检查。2. Huawei Cloud Credentials Configured
2. 已配置华为云凭证
- Valid Huawei Cloud OBS credentials (AK/SK mode)
bash
undefined- 有效的华为云OBS凭证(AK/SK模式)
bash
undefinedView configuration
查看配置
hcloud obs ls -s
hcloud obs ls -s
Configuration file location ~/.obsutilconfig
配置文件位置 ~/.obsutilconfig
If Huawei Cloud credentials are not configured, prompt the user to execute the following command:
```bash
若未配置华为云凭证,请提示用户执行以下命令:
```bashConfigure Huawei Cloud credentials
配置华为云凭证
hcloud OBS config -i="<Your AK>" -k="<Your SK>" -e="obs.<Region>.myhuaweicloud.com"
>**Huawei Cloud OBS credentials do not inherit from Huawei Cloud credentials and need to be set separately.**
- **Security Rules**:
- 🚫 Do not directly enter AK/SK values in plain text.
- 🚫 Never expose AK/SK values, do not extract AK/SK from hcloud configuration files.
- ✅ Only use `hcloud configure list` to check credential status.hcloud OBS config -i="<Your AK>" -k="<Your SK>" -e="obs.<Region>.myhuaweicloud.com"
>**华为云OBS凭证不继承自华为云通用凭证,需单独设置。**
- **安全规则**:
- 🚫 请勿直接明文输入AK/SK值。
- 🚫 切勿暴露AK/SK值,不要从hcloud配置文件中提取AK/SK。
- ✅ 仅使用`hcloud configure list`查看凭证状态。Core Workflow
核心流程
Bucket name is a required condition for creating an OBS bucket. If the context does not specify a bucket name, prompt the user that a specific bucket name is needed, no other text prompts required.
bucket-name存储桶名称是创建OBS存储桶的必填条件。若上下文未指定存储桶名称,仅需提示用户需要具体的存储桶名称,无需其他文本提示。
bucket-nameStep 1: Validate Bucket Name
步骤1:验证存储桶名称
Bucket name rules are as follows:
- 3-63 characters, starting with a number or letter, supporting lowercase letters, numbers, "-", ".".
- IP address format is not allowed.
- Cannot start or end with "-" or ".".
- Two adjacent "." are not allowed (e.g., "my..bucket").
- Adjacent "." and "-" are not allowed (e.g., "my-.bucket" and "my.-bucket")."
If the bucket name does not comply with the specification. Remind the user to reset the bucket name.
存储桶名称规则如下:
- 长度为3-63字符,以数字或字母开头,支持小写字母、数字、"-"、"."。
- 不允许使用IP地址格式。
- 不能以"-"或"."开头或结尾。
- 不允许出现两个相邻的"."(例如:"my..bucket")。
- 不允许相邻的"."和"-"(例如:"my-.bucket"和"my.-bucket")。"
若存储桶名称不符合规范,请提醒用户重新设置。
Step 2: Select Region
步骤2:选择区域
Get the region for the OBS bucket to be created from the context. If no region is specified, use the "endpoint" parameter in the ~/.obsutilconfig file as the region by default.
Return prompt text:
Once a bucket is created successfully, the region cannot be changed, please choose carefully. The region you want to create the bucket in is ${region}
从上下文中获取要创建的OBS存储桶所在区域。若未指定区域,默认使用~/.obsutilconfig文件中的"endpoint"参数对应的区域。
返回提示文本:
存储桶创建成功后,区域无法更改,请谨慎选择。你要创建存储桶的区域为${region}
Step 3: Create Bucket
步骤3:创建存储桶
bash
undefinedbash
undefinedCreate with recommended configuration
使用推荐配置创建
hcloud OBS mb obs://bucket-name [-acl=xxx] [-location=xxx] [-fs] [-az=xxx] [-sc=xxx]
```bashhcloud OBS mb obs://bucket-name [-acl=xxx] [-location=xxx] [-fs] [-az=xxx] [-sc=xxx]
```bashBatch create multiple buckets. Script exit code 6 from Huawei Cloud CLI is normal behavior, not an execution error
批量创建多个存储桶。华为云CLI返回的脚本退出码6为正常行为,不属于执行错误
./scripts/batch_create_buckets.sh <bucket-name-prefix> <regions>
undefined./scripts/batch_create_buckets.sh <bucket-name-prefix> <regions>
undefinedStep 4: Validate Success (Optional)
步骤4:验证创建成功(可选)
bash
undefinedbash
undefinedList all buckets to confirm creation success
列出所有存储桶以确认创建成功
hcloud OBS ls
hcloud OBS ls
Check bucket properties
查看存储桶属性
hcloud OBS stat obs://bucket-name
If the bucket list contains the bucket name created this time and the bucket information is output normally, prompt that the creation is successful and list the basic information of the bucket.hcloud OBS stat obs://bucket-name
若存储桶列表中包含本次创建的存储桶名称,且能正常输出存储桶信息,则提示创建成功并列出存储桶的基本信息。Core Commands
核心命令
Create Storage Bucket
创建存储桶
bash
hcloud OBS mb obs://bucket-name [-acl=xxx] [-location=xxx] [-fs] [-az=xxx] [-sc=xxx]| Option | Description | Possible Values |
|---|---|---|
| Access Control List | private, public-read, public-read-write |
| Region | cn-north-4, cn-east-2, etc. |
| Availability Zone | multi-az |
| Default Storage Class | standard, warm, cold, deep-archive |
bash
hcloud OBS mb obs://bucket-name [-acl=xxx] [-location=xxx] [-fs] [-az=xxx] [-sc=xxx]| 参数 | 描述 | 可选值 |
|---|---|---|
| 访问控制列表 | private, public-read, public-read-write |
| 区域 | cn-north-4, cn-east-2等 |
| 可用区 | multi-az |
| 默认存储类别 | standard, warm, cold, deep-archive |
List Storage Buckets
列出存储桶
bash
hcloud OBS lsbash
hcloud OBS lsView Storage Bucket Properties
查看存储桶属性
bash
hcloud OBS stat obs://${bucket-name}bash
hcloud OBS stat obs://${bucket-name}Parameter Confirmation
参数确认
Required Parameters
必填参数
- bucket-name: Storage bucket name, must comply with OBS naming convention (3-63 characters, lowercase letters, numbers, hyphens, dots, not starting or ending with hyphen or dot)
- bucket-name: 存储桶名称,必须符合OBS命名规范(3-63字符,小写字母、数字、连字符、点号,不能以连字符或点号开头/结尾)
Optional Parameters
可选参数
- region: Region code, such as cn-north-4 (North China-Beijing 4), cn-east-2 (East China-Shanghai 2)
- acl: Access permission, default private
- storage-class: Storage class, default standard
- az: Availability zone, default single availability zone, can be set to multi-az (multi-availability zone)
- region: 区域编码,例如cn-north-4(华北-北京四)、cn-east-2(华东-上海二)
- acl: 访问权限,默认private
- storage-class: 存储类别,默认standard
- az: 可用区,默认单可用区,可设置为multi-az(多可用区)
Best Practices
最佳实践
- Naming Convention: Use meaningful bucket names, such as
project-name-environment-purpose-20250527 - Region Selection: Choose the region closest to users to reduce latency, Beijing 4 (cn-north-4) is a commonly used region
- Access Control: Use private ACL by default, only open public-read when needed
- Storage Class: Choose based on access frequency:
- Standard storage (standard): Frequently accessed data
- Infrequent access storage (warm): Infrequently accessed data
- Archive storage (cold): Rarely accessed data
- Deep archive storage (deep-archive): Very rarely accessed data
- Batch Creation: Use script to batch create multiple buckets
batch_create_buckets.sh - Version Control: Consider enabling bucket version control to prevent accidental deletion
- 命名规范: 使用有意义的存储桶名称,例如
project-name-environment-purpose-20250527 - 区域选择: 选择离用户最近的区域以降低延迟,北京四(cn-north-4)是常用区域
- 访问控制: 默认使用private ACL,仅在需要时开放public-read
- 存储类别: 根据访问频率选择:
- 标准存储(standard):频繁访问的数据
- 低频访问存储(warm):不频繁访问的数据
- 归档存储(cold):极少访问的数据
- 深度归档存储(deep-archive):几乎不访问的数据
- 批量创建: 使用脚本批量创建多个存储桶
batch_create_buckets.sh - 版本控制: 考虑启用存储桶版本控制以防止误删除
Notes
注意事项
- Bucket Name Uniqueness: Bucket name is globally unique in Huawei Cloud OBS, cannot be duplicated with other users
- Region Immutability: Cannot change the bucket region after creation
- Cost: Storage buckets are free, but storing data, requests, and traffic will incur costs
- Security: Do not hard-code AK/SK in scripts, use environment variables or configuration files
- Permissions: Ensure the user executing the command has sufficient OBS permissions
- Network: Ensure network can access Huawei Cloud OBS service endpoints
- Quota: Check account's OBS bucket quantity quota
- Deletion Protection: Important buckets can enable deletion protection to prevent accidental deletion
- 存储桶名称唯一性: 华为云OBS的存储桶名称全局唯一,不能与其他用户的重复
- 区域不可变更: 存储桶创建后无法更改区域
- 成本: 存储桶本身免费,但存储数据、请求及流量会产生费用
- 安全性: 请勿在脚本中硬编码AK/SK,使用环境变量或配置文件
- 权限: 确保执行命令的用户拥有足够的OBS权限
- 网络: 确保网络可访问华为云OBS服务端点
- 配额: 检查账号的OBS存储桶数量配额
- 删除保护: 重要存储桶可启用删除保护以防止误删除
Reference Documentation
参考文档
| Document | Description |
|---|---|
| KooCLI Installation Guide | KooCLI installation guide |
| Common Errors and Solutions | Error troubleshooting |
| 文档 | 描述 |
|---|---|
| KooCLI安装指南 | KooCLI安装说明 |
| 常见错误与解决方案 | 问题排查指南 |