huawei-cloud-obs-bucket-create

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Huawei 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
undefined

Check 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
undefined

View 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

若未配置华为云凭证,请提示用户执行以下命令:

```bash

Configure 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
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存储桶的必填条件。若上下文未指定存储桶名称,仅需提示用户需要具体的存储桶名称,无需其他文本提示。

Step 1: Validate Bucket Name

步骤1:验证存储桶名称

Bucket name rules are as follows:
  1. 3-63 characters, starting with a number or letter, supporting lowercase letters, numbers, "-", ".".
  2. IP address format is not allowed.
  3. Cannot start or end with "-" or ".".
  4. Two adjacent "." are not allowed (e.g., "my..bucket").
  5. 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.
存储桶名称规则如下:
  1. 长度为3-63字符,以数字或字母开头,支持小写字母、数字、"-"、"."。
  2. 不允许使用IP地址格式。
  3. 不能以"-"或"."开头或结尾。
  4. 不允许出现两个相邻的"."(例如:"my..bucket")。
  5. 不允许相邻的"."和"-"(例如:"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
undefined
bash
undefined

Create with recommended configuration

使用推荐配置创建

hcloud OBS mb obs://bucket-name [-acl=xxx] [-location=xxx] [-fs] [-az=xxx] [-sc=xxx]

```bash
hcloud OBS mb obs://bucket-name [-acl=xxx] [-location=xxx] [-fs] [-az=xxx] [-sc=xxx]

```bash

Batch 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>
undefined

Step 4: Validate Success (Optional)

步骤4:验证创建成功(可选)

bash
undefined
bash
undefined

List 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]
OptionDescriptionPossible Values
-acl=xxx
Access Control Listprivate, public-read, public-read-write
-location=xxx
Regioncn-north-4, cn-east-2, etc.
-az=xxx
Availability Zonemulti-az
-sc=xxx
Default Storage Classstandard, warm, cold, deep-archive
bash
hcloud OBS mb obs://bucket-name [-acl=xxx] [-location=xxx] [-fs] [-az=xxx] [-sc=xxx]
参数描述可选值
-acl=xxx
访问控制列表private, public-read, public-read-write
-location=xxx
区域cn-north-4, cn-east-2等
-az=xxx
可用区multi-az
-sc=xxx
默认存储类别standard, warm, cold, deep-archive

List Storage Buckets

列出存储桶

bash
hcloud OBS ls
bash
hcloud OBS ls

View 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

最佳实践

  1. Naming Convention: Use meaningful bucket names, such as
    project-name-environment-purpose-20250527
  2. Region Selection: Choose the region closest to users to reduce latency, Beijing 4 (cn-north-4) is a commonly used region
  3. Access Control: Use private ACL by default, only open public-read when needed
  4. 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
  5. Batch Creation: Use
    batch_create_buckets.sh
    script to batch create multiple buckets
  6. Version Control: Consider enabling bucket version control to prevent accidental deletion
  1. 命名规范: 使用有意义的存储桶名称,例如
    project-name-environment-purpose-20250527
  2. 区域选择: 选择离用户最近的区域以降低延迟,北京四(cn-north-4)是常用区域
  3. 访问控制: 默认使用private ACL,仅在需要时开放public-read
  4. 存储类别: 根据访问频率选择:
    • 标准存储(standard):频繁访问的数据
    • 低频访问存储(warm):不频繁访问的数据
    • 归档存储(cold):极少访问的数据
    • 深度归档存储(deep-archive):几乎不访问的数据
  5. 批量创建: 使用
    batch_create_buckets.sh
    脚本批量创建多个存储桶
  6. 版本控制: 考虑启用存储桶版本控制以防止误删除

Notes

注意事项

  1. Bucket Name Uniqueness: Bucket name is globally unique in Huawei Cloud OBS, cannot be duplicated with other users
  2. Region Immutability: Cannot change the bucket region after creation
  3. Cost: Storage buckets are free, but storing data, requests, and traffic will incur costs
  4. Security: Do not hard-code AK/SK in scripts, use environment variables or configuration files
  5. Permissions: Ensure the user executing the command has sufficient OBS permissions
  6. Network: Ensure network can access Huawei Cloud OBS service endpoints
  7. Quota: Check account's OBS bucket quantity quota
  8. Deletion Protection: Important buckets can enable deletion protection to prevent accidental deletion
  1. 存储桶名称唯一性: 华为云OBS的存储桶名称全局唯一,不能与其他用户的重复
  2. 区域不可变更: 存储桶创建后无法更改区域
  3. 成本: 存储桶本身免费,但存储数据、请求及流量会产生费用
  4. 安全性: 请勿在脚本中硬编码AK/SK,使用环境变量或配置文件
  5. 权限: 确保执行命令的用户拥有足够的OBS权限
  6. 网络: 确保网络可访问华为云OBS服务端点
  7. 配额: 检查账号的OBS存储桶数量配额
  8. 删除保护: 重要存储桶可启用删除保护以防止误删除

Reference Documentation

参考文档

DocumentDescription
KooCLI Installation GuideKooCLI installation guide
Common Errors and SolutionsError troubleshooting
文档描述
KooCLI安装指南KooCLI安装说明
常见错误与解决方案问题排查指南