Huawei Cloud Config Helper
⚠️ Execution Method (Must Read): This skill executes queries via local Python scripts. Using hcloud, curl, or other CLI tools or direct API calls is prohibited.
- Query scripts are located under the skill directory
scripts/config/- All scripts are inside the skill package. You must use
skill action=execto execute them; do not run them directly in a shell- All paths are relative to the skill directory, which is the directory where this SKILL.md resides
Overview 概述
This skill is a standalone read-only query skill that uses local Python scripts to call the Huawei Cloud Python SDK to query the Config service, providing:
- 查询资源概览(各服务/类型/区域的资源数量统计)
- 查询资源 Schema(资源结构定义,含字段名、类型、描述)
- 按条件通过 SQL 查询资源(高级查询,仅支持
resources表) - 查询预置合规规则(Config 内置策略定义)
This skill does NOT handle the following:
- Creating, modifying, or deleting any resources or compliance rules
- Guessing or fabricating information that has not been queried
Before writing SQL or analyzing security posture, read the reference docs:
| File | Description |
|---|---|
references/knowledge.md |
资源类型映射表、Region 映射、各服务安全知识索引 |
references/sql-example.json |
SQL 查询示例集合,编写 SQL 前必读 |
references/service/config.md |
Config 核心概念 |
references/service/vpc.md |
VPC 安全知识 |
references/service/iam.md |
IAM 安全知识 |
references/service/obs.md |
OBS 安全知识 |
references/iam-policies.md |
最小权限 IAM 策略(Config ReadOnlyAccess) |
references/verification-method.md |
验证方法 |
references/acceptance-criteria.md |
验收标准 |
Prerequisites 前置条件
Environment Variables:
| Variable | Required | Description |
|---|---|---|
| HW_ACCESS_KEY | Yes* | Huawei Cloud AK (preferred; fallback: HUAWEICLOUD_AK; only requires Config ReadOnlyAccess permission) |
| HW_SECRET_KEY | Yes* | Huawei Cloud SK (preferred; fallback: HUAWEICLOUD_SK) |
| HW_SECURITY_TOKEN | No | Required when using temporary AK/SK |
| HW_IGNORE_SSL_VERIFICATION | No | Set to true to disable TLS certificate verification (only for intranet/proxy with self-signed certificates) |
| PROXY_URL | No | Proxy URL, e.g. http://user:pass@host:port (intranet access); falls back to HTTPS_PROXY/HTTP_PROXY |
* Either HW_ACCESS_KEY/HW_SECRET_KEY (preferred) or HUAWEICLOUD_AK/HUAWEICLOUD_SK (fallback) must be set. The scripts check HW_ACCESS_KEY/HW_SECRET_KEY first, then fall back to HUAWEICLOUD_AK/HUAWEICLOUD_SK.
Do not output the values of the above environment variables.
Dependencies: pip install -r requirements.txt(huaweicloudsdkcore、huaweicloudsdkconfig、urllib3)
See references/iam-policies.md for the least-privilege IAM policy.
Workflow 工作流
Prerequisite: Environment Setup 前置步骤
- Confirm
HW_ACCESS_KEY/HW_SECRET_KEY(or fallbackHUAWEICLOUD_AK/HUAWEICLOUD_SK) are set (without printing values) - Install dependencies:
pip install -r requirements.txt - Run the resource summary query first to confirm connectivity
Scenario 1: 查询资源概览 Resource Summary
- Read
references/knowledge.mdto map user intent to provider/region - Execute:
skill action=exec: skill://.venv/Scripts/python3.exe skill://scripts/config/query_Config_resource_summary.py [--provider=<provider>] [--region_id=<region_id>]--provider: 可选,只查询某云服务的资源概览(如obs、vpc),也支持provider.type形式(如obs.buckets)--region_id: 可选,只查询某区域(如cn-north-4北京四、cn-east-3上海一、global全局)
- Verify: output is a JSON array with
provider、type、region_id、cntfields
Scenario 2: 查询资源 Schema Resource Schema
- Identify the resource type in
provider.typeformat (e.g.obs.buckets,ecs.cloudservers,iam.users,vpc.securityGroups) - Execute:
skill action=exec: skill://.venv/Scripts/python3.exe skill://scripts/config/query_Config_resource_schema.py --resource_type=<provider.type> - Use the returned field names/types to prepare SQL in Scenario 3
Scenario 3: 按条件 SQL 查询资源 SQL Resource Query
- Query the resource Schema first (Scenario 2) to confirm available fields
- Read
references/sql-example.jsonfor query patterns - Execute:
skill action=exec: skill://.venv/Scripts/python3.exe skill://scripts/config/query_Config_resource_by_sql.py --sql="<SQL>"- SQL 只能查询
resources表;支持标准 SELECT/WHERE/GROUP BY/ORDER BY,数组函数(transform/filter/any_match/contains),日期函数(date_diff/date_parse) - SQL 语句用双引号包裹,内部字符串用单引号
- 示例:
--sql="select id, name, provider, type, properties from resources where region_id = 'cn-north-4'"
- SQL 只能查询
- If the result is empty, run Scenario 1 first to confirm the actual resource distribution
- Common top-level fields (
name,created,updated,tag,project_id) are collected by Config uniformly and do NOT appear inproperties/Schema — do not treat them as missing fields
Scenario 4: 查询预置合规规则 Built-in Compliance Rules
- Execute:
skill action=exec: skill://.venv/Scripts/python3.exe skill://scripts/config/query_Config_builtin_rule.py [--keyword=<keyword>] [--limit=<n>]--keyword: 过滤关键词,对规则名称、描述及 keywords 做忽略大小写的子串匹配(如obs、vpc)--limit: 限制返回数量,默认 20
- Map rules to security dimensions (加密静态数据、保护配置、强制执行最低权限、限制网络访问等,完整维度见
references/knowledge.md) - Analyze resource compliance by combining rule conditions with SQL queries from Scenario 3
Core Commands 核心命令
All commands are executed via skill action=exec with the skill venv Python:
# Windows
skill://.venv/Scripts/python3.exe skill://scripts/config/<script>.py [OPTIONS]
# Linux / macOS
skill://.venv/bin/python3 skill://scripts/config/<script>.py [OPTIONS]
| Script | Purpose | Key Options |
|---|---|---|
query_Config_resource_summary.py |
资源概览统计 | --provider, --region_id |
query_Config_resource_schema.py |
资源 Schema 查询 | --resource_type (required) |
query_Config_resource_by_sql.py |
SQL 高级查询 | --sql (required) |
query_Config_builtin_rule.py |
预置合规规则查询 | --keyword, --limit |
Output: JSON (UTF-8, ensure_ascii=False). Empty results print 没有找到数据 and exit with code 0; failures print the error and exit with code 1.
Parameter Confirmation 参数确认
| Parameter | Required | Description | Example |
|---|---|---|---|
--cli-region |
No | CLI/SDK 区域标识,SDK 默认 cn-north-4(Config 为全局服务,固定使用该 endpoint) |
cn-north-4 |
--provider |
No (Scenario 1) | 云服务标识,支持 provider.type 形式 |
obs, obs.buckets |
--region_id |
No (Scenario 1) | 资源所在区域,global 表示全局资源 |
cn-north-4, global |
--resource_type |
Yes (Scenario 2) | 资源类型标识,格式 provider.type,区分大小写 |
vpc.securityGroups |
--sql |
Yes (Scenario 3) | 高级查询 SQL,双引号包裹、内部单引号 | select id, name from resources where provider = 'ecs' |
--keyword |
No (Scenario 4) | 合规规则过滤关键词,忽略大小写的子串匹配(名称/描述/keywords) | obs |
--limit |
No (Scenario 4) | 返回数量限制,默认 20 | 10 |
Reference Documents 参考文档
- Knowledge Base — 资源类型映射表、Region 映射、各服务安全知识索引
- SQL Examples — SQL 查询示例集合
- Config Concepts — Config 核心概念
- VPC Security — VPC 安全知识
- IAM Security — IAM 安全知识
- OBS Security — OBS 安全知识
- IAM Policies — Least-privilege credential model
- Verification Method — Verification method details
- Acceptance Criteria — Acceptance criteria
Notes
- This skill only provides read-only query capabilities; it does not perform any write operations
- 严禁在日志、控制台输出 AK/SK 等敏感信息;AK 仅需
Config ReadOnlyAccess最小权限 - All scripts must be executed via
skill action=exec; do not run them directly in a shell - SQL 资源类型名称区分大小写(如
securityGroups),先查 Schema 确认 - 大结果集缓存到本地文件,避免重复请求
