huaweicloud-devkit 0.1.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/.agents/plugins/marketplace.json +20 -0
  2. package/LICENSE +201 -0
  3. package/README.md +148 -0
  4. package/bin/setup.cjs +8 -0
  5. package/integrations/opencode/commands/huaweicloud-doctor.md +14 -0
  6. package/integrations/opencode/opencode.json +14 -0
  7. package/integrations/opencode/skills/huaweicloud-core/SKILL.md +30 -0
  8. package/package.json +43 -0
  9. package/plugins/huaweicloud-core/.claude-plugin/plugin.json +44 -0
  10. package/plugins/huaweicloud-core/.codex-plugin/plugin.json +43 -0
  11. package/plugins/huaweicloud-core/.cursor-plugin/plugin.json +44 -0
  12. package/plugins/huaweicloud-core/.mcp.json +13 -0
  13. package/plugins/huaweicloud-core/hooks/hooks.json +26 -0
  14. package/plugins/huaweicloud-core/hooks/huaweicloud-safety.py +88 -0
  15. package/plugins/huaweicloud-core/safety/policy.json +86 -0
  16. package/plugins/huaweicloud-core/skills/huawei-apig/SKILL.md +144 -0
  17. package/plugins/huaweicloud-core/skills/huawei-billing/SKILL.md +48 -0
  18. package/plugins/huaweicloud-core/skills/huawei-cbr/SKILL.md +50 -0
  19. package/plugins/huaweicloud-core/skills/huawei-cce/SKILL.md +101 -0
  20. package/plugins/huaweicloud-core/skills/huawei-cloud-eye/SKILL.md +73 -0
  21. package/plugins/huaweicloud-core/skills/huawei-cloud-find-skills/SKILL.md +190 -0
  22. package/plugins/huaweicloud-core/skills/huawei-cloud-find-skills/scripts/search-skills.mjs +124 -0
  23. package/plugins/huaweicloud-core/skills/huawei-cts/SKILL.md +55 -0
  24. package/plugins/huaweicloud-core/skills/huawei-dds-dcs/SKILL.md +70 -0
  25. package/plugins/huaweicloud-core/skills/huawei-deployment/SKILL.md +56 -0
  26. package/plugins/huaweicloud-core/skills/huawei-dew/SKILL.md +97 -0
  27. package/plugins/huaweicloud-core/skills/huawei-dew/references/csms-usage.md +29 -0
  28. package/plugins/huaweicloud-core/skills/huawei-dew/references/kms-usage.md +23 -0
  29. package/plugins/huaweicloud-core/skills/huawei-ecs/SKILL.md +131 -0
  30. package/plugins/huaweicloud-core/skills/huawei-ecs/references/create-instance.md +92 -0
  31. package/plugins/huaweicloud-core/skills/huawei-ecs/references/evs.md +31 -0
  32. package/plugins/huaweicloud-core/skills/huawei-ecs/references/flavors.md +28 -0
  33. package/plugins/huaweicloud-core/skills/huawei-ecs/references/troubleshooting.md +52 -0
  34. package/plugins/huaweicloud-core/skills/huawei-functiongraph/SKILL.md +132 -0
  35. package/plugins/huaweicloud-core/skills/huawei-functiongraph/references/apig-event-format.md +58 -0
  36. package/plugins/huaweicloud-core/skills/huawei-functiongraph/references/create-function.md +71 -0
  37. package/plugins/huaweicloud-core/skills/huawei-functiongraph/references/deploy-workflow.md +119 -0
  38. package/plugins/huaweicloud-core/skills/huawei-functiongraph/references/triggers.md +142 -0
  39. package/plugins/huaweicloud-core/skills/huawei-gaussdb/SKILL.md +56 -0
  40. package/plugins/huaweicloud-core/skills/huawei-getting-started/SKILL.md +65 -0
  41. package/plugins/huaweicloud-core/skills/huawei-iam/SKILL.md +111 -0
  42. package/plugins/huaweicloud-core/skills/huawei-iam/references/policy-examples.md +122 -0
  43. package/plugins/huaweicloud-core/skills/huawei-iam/references/quick-ref.md +56 -0
  44. package/plugins/huaweicloud-core/skills/huawei-modelarts/SKILL.md +65 -0
  45. package/plugins/huaweicloud-core/skills/huawei-obs/SKILL.md +118 -0
  46. package/plugins/huaweicloud-core/skills/huawei-obs/references/bucket-create.md +49 -0
  47. package/plugins/huaweicloud-core/skills/huawei-obs/references/bucket-lifecycle.md +26 -0
  48. package/plugins/huaweicloud-core/skills/huawei-obs/references/common-pitfalls.md +100 -0
  49. package/plugins/huaweicloud-core/skills/huawei-obs/references/static-website.md +56 -0
  50. package/plugins/huaweicloud-core/skills/huawei-rds/SKILL.md +181 -0
  51. package/plugins/huaweicloud-core/skills/huawei-smn-dms/SKILL.md +69 -0
  52. package/plugins/huaweicloud-core/skills/huawei-vpc/SKILL.md +77 -0
  53. package/plugins/huaweicloud-core/skills/huawei-vpc/references/network.md +52 -0
  54. package/plugins/huaweicloud-core/skills/huawei-vpc/references/security-group.md +59 -0
  55. package/plugins/huaweicloud-core/skills/huawei-vpc/references/subnet.md +50 -0
  56. package/plugins/huaweicloud-core/skills/huawei-waf-aad/SKILL.md +63 -0
  57. package/plugins/huaweicloud-core/skills/huaweicloud-api-and-sdk/SKILL.md +56 -0
  58. package/plugins/huaweicloud-core/skills/huaweicloud-api-and-sdk/agents/openai.yaml +4 -0
  59. package/plugins/huaweicloud-core/skills/huaweicloud-capability-discovery/SKILL.md +47 -0
  60. package/plugins/huaweicloud-core/skills/huaweicloud-capability-discovery/agents/openai.yaml +4 -0
  61. package/plugins/huaweicloud-core/skills/huaweicloud-cli-and-auth/SKILL.md +125 -0
  62. package/plugins/huaweicloud-core/skills/huaweicloud-cli-and-auth/agents/openai.yaml +4 -0
  63. package/plugins/huaweicloud-core/skills/huaweicloud-core/SKILL.md +94 -0
  64. package/plugins/huaweicloud-core/skills/huaweicloud-core/agents/openai.yaml +4 -0
  65. package/plugins/huaweicloud-core/skills/huaweicloud-core/references/report-issue.md +20 -0
  66. package/plugins/huaweicloud-core/skills/huaweicloud-core/references/select.md +28 -0
  67. package/plugins/huaweicloud-core/skills/huaweicloud-safety/SKILL.md +46 -0
  68. package/plugins/huaweicloud-core/skills/huaweicloud-safety/agents/openai.yaml +4 -0
  69. package/plugins/huaweicloud-core/skills/huaweicloud-troubleshooting/SKILL.md +83 -0
  70. package/plugins/huaweicloud-core/skills/huaweicloud-troubleshooting/agents/openai.yaml +4 -0
  71. package/plugins/huaweicloud-core/src/hcloud-cli.mjs +265 -0
  72. package/plugins/huaweicloud-core/src/mcp-server.mjs +93 -0
  73. package/plugins/huaweicloud-core/src/safety-policy.mjs +289 -0
  74. package/plugins/huaweicloud-core/src/search-market.mjs +169 -0
  75. package/plugins/huaweicloud-core/src/setup-cli.mjs +628 -0
  76. package/plugins/huaweicloud-core/src/tools.mjs +672 -0
@@ -0,0 +1,119 @@
1
+ # End-to-End Deployment Workflow
2
+
3
+ ```
4
+ 1. Write code → Create index.py with handler function
5
+ 2. Package → zip -j function.zip index.py (no directory nesting!)
6
+ 3. Create function → hcloud FunctionGraph CreateFunction (inline for small demos, zip for production)
7
+ 4. Verify → hcloud FunctionGraph InvokeFunction
8
+ 5. Create trigger → hcloud FunctionGraph CreateFunctionTrigger (TIMER for testing, DEDICATEDGATEWAY for HTTP)
9
+ ```
10
+
11
+ ## Quick Demo (Inline — No File Packaging)
12
+
13
+ Use inline for small demo functions (<10KB):
14
+
15
+ ```bash
16
+ # 1. Prepare base64-encoded code
17
+ python3 -c "
18
+ import base64
19
+ code = '''import json
20
+ def handler(event, context):
21
+ return {'statusCode': 200, 'body': json.dumps({'message': 'Hello FunctionGraph!'}), 'headers': {'Content-Type': 'application/json'}}
22
+ '''
23
+ print(base64.b64encode(code.encode()).decode())
24
+ "
25
+
26
+ # 2. Create function with inline code (paste base64 output as --func_code.file)
27
+ hcloud FunctionGraph CreateFunction --help
28
+ hcloud FunctionGraph CreateFunction \
29
+ --func_name=my-backend \
30
+ --runtime=Python3.10 \
31
+ --handler=index.handler \
32
+ --memory_size=256 \
33
+ --package=default \
34
+ --timeout=30 \
35
+ --code_type=inline \
36
+ --func_code.file=<base64-from-step-1> \
37
+ --cli-region=<region> \
38
+ --project_id=<project-id>
39
+
40
+ # 3. Verify
41
+ hcloud FunctionGraph InvokeFunction \
42
+ --function_urn=<urn> \
43
+ --name=test-event \
44
+ --x_cff_request_version=v0
45
+ ```
46
+
47
+ ## Production Deployment (Zip)
48
+
49
+ ```bash
50
+ # 1. Write code
51
+ cat > index.py << 'EOF'
52
+ import json
53
+
54
+ def handler(event, context):
55
+ return {
56
+ "statusCode": 200,
57
+ "body": json.dumps({"message": "Hello from FunctionGraph!"}),
58
+ "headers": {"Content-Type": "application/json"}
59
+ }
60
+ EOF
61
+
62
+ # 2. Package — CRITICAL: use -j to flatten, no directory nesting
63
+ zip -j function.zip index.py
64
+
65
+ # 3. Create function (discover params with --help first!)
66
+ hcloud FunctionGraph CreateFunction --help
67
+ # Required: --func_name, --runtime, --handler, --memory_size, --package, --timeout
68
+ # Code type: use --code_type=zip --code_filename=function.zip
69
+ # IMPORTANT: cd to function.zip directory first! --code_filename is filename only.
70
+
71
+ # 4. Verify (store URN from step 3 output)
72
+ hcloud FunctionGraph InvokeFunction --help
73
+ # Requires body param: --name=test-event (becomes event body passed to handler)
74
+ hcloud FunctionGraph InvokeFunction \
75
+ --function_urn=<urn> \
76
+ --name=test-event \
77
+ --x_cff_request_version=v0
78
+
79
+ # 5. Create trigger (see references/triggers.md)
80
+ # For quick testing: TIMER trigger (no prerequisites)
81
+ # For HTTP access: DEDICATEDGATEWAY (requires APIG instance — see pre-flight checklist below)
82
+
83
+ # 5a. TIMER (simple — no APIG dependency)
84
+ hcloud FunctionGraph CreateFunctionTrigger \
85
+ --function_urn=<urn> \
86
+ --trigger_type_code=TIMER \
87
+ --event_type_code=MessageCreated \
88
+ --trigger_status=ACTIVE \
89
+ --event_data.name=test-timer \
90
+ --event_data.schedule_type=Rate \
91
+ --event_data.schedule="5m"
92
+ ```
93
+
94
+ ## DEDICATEDGATEWAY Pre-Flight Checklist
95
+
96
+ Before creating a DEDICATEDGATEWAY (HTTP) trigger, verify these prerequisites exist:
97
+
98
+ ```bash
99
+ # 1. Check for APIG dedicated instance
100
+ hcloud APIG ListInstancesV2 --cli-region=<r>
101
+
102
+ # 2. If no instance exists, create one (see huawei-apig skill)
103
+ # Key: --spec_id=PROFESSIONAL --loadbalancer_provider=elb for public access
104
+ # Requires: VPC, subnet, security group, enterprise_project_id
105
+
106
+ # 3. Once instance is Running with public IP, create API group
107
+ hcloud APIG CreateApiGroupV2 --instance_id=<id> --name=<group-name>
108
+
109
+ # 4. Create DEDICATEDGATEWAY trigger (see references/triggers.md)
110
+
111
+ # 5. Publish the API (after trigger creation)
112
+ hcloud APIG BatchPublishOrOfflineApiV2 \
113
+ --instance_id=<apig-instance-id> \
114
+ --action=online \
115
+ --env_id=<env-id> \
116
+ --api_ids=<api-id-from-trigger-response>
117
+ ```
118
+
119
+ If no APIG instance is available, use TIMER trigger for function testing instead.
@@ -0,0 +1,142 @@
1
+ # Triggers
2
+
3
+ **Always run `hcloud FunctionGraph CreateFunctionTrigger --help` first** for exact parameter names and requirements.
4
+
5
+ ## KooCLI event_data Format (CRITICAL)
6
+
7
+ KooCLI uses **dotted key-value format**, NOT JSON strings:
8
+
9
+ ```bash
10
+ # CORRECT
11
+ --event_data.name=my-api --event_data.auth=IAM --event_data.path=/test
12
+
13
+ # WRONG — will fail
14
+ --event_data='{"name":"my-api","auth":"IAM","path":"/test"}'
15
+ ```
16
+
17
+ ## Trigger Types
18
+
19
+ | Type | `--trigger_type_code` | Notes |
20
+ |------|----------------------|-------|
21
+ | APIG Dedicated | `DEDICATEDGATEWAY` | Use this, not `APIG` (deprecated). Requires APIG instance. |
22
+ | Timer / Cron | `TIMER` | Simplest trigger for testing. No APIG dependency. |
23
+ | OBS | `OBS` | Event when objects created/deleted in bucket |
24
+ | SMN | `SMN` | Message notification trigger |
25
+
26
+ ## TIMER Trigger (Simple Testing)
27
+
28
+ The TIMER trigger is the easiest path for verifying a function works — no APIG instance needed:
29
+
30
+ ```bash
31
+ hcloud FunctionGraph CreateFunctionTrigger \
32
+ --function_urn=<urn> \
33
+ --trigger_type_code=TIMER \
34
+ --event_type_code=MessageCreated \
35
+ --trigger_status=ACTIVE \
36
+ --event_data.name=<trigger-name> \
37
+ --event_data.schedule_type=Rate \
38
+ --event_data.schedule="1m"
39
+ ```
40
+
41
+ ## DEDICATEDGATEWAY Trigger (HTTP Access)
42
+
43
+ `trigger_type_code=APIG` is **deprecated**. Use `DEDICATEDGATEWAY` for KooCLI 7.x.
44
+
45
+ ### Required Parameters (Hidden Optional)
46
+
47
+ These are labeled optional by `--help` but are **required** for DEDICATEDGATEWAY:
48
+
49
+ | Param | Note |
50
+ |-------|------|
51
+ | `--event_data.protocol` | `HTTPS` or `HTTP` or `BOTH` |
52
+ | `--event_data.sl_domain` | Subdomain from APIG instance (e.g. `xxxx.apic.<region>.huaweicloudapis.com`) |
53
+ | `--event_data.env_name` | API environment name (`RELEASE`) |
54
+ | `--event_data.env_id` | API environment ID |
55
+ | `--event_data.instance_id` | APIG dedicated instance ID |
56
+ | `--event_data.group_id` | API group ID |
57
+ | `--event_data.name` | API name — **hyphens (`-`) are DISALLOWED**. Use underscores (`_`) instead. |
58
+
59
+ ### Error Mapping
60
+
61
+ | Error | Root Cause → Fix |
62
+ |-------|-----------------|
63
+ | FSS.1417 | Missing `instance_id`, `group_id`, `protocol`, `env_name`, or `env_id`. These are labeled optional but REQUIRED. |
64
+ | API name regex fail | Rename API — remove hyphens (`-`), use `[a-zA-Z0-9_]+` only. |
65
+
66
+ ### Example
67
+
68
+ ```bash
69
+ hcloud FunctionGraph CreateFunctionTrigger \
70
+ --function_urn=<urn> \
71
+ --trigger_type_code=DEDICATEDGATEWAY \
72
+ --event_type_code=APICreated \
73
+ --trigger_status=ACTIVE \
74
+ --event_data.name=<api-name-no-hyphens> \
75
+ --event_data.auth=IAM \
76
+ --event_data.path=/my-backend \
77
+ --event_data.match_mode=SWA \
78
+ --event_data.type=1 \
79
+ --event_data.protocol=HTTPS \
80
+ --event_data.req_method=ANY \
81
+ --event_data.func_info.timeout=5000 \
82
+ --event_data.instance_id=<apig-instance-id> \
83
+ --event_data.group_id=<api-group-id> \
84
+ --event_data.sl_domain=<sl-domain> \
85
+ --event_data.env_name=RELEASE \
86
+ --event_data.env_id=<env-id>
87
+ ```
88
+
89
+ After trigger creation, you must **publish** the API before it's accessible:
90
+
91
+ ```bash
92
+ hcloud APIG BatchPublishOrOfflineApiV2 \
93
+ --instance_id=<apig-instance-id> \
94
+ --action=online \
95
+ --env_id=<env-id> \
96
+ --api_ids=<api-id-from-trigger-response>
97
+ ```
98
+
99
+ ### Alternative: --cli-jsonInput (Recommended for Complex Configs)
100
+
101
+ For trigger configs with many nested fields, use `--cli-jsonInput` to avoid shell escaping issues:
102
+
103
+ ```bash
104
+ cat > trigger.json << 'EOF'
105
+ {
106
+ "trigger_type_code": "DEDICATEDGATEWAY",
107
+ "trigger_status": "ACTIVE",
108
+ "event_type_code": "APICreated",
109
+ "event_data": {
110
+ "name": "my-api",
111
+ "auth": "IAM",
112
+ "path": "/my-backend",
113
+ "match_mode": "SWA",
114
+ "type": 1,
115
+ "protocol": "HTTPS",
116
+ "req_method": "ANY",
117
+ "func_info": { "timeout": 5000 },
118
+ "instance_id": "<apig-instance-id>",
119
+ "group_id": "<api-group-id>",
120
+ "sl_domain": "<sl-domain>",
121
+ "env_name": "RELEASE",
122
+ "env_id": "<env-id>"
123
+ }
124
+ }
125
+ EOF
126
+ hcloud FunctionGraph CreateFunctionTrigger \
127
+ --function_urn=<urn> \
128
+ --cli-region=<region> \
129
+ --project_id=<project_id> \
130
+ --cli-jsonInput=trigger.json
131
+ ```
132
+
133
+ ## List / Delete Triggers
134
+
135
+ ```bash
136
+ hcloud FunctionGraph ListFunctionTriggers --function_urn=<urn>
137
+ hcloud FunctionGraph DeleteFunctionTrigger --function_urn=<urn> --trigger_type_code=<type> --trigger_id=<id>
138
+ ```
139
+
140
+ > Deleting a trigger does NOT cascade-delete the associated APIG API. After `DeleteFunctionTrigger`, also run `hcloud APIG ListApisV2 --instance_id=<id>` and delete orphaned APIs to avoid resource residue.
141
+
142
+ > **APIG event format**: When using DEDICATEDGATEWAY, the event body is Base64 encoded and uses a non-standard structure. See `apig-event-format.md` for handler templates.
@@ -0,0 +1,56 @@
1
+ ---
2
+ name: huawei-gaussdb
3
+ description: "Use when creating or managing GaussDB distributed database on Huawei Cloud. Covers GaussDB(for MySQL), GaussDB(for openGauss), sharding, HTAP. Triggers: GaussDB, distributed database, sharding, openGauss, HTAP. NOT for: single RDS (use huawei-rds)."
4
+ version: 1
5
+ ---
6
+
7
+ # Huawei Cloud GaussDB
8
+
9
+ **STOP - Do not answer from general knowledge.** Follow the procedure below.
10
+
11
+ Always run `hcloud GaussDB <Operation> --help` before constructing commands to discover exact parameter names and requirements.
12
+
13
+ ## Overview
14
+
15
+ Domain expertise for GaussDB. Covers instance lifecycle, databases, backups, configurations, and shard/readonly node management.
16
+
17
+ ## Critical Warnings
18
+
19
+ | Trap | Why |
20
+ |------|-----|
21
+ | Shard key permanent | Once set, shard key cannot be changed |
22
+ | Minimum nodes | Distributed GaussDB requires at least 3 nodes for production |
23
+ | Engine version pinned | MySQL-compatible vs openGauss are separate products |
24
+
25
+ ## Common Workflows
26
+
27
+ | Task | Operation |
28
+ |------|-----------|
29
+ | List instances | `ListInstances --cli-region=<r> --project_id=<p>` |
30
+ | Show instance | `ShowInstance --cli-region=<r> --project_id=<p>` |
31
+ | List flavors | `ListFlavors --cli-region=<r> --project_id=<p>` |
32
+ | Create instance | `CreateInstance --cli-region=<r> --project_id=<p>` |
33
+ | Delete instance | `DeleteInstance --cli-region=<r> --project_id=<p>` |
34
+ | Create backup | `CreateGaussMySqlBackup --cli-region=<r> --project_id=<p>` |
35
+ | Add readonly node | `AddReadonlyNode --cli-region=<r> --project_id=<p>` |
36
+ | Add shard | `AddShardingNode --cli-region=<r> --project_id=<p>` |
37
+ | Manage database | `AddDatabasePermission --cli-region=<r> --project_id=<p>` |
38
+
39
+ Discover exact parameters with `--help` before executing any command.
40
+
41
+ ## Troubleshooting
42
+
43
+ | Error | Fix |
44
+ |-------|-----|
45
+ | Instance creation fails | Check VPC/subnet availability and flavor capacity |
46
+ | Connection refused | SG missing database port |
47
+
48
+ ## Security
49
+
50
+ - MUST use security groups for database access
51
+ - MUST enable SSL for connections
52
+
53
+ ## Cross-Skill References
54
+
55
+ - **VPC/Subnet/Security Group**: See `huawei-vpc`
56
+ - **Backup/CBR**: See `huawei-cbr`
@@ -0,0 +1,65 @@
1
+ ---
2
+ name: huawei-getting-started
3
+ description: "Use when starting fresh with Huawei Cloud or KooCLI, installing prerequisites, setting up authentication, or exploring what is possible. Triggers: getting started, first time, setup, install, explore, quickstart, beginner, tutorial. NOT for: specific service operations (use huawei-ecs, huawei-obs, etc.)."
4
+ version: 1
5
+ ---
6
+
7
+ # Huawei Cloud Getting Started
8
+
9
+ **STOP - Do not answer from general knowledge.** Follow the procedure below.
10
+
11
+ ## KooCLI Installation
12
+
13
+ | OS | Command |
14
+ |----|---------|
15
+ | Windows (PowerShell) | See https://support.huaweicloud.com/qs-hcli/hcli_02_003.html for MSI download |
16
+ | Linux | curl -LO "https://hwcloudcli.obs.cn-north-1.myhuaweicloud.com/cli/latest/hcloud_install.sh" && bash hcloud_install.sh |
17
+ | macOS | curl -LO "https://hwcloudcli.obs.cn-north-1.myhuaweicloud.com/cli/latest/hcloud_install.sh" && bash hcloud_install.sh |
18
+
19
+ ## First-Time Setup
20
+ 1. **Install KooCLI** using command above
21
+ 2. **Accept privacy policy** (first run only): KooCLI requires one-time privacy agreement. Run `hcloud version` and respond `y` to the prompt. For non-interactive terminals, use `echo "y" | hcloud version`
22
+ 3. **Configure credentials**: `hcloud configure init` (interactive, prompts for AK/SK/region safely)
23
+ 4. **Verify**: `hcloud configure list` to confirm profile, then `hcloud ECS ListServersDetails --cli-region=cn-north-4`
24
+ 5. For detailed auth guidance, see `huaweicloud-cli-and-auth` skill
25
+
26
+ > **Security**: Never pass AK/SK as command-line arguments (`--ak=...`). Always use `hcloud configure init` (interactive) or `hcloud configure set` with cached profile to avoid secrets in shell history.
27
+
28
+ ### Non-Interactive Setup (Agent/CI Environments)
29
+
30
+ When the interactive TUI is unavailable (Agent tools, CI/CD), use `hcloud configure set` — this must be run outside agent chat by the user:
31
+
32
+ ```bash
33
+ # User executes in their terminal (NOT in agent chat):
34
+ hcloud configure set --cli-access-key=<AK> --cli-secret-key=<SK> --cli-region=<region>
35
+
36
+ # Agent verifies:
37
+ hcloud configure list
38
+ ```
39
+
40
+ ## Critical Warnings
41
+ | Trap | Why |
42
+ |------|-----|
43
+ | AK/SK must be kept secret | Never commit to git or share |
44
+ | Default region applies to all commands | Override with --cli-region= per command |
45
+ | Some services region-specific | Not all services available in all regions |
46
+ | Privacy policy blocks first run | KooCLI requires one-time `y` confirmation. Non-interactive terminals need `echo "y" \| hcloud <cmd>` |
47
+
48
+ ## What Can I Do? (Quick Index)
49
+ | Goal | Skill |
50
+ |------|-------|
51
+ | Create a VM | huawei-ecs |
52
+ | Store files | huawei-obs |
53
+ | Set up a database | huawei-rds / huawei-gaussdb |
54
+ | Create a network | huawei-vpc |
55
+ | Manage access | huawei-iam |
56
+ | Deploy an app | huawei-deployment |
57
+ | Run containers | huawei-cce |
58
+ | Build an API | huawei-apig |
59
+ | Run serverless | huawei-functiongraph |
60
+ | Monitor resources | huawei-cloud-eye |
61
+
62
+ ## Pro Tips
63
+ - Use `hcloud <Service> --help` to discover operations (see huaweicloud-capability-discovery)
64
+ - Prepend `hcloud configure set --cli-region=<r>` to avoid per-command region flags
65
+ - Pipe sensitive output through IAM with `--cli-output-format=json`
@@ -0,0 +1,111 @@
1
+ ---
2
+ name: huawei-iam
3
+ description: "Use when managing IAM users, groups, roles, policies, agencies, projects, or access keys on Huawei Cloud. Covers IAM policy structure, least-privilege design, temporary credentials (STS), OneAccess integration, and security best practices. Triggers on: IAM, permission, policy, role, user, group, AK/SK, access key, agency, project, authorization. NOT for: DEW secret management (use huawei-dew)."
4
+ version: 1
5
+ ---
6
+
7
+ # Huawei Cloud IAM
8
+
9
+ **STOP - Do not answer from general knowledge.** Follow the procedure below.
10
+
11
+ Always run `hcloud <Service> <Operation> --help` before constructing commands to discover exact parameter names and requirements.
12
+
13
+ ## Overview
14
+
15
+ Domain expertise for Huawei Cloud Identity and Access Management (IAM). Covers user/group/role lifecycle, policy design, temporary credentials, and security best practices.
16
+
17
+ ## Critical Warnings
18
+
19
+ | Trap | Why |
20
+ |------|-----|
21
+ | NEVER create IAM users for humans | Use OneAccess (IAM Identity Center) or federated SSO |
22
+ | NEVER create long-term AK/SK | Use temporary STS tokens via agencies |
23
+ | Wildcard policies dangerous | Effect:Allow + Resource:* = full access. Always scope resources |
24
+ | Agency trust is powerful | Agencies let services assume roles. Always add conditions |
25
+ | Root account must have MFA | Root AK/SK is all-powerful. Enable MFA immediately |
26
+
27
+ ## Policy Structure
28
+
29
+ `json
30
+ {
31
+ "Version": "1.1",
32
+ "Statement": [{
33
+ "Effect": "Allow",
34
+ "Action": ["ecs:*"],
35
+ "Resource": ["*"],
36
+ "Condition": {
37
+ "StringEquals": {"g:SourceVpc": "vpc-xxx"}
38
+ }
39
+ }]
40
+ }
41
+ `
42
+
43
+ ## Common Workflows
44
+
45
+ | Task | Command | Steps |
46
+ |------|---------|-------|
47
+ | List users | hcloud IAM ListUsers | references/iam-ops.md |
48
+ | Create group | hcloud IAM CreateGroup --group.name=<name> | references/iam-ops.md |
49
+ | Create custom policy | hcloud IAM CreateCustomPolicy --policy.name=<n> --policy.document=<json> | references/policy-examples.md |
50
+ | Create agency | hcloud IAM CreateAgency --agency.name=<n> --agency.domain_id=<id> --agency.trust_policy=<json> | references/agency.md |
51
+ | Get temporary credential | hcloud STS GetTemporaryCredential --agency_name=<n> --domain_id=<id> --duration_seconds=3600 | references/sts.md |
52
+ | Attach policy | hcloud IAM AttachGroupPolicy --group_id=<id> --policy_id=<id> | references/iam-ops.md |
53
+
54
+ ## Policy Examples (Least Privilege)
55
+
56
+ | Role | Actions | Resource |
57
+ |------|---------|----------|
58
+ | ECS Reader | ecs:List*, ecs:Get*, ecs:Describe* | * |
59
+ | OBS Bucket Operator | obs:Get*, obs:Put*, obs:Delete*, obs:List* | obs:*:*:bucket:my-bucket |
60
+ | RDS Backup Operator | rds:CreateBackup, rds:RestoreFromBackup, rds:ListBackup | rds:* |
61
+
62
+ > See `references/policy-examples.md` for complete policy JSON templates with conditions.
63
+
64
+ ## Troubleshooting
65
+
66
+ | Error | Root Cause -> Fix |
67
+ |-------|------------------|
68
+ | AccessDenied | Missing IAM permission -> Check policy action and resource scope |
69
+ | AuthFailure | Expired AK/SK or wrong project -> Renew credentials / Check project ID |
70
+ | Agency trust failed | Missing trust policy condition -> Add g:SourceAccount condition |
71
+ | Quota exceeded | IAM user/group/policy limit -> Request quota increase |
72
+
73
+ ## Security Considerations
74
+
75
+ - MUST NOT create IAM users. Use OneAccess or federated SSO
76
+ - MUST NOT create long-term AK/SK. Use STS temporary tokens
77
+ - MUST scope Resource ARNs. Never use wildcard *
78
+ - MUST add conditions to trust policies (g:SourceAccount, g:SourceUrn)
79
+ - SHOULD rotate credentials every 90 days
80
+
81
+ ## Agencies (Cross-Service Delegation)
82
+
83
+ Agencies allow one service to act on behalf of another. Common use cases:
84
+
85
+ ### FunctionGraph Agency (VPC Access)
86
+
87
+ FunctionGraph needs an agency to access VPC resources (RDS, DCS, etc.):
88
+
89
+ ```bash
90
+ # 1. Create agency with FunctionGraph trust
91
+ hcloud IAM CreateAgency --agency_name=<name> --trust_domain_name=functiongraph
92
+
93
+ # 2. Attach VPC Administrator role
94
+ hcloud IAM GrantRoleToAgency --agency_name=<name> --role_id=<role-id>
95
+
96
+ # 3. Use in CreateFunction
97
+ hcloud FunctionGraph CreateFunction ... --app_xrole=<agency-name>
98
+ ```
99
+
100
+ Common roles for FunctionGraph: VPC Administrator, RDS Administrator, DCS Administrator.
101
+
102
+ ## MCP Tools
103
+
104
+ - huaweicloud_list_operations service=IAM
105
+ - huaweicloud_run_readonly_command for user/policy discovery
106
+
107
+ ## References
108
+
109
+ - IAM Docs: https://support.huaweicloud.com/iam/
110
+ - Policy examples: references/policy-examples.md
111
+ - Agency setup: references/agency.md
@@ -0,0 +1,122 @@
1
+ # IAM Policy Examples
2
+
3
+ ## Huawei Cloud IAM Policy Format
4
+
5
+ Huawei Cloud IAM uses a different action naming convention from AWS. Actions use lowercase service prefixes:
6
+
7
+ ```
8
+ <service>:<resource>:<action>
9
+ ```
10
+
11
+ Examples:
12
+ - `ecs:servers:list` (NOT `ecs:ListInstances`)
13
+ - `obs:bucket:GetBucket` (NOT `s3:GetBucket`)
14
+ - `vpc:vpcs:list` (NOT `vpc:DescribeVpcs`)
15
+
16
+ Always verify exact action names via `https://support.huaweicloud.com/usermanual-iam/iam_01_0001.html` or KooCLI `--help`.
17
+
18
+ ## Read-Only Policies
19
+
20
+ ### ECS Read-Only
21
+ ```json
22
+ {
23
+ "Version": "1.1",
24
+ "Statement": [{
25
+ "Effect": "Allow",
26
+ "Action": ["ecs:servers:list", "ecs:servers:get", "ecs:*:list", "ecs:*:get"],
27
+ "Resource": ["*"]
28
+ }]
29
+ }
30
+ ```
31
+
32
+ ### OBS Read-Only (scoped bucket)
33
+ ```json
34
+ {
35
+ "Version": "1.1",
36
+ "Statement": [{
37
+ "Effect": "Allow",
38
+ "Action": ["obs:bucket:Get*", "obs:bucket:List*", "obs:object:Get*"],
39
+ "Resource": ["obs:*:*:bucket:my-bucket", "obs:*:*:bucket:my-bucket/*"]
40
+ }]
41
+ }
42
+ ```
43
+
44
+ ### FunctionGraph Read-Only
45
+ ```json
46
+ {
47
+ "Version": "1.1",
48
+ "Statement": [{
49
+ "Effect": "Allow",
50
+ "Action": ["functiongraph:function:getConfig", "functiongraph:function:list", "functiongraph:function:invoke", "functiongraph:trigger:list"],
51
+ "Resource": ["*"]
52
+ }]
53
+ }
54
+ ```
55
+
56
+ ## Full-Access (Scoped)
57
+
58
+ ### RDS Operator
59
+ ```json
60
+ {
61
+ "Version": "1.1",
62
+ "Statement": [{
63
+ "Effect": "Allow",
64
+ "Action": ["rds:*"],
65
+ "Resource": ["*"],
66
+ "Condition": {"StringEquals": {"g:ResourceTag/Environment": ["dev", "staging"]}}
67
+ }]
68
+ }
69
+ ```
70
+
71
+ ### FunctionGraph Developer
72
+ ```json
73
+ {
74
+ "Version": "1.1",
75
+ "Statement": [{
76
+ "Effect": "Allow",
77
+ "Action": ["functiongraph:function:*", "functiongraph:trigger:*", "functiongraph:runtime:list"],
78
+ "Resource": ["*"]
79
+ }]
80
+ }
81
+ ```
82
+
83
+ ### APIG Operator
84
+ ```json
85
+ {
86
+ "Version": "1.1",
87
+ "Statement": [{
88
+ "Effect": "Allow",
89
+ "Action": ["apig:instance:*", "apig:api:*", "apig:group:*", "apig:environment:*"],
90
+ "Resource": ["*"]
91
+ }]
92
+ }
93
+ ```
94
+
95
+ ## Best Practices
96
+
97
+ 1. **Least privilege**: Start with empty policy, add only needed actions
98
+ 2. **No `*` wildcard on Resource**: Scope to specific resources or use tag conditions
99
+ 3. **Use Condition keys**: `g:RequestedRegion`, `g:ResourceTag`, `g:CurrentTime` for context-aware policies
100
+ 4. **Separate policies per role**: Don't combine read and write in one policy
101
+
102
+ ## Confused Deputy Protection
103
+
104
+ ```json
105
+ {
106
+ "Version": "1.1",
107
+ "Statement": [{
108
+ "Effect": "Allow",
109
+ "Action": ["ecs:*"],
110
+ "Resource": ["*"],
111
+ "Condition": {
112
+ "StringEquals": {"g:SourceAccount": "0123456789"},
113
+ "StringLike": {"g:SourceUrn": "urn:fss:*"}
114
+ }
115
+ }]
116
+ }
117
+ ```
118
+
119
+ ## References
120
+
121
+ - IAM Action Reference: https://support.huaweicloud.com/usermanual-iam/iam_01_0001.html
122
+ - Policy Syntax: https://support.huaweicloud.com/usermanual-iam/iam_01_0602.html
@@ -0,0 +1,56 @@
1
+ # IAM Quick Reference
2
+
3
+ ## Common Operations
4
+
5
+ ```bash
6
+ hcloud IAM KeystoneListProjects # list projects
7
+ hcloud IAM KeystoneListUsers # list users
8
+ hcloud IAM KeystoneListGroups # list groups
9
+ hcloud IAM ListCustomPolicies # list custom policies
10
+ hcloud IAM ListAgencies # list agencies
11
+ hcloud IAM KeystoneListAuthDomains # list domains
12
+ hcloud IAM KeystoneShowUser # show user detail
13
+ ```
14
+
15
+ ## Credential Management
16
+
17
+ ```bash
18
+ hcloud IAM KeystoneListAccessKeys --user_id=<id> # list AK/SK for user
19
+ hcloud IAM CreateLoginToken # create login token
20
+ hcloud IAM GetAccountSummary # account summary
21
+ ```
22
+
23
+ ## Security Best Practices
24
+
25
+ 1. **NEVER create IAM users** — use IAM Identity Center or temporary STS tokens
26
+ 2. **NEVER create long-term AK/SK** — use temporary credentials
27
+ 3. **Least privilege by default** — start empty, add only needed actions
28
+ 4. **Scope resources** — no `*` wildcards on Resource
29
+ 5. **Use condition keys** — `g:RequestedRegion`, `g:ResourceTag`, `g:CurrentTime`
30
+ 6. **Rotate AK/SK every 90 days** — or use agency delegation
31
+
32
+ ## IAM vs AWS Comparison
33
+
34
+ | AWS | Huawei Cloud |
35
+ |-----|-------------|
36
+ | `iam:ListUsers` | `iam:users:list` (lowercase + colon) |
37
+ | AWS Managed Policy | System Policy (系统策略) |
38
+ | Customer Managed | Custom Policy (自定义策略) |
39
+ | Resource-Based Policy | Project-Level Policy (项目级策略) |
40
+ | IAM Role | Agency (委托) |
41
+
42
+ > Huawei Cloud IAM action naming: `<service>:<resource>:<action>`. Always verify at https://support.huaweicloud.com/usermanual-iam/iam_01_0001.html
43
+
44
+ ## Confused Deputy Protection
45
+
46
+ ```json
47
+ {
48
+ "Effect": "Allow",
49
+ "Action": ["ecs:*"],
50
+ "Resource": ["*"],
51
+ "Condition": {
52
+ "StringEquals": {"g:SourceAccount": "<account-id>"},
53
+ "StringLike": {"g:SourceUrn": "urn:fss:*"}
54
+ }
55
+ }
56
+ ```