
Huawei Cloud Obs Bucket Create
- 94 installs
- 19 repo stars
- Updated July 31, 2026
- huaweicloud/huaweicloud-skills
Create Huawei Cloud OBS buckets with name validation, region selection, access-permission config, and storage-class options.
About
Provides an interactive workflow to create Huawei Cloud OBS object-storage buckets, including name validation, region and storage-class selection, and access-permission configuration. A developer uses it to set up new OBS buckets, including batch creation.
- Bucket name validation and region/storage-class selection
- Access-permission config and batch bucket creation
Huawei Cloud Obs Bucket Create by the numbers
- 94 all-time installs (skills.sh)
- +14 installs in the week ending Aug 2, 2026 (Skillselion tracking)
- Ranked #572 of 1,042 Cloud & Infrastructure skills by installs in the Skillselion catalog
- Data as of Aug 2, 2026 (Skillselion catalog sync)
npx skills add https://github.com/huaweicloud/huaweicloud-skills --skill huawei-cloud-obs-bucket-createAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 94 |
|---|---|
| repo stars | ★ 19 |
| Last updated | July 31, 2026 |
| Repository | huaweicloud/huaweicloud-skills ↗ |
What it does
Create Huawei Cloud OBS buckets with name validation, region selection, access-permission config, and storage-class options.
Files
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
# Check if installed
hcloud versionIf not installed, or version is lower than 3.2.0, refer to 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)
# View configuration
hcloud OBS config
# Configuration file location ~/.obsutilconfigIf Huawei Cloud credentials are not configured, prompt the user to execute the following command:
# 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 listto 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
# Create with recommended configuration
hcloud OBS mb obs://bucket-name [-acl=xxx] [-location=xxx] [-fs] [-az=xxx] [-sc=xxx]# 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)
# List all buckets to confirm creation success
hcloud OBS ls
# Check bucket properties
hcloud OBS stat obs://bucket-nameIf 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
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
hcloud OBS lsView Storage Bucket Properties
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 | KooCLI installation guide |
| Common Errors and Solutions | Error troubleshooting |
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 2.Create IAM user and authorize 3.Get access key (AK/SK)
Step 2: Installation on Different Systems
Linux and MacOS System Installation
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.shThe 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:
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 -yWindows System Installation
1.Click here to download 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.
set path4.(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.
hcloud version
# Current KooCLI version: x.x.xThe system displays version information similar to the following, indicating successful installation:
hcloud version
# Current KooCLI version: x.x.xStep 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:
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:
hcloud configure show --cli-profile=defaultError Handling
Common Errors and Solutions
Error 1: Bucket Name Already Exists
Error: Bucket name does not comply with specification or already existsSolution:
- 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 permissionsSolution: 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 unavailableSolution:
- Check if region code is correct
- Confirm account has access permission in that region
- Try other regions
Error 4: Network Connection Issue
Error: Connection timeoutSolution: 1. Check network connection 2. Verify endpoint is correct 3. Check firewall settings
#!/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 "$@"