Install
openclaw skills install @huaweicloudskill/huawei-cloud-iac-reverseReverse-engineer existing Huawei Cloud resources into deployable Terraform IaC code. Queries all resources via RMS (Config/配置审计) API, analyzes specs and topology service-by-service, then synthesizes Terraform HCL configurations with provider validation. Use when the user wants to generate IaC from existing cloud resources, migrate infrastructure to code, or reverse-engineer cloud topology. Triggers include: "逆向生成IaC", "反向生成Terraform", "从现有资源生成代码", "reverse engineer IaC", "generate Terraform from existing resources", "infrastructure to code", "cloud to IaC".
openclaw skills install @huaweicloudskill/huawei-cloud-iac-reverseGiven a Huawei Cloud account with existing resources, this skill:
terraform fmt → validate → planhcloud CLI (KooCLI) installed and configured with AK/SKreferences/cli-installation-guide.md)HUAWEI_ACCESS_KEY, HUAWEI_SECRET_KEY (unset HUAWEI_SECURITY_TOKEN if switching accounts)# Set credentials (never write AK/SK into .tf files)
export HUAWEI_ACCESS_KEY="your-ak"
export HUAWEI_SECRET_KEY="your-sk"
# CRITICAL: unset stale security token when switching accounts
unset HUAWEI_SECURITY_TOKEN
Use RMS ListAllResources to get ALL resources across ALL services in one call:
# List all resources in a region
hcloud Config ListAllResources --cli-region={region} --limit=200
Known limitations:
Analyze resources in dependency order:
| Phase | Layer | Resources | Key Data to Extract |
|---|---|---|---|
| 1 | Network | VPC, subnets, SGs, EIPs | CIDR, AZ, rules, bandwidth |
| 2 | Storage | OBS, EVS, SFS Turbo | bucket names, share_type, size |
| 3 | Compute | ECS instances | flavor, image_id, AZ, disk, EIP, SG |
| 4 | CCE | Clusters, nodes | cluster version, network type, node flavor |
| 5 | Database | GaussDB | engine, version, flavor, HA mode, volume |
| 6-7 | Cache/MQ | DCS, DMS | spec_code, broker_num, storage |
| 8 | Auxiliary | KMS, keypairs, HSS, LTS | key alias, topic names |
| 9 | Topology | Cross-references | VPC→subnet→ECS, SG→rules, CCE→nodes |
Generate .tf files in dependency order:
project/
├── providers.tf # provider config (version, region, no AK/SK)
├── variables.tf # variables (image IDs, keypair name, passwords)
├── terraform.tfvars # region assignment
├── .tfrc # Huawei Cloud provider mirror
├── main.tf # Layer 0-1: VPC, subnets, SG, EIP
├── storage.tf # Layer 2: OBS, SFS Turbo
├── compute.tf # Layer 3a: ECS
├── cce.tf # Layer 3b-4: CCE cluster + node pool
├── database.tf # Layer 3c: GaussDB, DCS, DMS
├── security.tf # Layer 0 aux: KMS
├── lts.tf # LTS log groups
└── README.md # documentation
Key rules:
.tf files — use env vars or provider profilecharging_mode = "prePaid" / "postPaid" (string, not numeric)volumetype (not volume_type)datastore.version uses MySQL-compatible version (e.g., "8.0"), not internal versionterraform fmt -recursive
terraform validate
terraform plan
Fix provider schema mismatches iteratively. Common issues:
billing_mode (deprecated) → charging_modevolume_type → volumetype (CCE node pool)spec_code → flavor (DCS)subnet_id → network_id (DMS)available_zones (deprecated) → availability_zonesscale_enable → scall_enable (CCE node pool, provider typo)eni_subnet_ids → eni_subnet_id (CCE cluster)Compare generated resources against original inventory:
| Category | Check |
|---|---|
| Fully covered | Each original resource has a TF equivalent |
| Correctly excluded | Auto-created sub-resources (CCE nodes, DB nodes) not in TF |
| Gaps | Missing resources, incomplete properties, provider limitations |
Common gaps to check:
security_group_id, port, dataVolumeSizeInGBsshare_type mapping (e.g., HPC_STANDARD_20M → HPC + hpc_bandwidth)| Command | Purpose |
|---|---|
hcloud Config ListAllResources --cli-region={region} --limit=200 | Discover all resources via RMS |
hcloud GaussDB ShowGaussMySqlEngineVersion --database_name=gaussdb-mysql --cli-region={region} | Query GaussDB engine versions |
hcloud SFSTurbo ListShares --cli-region={region} | Query SFS Turbo shares |
hcloud CCE ListClusters --cli-region={region} | Query CCE clusters |
bash scripts/query_all_resources.sh {region} | Query all resources in a region |
bash scripts/validate_terraform.sh {project_dir} | Validate Terraform configuration |
bash scripts/compare_resources.sh {plan_file} {rms_json_file} | Compare plan vs inventory |
| Parameter | Required | Description |
|---|---|---|
--cli-region | Yes (auto) | Region, agent fills automatically |
--limit | No | Number of records to return, default 200 |
| Parameter | Required | Description |
|---|---|---|
--database_name | Yes | Database name, e.g. gaussdb-mysql |
--cli-region | Yes (auto) | Region, agent fills automatically |
| Parameter | Required | Description |
|---|---|---|
--cli-region | Yes (auto) | Region, agent fills automatically |
| Parameter | Required | Description |
|---|---|---|
--cli-region | Yes (auto) | Region, agent fills automatically |
| Script | Required Args |
|---|---|
scripts/query_all_resources.sh | {region} (positional) |
scripts/validate_terraform.sh | {project_dir} (positional, default .) |
scripts/compare_resources.sh | {plan_file} {rms_json_file} (positional) |
Format template: hcloud <service> <Operation> --cli-region={region} [--key={value} ...] (template only — replace the placeholders with real values; not an executable command)
| Feature | Description | Example |
|---|---|---|
| Service name | hcloud service as detected in metadata | Config, GaussDB, SFSTurbo, CCE |
| Operation name | PascalCase | ListAllResources, ListShares, ListClusters |
| Region parameter | --cli-region={region} | --cli-region=cn-north-4 |
| Simple parameter | --key={value} | --database_name=gaussdb-mysql |
When unsure about argument names, query the provider schema:
terraform providers schema -json | python3 -c "
import json, sys
data = json.load(sys.stdin)
for name, schema in data.get('provider_schemas', {}).items():
resources = schema.get('resource_schemas', {})
for rname in ['TARGET_RESOURCE']:
if rname in resources:
attrs = resources[rname].get('block', {}).get('attributes', {})
for an, av in attrs.items():
req = av.get('required', False)
print(f' [{"REQ" if req else "opt"}] {an}')
"
When RMS doesn't return enough detail, use hcloud CLI:
# Query GaussDB engine versions
hcloud GaussDB ShowGaussMySqlEngineVersion --database_name=gaussdb-mysql --cli-region={region}
# Query SFS Turbo shares
hcloud SFSTurbo ListShares --cli-region={region}
# Query CCE clusters
hcloud CCE ListClusters --cli-region={region}
terraform apply without user confirmation — this skill only generates and validates code.sensitive = true and default values marked as placeholders..tf files when a property cannot be set via Terraform.For a 144-resource environment, the skill generates ~57 Terraform resources:
references/iam-policies.md — Least-privilege IAM policiesreferences/cli-installation-guide.md — KooCLI installation and credential configurationreferences/verification-method.md — Verification method detailsreferences/acceptance-criteria.md — Acceptance criteriareferences/dataflow-diagram.md — Data flow diagram