Skills로 돌아가기
huaweicloud/huaweicloud-skills검사 통과

SKILL DETAIL

huawei-cloud-obs-bucket-create

huaweicloud/huaweicloud-skills/huawei-cloud-obs-bucket-create

This skill is specialized 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 include: creating new buckets on Huawei Cloud OBS, setting bucket access permissions and policies, configuring bucket region and storage class, validating bucket names against specifications, and batch creation of multiple buckets.

설치 수 · 236출처 보기

Installation

npx skills add https://github.com/huaweicloud/huaweicloud-skills --skill huawei-cloud-obs-bucket-create

스킬 파일

SKILL.md

최근 동기화 · 2026. 8. 29.

references/cli-installation-guide.md
# KooCLI Installation Guide

## Step 1: Preparation

Before using KooCLI, text prompt users about the preparation work needed:
1.[Register Huawei account and complete real-name authentication](https://support.huaweicloud.com/qs-hcli/hcli_02_002.html#hcli_02_002__section544111119366)
2.[Create IAM user and authorize](https://support.huaweicloud.com/qs-hcli/hcli_02_002.html#hcli_02_002__section10273653161410)
3.[Get access key (AK/SK)](https://support.huaweicloud.com/qs-hcli/hcli_02_002.html#hcli_02_002__section10548184715361)

## Step 2: Installation on Different Systems

### Linux and MacOS System Installation
```bash
curl -sSL https://cn-north-4-hdn-koocli.obs.cn-north-4.myhuaweicloud.com/cli/latest/hcloud_install.sh -o ./hcloud_install.sh && bash ./hcloud_install.sh
```
The above command downloads KooCLI to "/usr/local/hcloud/" directory by default and moves it to "/usr/local/bin/" directory for convenient use of hcloud command in any directory (before completing this step, please ensure PATH system variable contains "/usr/local/bin/" path).

You can modify the file download directory during command execution based on interactive information. If permission insufficient is prompted during execution, you can switch to root user and re-execute the installation command.

If you want to use default configuration and skip interactive mode, you can add "-y" at the end of the command, as follows:
```bash
curl -sSL https://cn-north-4-hdn-koocli.obs.cn-north-4.myhuaweicloud.com/cli/latest/hcloud_install.sh -o ./hcloud_install.sh && bash ./hcloud_install.sh -y
```

### Windows System Installation
1.[Click here to download](https://cn-north-4-hdn-koocli.obs.cn-north-4.myhuaweicloud.com/cli/latest/huaweicloud-cli-windows-amd64.zip) KooCLI adapted for Windows system.

2.Extract the downloaded zip package to get hcloud.exe

3.(Optional) Add the directory where KooCLI is located to the system environment variable Path for convenient use of hcloud command in any directory in cmd window.
Windows 10 and Windows 8 search and select "View advanced system settings", then click "Environment Variables";
Windows 7 right-click the "Computer" icon on the desktop, select "Properties" from the menu. Click the "Advanced system settings" link, then click "Environment Variables".

Enter the environment variables graphical interface, in the "User variables" list, select the environment variable named "Path" and click "Edit".
In the edit environment variable interface, click "New" and enter the path of the directory where hcloud.exe file is located.
Click "OK" three times to save this modification.
(Optional) Open cmd window, execute the following command to check if environment variable contains the directory where hcloud.exe file is located, if exists it means configuration is successful.
```bash
set path
```

4.(Optional) Open Windows system cmd window (if you did not execute step 3 above, you need to enter the directory where the tool is located), input and execute the following command to verify if KooCLI is installed successfully.
```bash
hcloud version
# Current KooCLI version: x.x.x
```

The system displays version information similar to the following, indicating successful installation:
```bash
hcloud version
# Current KooCLI version: x.x.x
```

### Step 3: Initialize Configuration
You can initialize configuration through the following command, after entering the command press Enter to enter interactive mode, input each parameter value according to interface prompts:
```bash
hcloud configure init
```
>hcloud configure init
Start initializing configuration, where "Secret Access Key" input is anonymized
Access Key ID [required]: ********
Secret Access Key [required]: ****
Secret Access Key (again): ****
Region: cn-north-4

>Note:
During initialization, the value of "Secret Access Key" needs to be confirmed twice. To ensure your account security, your input "Secret Access Key" has been anonymized. During your input process, the entered characters will not be displayed, when you finish input and press Enter to the next line, your input content will be echoed with "*". After configuration is complete, KooCLI will encrypt and save authentication-related sensitive information in the configuration items locally.
If you re-execute the initialization command, the original configuration file will be deleted and a new configuration file will be regenerated, configuration file save location is as follows:
Windows system: C:\Users\{Your Windows system username}\.hcloud\config.json
Linux system: /home/{current username}/.hcloud/config.json
Mac system: /Users/{current username}/.hcloud/config.json

After initialization is complete, you can query configuration information through the following command:
```bash
hcloud configure show --cli-profile=default
```
references/trouble-shooting.md
## Error Handling

### Common Errors and Solutions

#### Error 1: Bucket Name Already Exists
```
Error: Bucket name does not comply with specification or already exists
```
**Solution**:
- Choose a different bucket name
- Add a timestamp or random suffix
- Check if the same name is already used in other regions

#### Error 2: Insufficient Permissions
```
Error: Insufficient permissions
```
**Solution**:
1. Check if Access Key has OBS FullAccess permission
2. Check if Access Key has expired
3. Verify if credential configuration is correct

#### Error 3: Region Unavailable
```
Error: Specified region is unavailable
```
**Solution**:
- Check if region code is correct
- Confirm account has access permission in that region
- Try other regions

#### Error 4: Network Connection Issue
```
Error: Connection timeout
```
**Solution**:
1. Check network connection
2. Verify endpoint is correct
3. Check firewall settings
scripts/batch_create_buckets.sh
#!/bin/bash
# Huawei Cloud OBS Batch Bucket Creation Script
# Usage: ./batch_create_buckets.sh <prefix> <region> <purpose1> <purpose2> ...

set -e

# Color output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color

print_info() {
    echo -e "${BLUE}[INFO]${NC} $1"
}

print_success() {
    echo -e "${GREEN}[SUCCESS]${NC} $1"
}

print_warning() {
    echo -e "${YELLOW}[WARNING]${NC} $1"
}

print_error() {
    echo -e "${RED}[ERROR]${NC} $1"
}

# Check if hcloud command is available
check_hcloud() {
    if ! command -v hcloud &> /dev/null; then
        print_error "hcloud command not found, please install Huawei Cloud KooCLI first"
        echo "Installation Guide: https://support.huaweicloud.com/cli-koocli/koocli_01_0001.html"
        exit 1
    fi
    
    # Check OBS configuration
    if ! hcloud OBS ls &> /dev/null; then
        print_error "OBS configuration invalid or credentials error"
        echo "Please check the following configuration:"
        echo "1. Environment variables: OBS_ACCESS_KEY_ID, OBS_SECRET_ACCESS_KEY, OBS_ENDPOINT"
        echo "2. Configuration file: ~/.obsutilconfig"
        echo "3. Run: hcloud OBS config to check configuration"
        exit 1
    fi
    
    print_success "hcloud command and OBS configuration check passed"
}

# Validate bucket name
validate_bucket_name() {
    local bucket_name="$1"
    
    if [[ ${#bucket_name} -lt 3 || ${#bucket_name} -gt 63 ]]; then
        print_error "Bucket name length must be between 3-63 characters"
        return 1
    fi
    
    if [[ ! "$bucket_name" =~ ^[a-z0-9]([a-z0-9\-]*[a-z0-9])?$ ]]; then
        print_error "Bucket name can only contain lowercase letters, numbers and hyphens, and cannot start or end with a hyphen"
        return 1
    fi
    
    if [[ "$bucket_name" == *--* ]]; then
        print_error "Bucket name cannot contain two consecutive hyphens"
        return 1
    fi

    if [[ "$bucket_name" =~ ^[0-9]{1,3}(\.[0-9]{1,3}){3}$ ]]; then
        print_error "Bucket name cannot be in IP address format"
        return 1
    fi
    
    return 0
}


# Create single bucket
create_bucket() {
    local bucket_name="$1"
    local region="$2"
    local acl="${3:-private}"
    local storage_class="${4:-standard}"
    
    print_info "Creating bucket: $bucket_name"
    echo "  Region: $region"
    echo "  Access Permission: $acl"
    echo "  Storage Class: $storage_class"

    
    # Build command, use -e parameter to specify endpoint
    if hcloud OBS mb "obs://$bucket_name" -location="$region" -acl="$acl" -sc="$storage_class" ; then
        print_success "Bucket '$bucket_name' created successfully"
        
        # Display bucket information
        echo ""
        echo "Bucket Information:"
        hcloud OBS stat "obs://$bucket_name" | grep -E "(Bucket|Location|CreationDate|ACL)" || true
        echo ""
        
        return 0
    else
        # Check if it's a successful case but with non-zero exit code
        local exit_code=$?
        if [ $exit_code -eq 6 ]; then
            print_warning "Bucket '$bucket_name' created successfully, but command returned non-zero exit code (6), this is normal behavior for Huawei Cloud CLI"
            echo ""
            echo "Bucket Information:"
            hcloud OBS stat "obs://$bucket_name" | grep -E "(Bucket|Location|CreationDate|ACL)" || true
            echo ""
            return 0
        else
            print_error "Bucket '$bucket_name' creation failed, exit code: $exit_code"
            return 1
        fi
    fi
}

# Batch create buckets
batch_create() {
    local prefix="$1"
    local region="$2"
    shift 2
    local purposes=("$@")
    
    local timestamp=$(date +%Y%m%d)
    local success_count=0
    local total_count=${#purposes[@]}
    
    print_info "Starting batch bucket creation"
    echo "  Prefix: $prefix"
    echo "  Region: $region"
    echo "  Purposes: ${purposes[*]}"
    echo "  Timestamp: $timestamp"
    echo ""
    
    for purpose in "${purposes[@]}"; do
        local bucket_name="${prefix}-${purpose}-${timestamp}"
        
        # Validate bucket name
        if ! validate_bucket_name "$bucket_name"; then
            print_warning "Skipping invalid bucket name: $bucket_name"
            continue
        fi
        
        # Set ACL and storage class
        local acl="private"
        local storage_class="standard"
        
        case $purpose in
            logs|backup)
                acl="private"
                storage_class="ia"  # Infrequent access
                ;;
            website|assets)
                acl="public-read"
                storage_class="standard"
                ;;
            data|temp)
                acl="private"
                storage_class="standard"
                ;;
        esac
        
        # Create bucket
        if create_bucket "$bucket_name" "$region" "$acl" "$storage_class"; then
            ((success_count++))
        fi
        
        echo "----------------------------------------"
    done
    
    # Summary results
    echo ""
    echo "Batch creation completed!"
    echo "  Successful: $success_count/$total_count"
    echo "  Failed: $((total_count - success_count))"
    
    if [ $success_count -eq $total_count ]; then
        print_success "All buckets created successfully!"
    elif [ $success_count -gt 0 ]; then
        print_warning "Some buckets created successfully"
    else
        print_error "All bucket creations failed"
        exit 1
    fi
}


# Main program
main() {
    echo "Huawei Cloud OBS Batch Bucket Creation Tool"
    echo "========================================"
    
    # Check dependencies
    check_hcloud
    
    
    local prefix="$1"
    local region="$2"
    shift 2
    
    
    # Execute batch creation
    batch_create "$prefix" "$region" "$@"
    
}

# Run main program
main "$@"
SKILL.md
---
name: huawei-cloud-obs-bucket-create
description: |
  Skill specialized for creating buckets on Huawei Cloud OBS. Use this skill when users need to create OBS buckets, set bucket properties, configure access permissions, or need guidance on the bucket creation process. Trigger conditions: "创建OBS桶", "华为云存储桶", "存储空间创建", "create OBS bucket", "Huawei Cloud storage bucket", "OBS bucket", "Huawei Cloud bucket", "storage creation" or when setting up Huawei Cloud object storage.
tags: [huawei-cloud, obs, storage, bucket]
---

# Huawei Cloud OBS Bucket Create 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

## Prerequisites

### 1. Huawei Cloud CLI Tool Installed

Required check: Huawei Cloud CLI (hcloud / KooCLI) >= 3.2.0

  ```bash
# 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.

### 2. Huawei Cloud Credentials Configured

- Valid Huawei Cloud OBS credentials (AK/SK mode)

```bash
# View configuration
hcloud obs ls -s

# Configuration file location ~/.obsutilconfig
```

If Huawei Cloud credentials are not configured, prompt the user to execute the following command:

```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.

## 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.

### Step 1: Validate Bucket Name

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.

### Step 2: Select Region

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}

### Step 3: Create Bucket

```bash
# Create with recommended configuration
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
./scripts/batch_create_buckets.sh <bucket-name-prefix> <regions>
```

### Step 4: Validate Success (Optional)


```bash
# List all buckets to confirm creation success
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.


## 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 |
|--------|-------------|-----------------|
| `-acl=xxx` | Access Control List | private, public-read, public-read-write |
| `-location=xxx` | Region | cn-north-4, cn-east-2, etc. |
| `-az=xxx` | Availability Zone | multi-az |
| `-sc=xxx` | Default Storage Class | standard, warm, cold, deep-archive |

### List Storage Buckets

```bash
hcloud OBS ls
```

### View Storage Bucket Properties

```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)

### 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)


## 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

## 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

## Reference Documentation

| Document | Description |
|----------|-------------|
| [KooCLI Installation Guide](references/cli-installation-guide.md) | KooCLI installation guide |
| [Common Errors and Solutions](references/trouble-shooting.md) | Error troubleshooting |
huawei-cloud-obs-bucket-create · 인기 상승 중인 Agent Skills | Mengbi