huaweicloud-devkit 1.0.2-dev.9 → 1.0.2-next.0

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 (97) hide show
  1. package/.agents/plugins/marketplace.json +20 -20
  2. package/LICENSE +201 -201
  3. package/README.md +163 -138
  4. package/README.zh-CN.md +161 -138
  5. package/bin/setup.cjs +8 -8
  6. package/integrations/opencode/commands/huaweicloud-doctor.md +14 -14
  7. package/integrations/opencode/opencode.json +14 -14
  8. package/integrations/opencode/skills/huaweicloud-core/SKILL.md +32 -32
  9. package/package.json +46 -44
  10. package/plugins/huaweicloud-core/.claude-plugin/plugin.json +44 -44
  11. package/plugins/huaweicloud-core/.codex-plugin/plugin.json +43 -43
  12. package/plugins/huaweicloud-core/.cursor-plugin/plugin.json +44 -44
  13. package/plugins/huaweicloud-core/.mcp.json +15 -15
  14. package/plugins/huaweicloud-core/.workbuddy-plugin/plugin.json +44 -44
  15. package/plugins/huaweicloud-core/hooks/hooks.json +26 -26
  16. package/plugins/huaweicloud-core/hooks/huaweicloud-safety.py +136 -136
  17. package/plugins/huaweicloud-core/safety/policy.json +99 -99
  18. package/plugins/huaweicloud-core/safety/rules/cloud-risk-rules.json +199 -199
  19. package/plugins/huaweicloud-core/skills/huawei-apig/SKILL.md +164 -164
  20. package/plugins/huaweicloud-core/skills/huawei-billing/SKILL.md +48 -48
  21. package/plugins/huaweicloud-core/skills/huawei-cbr/SKILL.md +50 -50
  22. package/plugins/huaweicloud-core/skills/huawei-cce/SKILL.md +101 -101
  23. package/plugins/huaweicloud-core/skills/huawei-cloud-eye/SKILL.md +90 -90
  24. package/plugins/huaweicloud-core/skills/huawei-cloud-find-skills/SKILL.md +190 -190
  25. package/plugins/huaweicloud-core/skills/huawei-cloud-find-skills/scripts/search-skills.mjs +124 -124
  26. package/plugins/huaweicloud-core/skills/huawei-cts/SKILL.md +55 -55
  27. package/plugins/huaweicloud-core/skills/huawei-dds-dcs/SKILL.md +70 -70
  28. package/plugins/huaweicloud-core/skills/huawei-deployment/SKILL.md +56 -56
  29. package/plugins/huaweicloud-core/skills/huawei-dew/SKILL.md +97 -97
  30. package/plugins/huaweicloud-core/skills/huawei-dew/references/csms-usage.md +29 -29
  31. package/plugins/huaweicloud-core/skills/huawei-dew/references/kms-usage.md +23 -23
  32. package/plugins/huaweicloud-core/skills/huawei-ecs/SKILL.md +185 -185
  33. package/plugins/huaweicloud-core/skills/huawei-ecs/references/create-instance.md +133 -133
  34. package/plugins/huaweicloud-core/skills/huawei-ecs/references/evs.md +31 -31
  35. package/plugins/huaweicloud-core/skills/huawei-ecs/references/flavors.md +55 -55
  36. package/plugins/huaweicloud-core/skills/huawei-ecs/references/troubleshooting.md +52 -52
  37. package/plugins/huaweicloud-core/skills/huawei-functiongraph/SKILL.md +131 -131
  38. package/plugins/huaweicloud-core/skills/huawei-functiongraph/references/apig-event-format.md +58 -58
  39. package/plugins/huaweicloud-core/skills/huawei-functiongraph/references/create-function.md +71 -71
  40. package/plugins/huaweicloud-core/skills/huawei-functiongraph/references/deploy-workflow.md +119 -119
  41. package/plugins/huaweicloud-core/skills/huawei-functiongraph/references/triggers.md +142 -142
  42. package/plugins/huaweicloud-core/skills/huawei-gaussdb/SKILL.md +56 -56
  43. package/plugins/huaweicloud-core/skills/huawei-getting-started/SKILL.md +65 -65
  44. package/plugins/huaweicloud-core/skills/huawei-iam/SKILL.md +111 -111
  45. package/plugins/huaweicloud-core/skills/huawei-iam/references/policy-examples.md +122 -122
  46. package/plugins/huaweicloud-core/skills/huawei-iam/references/quick-ref.md +56 -56
  47. package/plugins/huaweicloud-core/skills/huawei-modelarts/SKILL.md +65 -65
  48. package/plugins/huaweicloud-core/skills/huawei-obs/SKILL.md +133 -127
  49. package/plugins/huaweicloud-core/skills/huawei-obs/references/bucket-create.md +49 -49
  50. package/plugins/huaweicloud-core/skills/huawei-obs/references/bucket-lifecycle.md +26 -26
  51. package/plugins/huaweicloud-core/skills/huawei-obs/references/common-pitfalls.md +100 -100
  52. package/plugins/huaweicloud-core/skills/huawei-obs/references/single-file-share.md +40 -40
  53. package/plugins/huaweicloud-core/skills/huawei-obs/references/static-website.md +56 -56
  54. package/plugins/huaweicloud-core/skills/huawei-rds/SKILL.md +224 -224
  55. package/plugins/huaweicloud-core/skills/huawei-sandbox/SKILL.md +135 -134
  56. package/plugins/huaweicloud-core/skills/huawei-smn-dms/SKILL.md +69 -69
  57. package/plugins/huaweicloud-core/skills/huawei-vpc/SKILL.md +84 -84
  58. package/plugins/huaweicloud-core/skills/huawei-vpc/references/network.md +76 -76
  59. package/plugins/huaweicloud-core/skills/huawei-vpc/references/security-group.md +59 -59
  60. package/plugins/huaweicloud-core/skills/huawei-vpc/references/subnet.md +50 -50
  61. package/plugins/huaweicloud-core/skills/huawei-waf-aad/SKILL.md +63 -63
  62. package/plugins/huaweicloud-core/skills/huaweicloud-api-and-sdk/SKILL.md +56 -56
  63. package/plugins/huaweicloud-core/skills/huaweicloud-api-and-sdk/agents/openai.yaml +4 -4
  64. package/plugins/huaweicloud-core/skills/huaweicloud-capability-discovery/SKILL.md +51 -47
  65. package/plugins/huaweicloud-core/skills/huaweicloud-capability-discovery/agents/openai.yaml +4 -4
  66. package/plugins/huaweicloud-core/skills/huaweicloud-cli-and-auth/SKILL.md +128 -128
  67. package/plugins/huaweicloud-core/skills/huaweicloud-cli-and-auth/agents/openai.yaml +4 -4
  68. package/plugins/huaweicloud-core/skills/huaweicloud-core/SKILL.md +110 -95
  69. package/plugins/huaweicloud-core/skills/huaweicloud-core/agents/openai.yaml +4 -4
  70. package/plugins/huaweicloud-core/skills/huaweicloud-core/references/report-issue.md +19 -19
  71. package/plugins/huaweicloud-core/skills/huaweicloud-core/references/select.md +27 -27
  72. package/plugins/huaweicloud-core/skills/huaweicloud-safety/SKILL.md +60 -60
  73. package/plugins/huaweicloud-core/skills/huaweicloud-safety/agents/openai.yaml +4 -4
  74. package/plugins/huaweicloud-core/skills/huaweicloud-troubleshooting/SKILL.md +83 -83
  75. package/plugins/huaweicloud-core/skills/huaweicloud-troubleshooting/agents/openai.yaml +4 -4
  76. package/plugins/huaweicloud-core/src/auth/agent-registration.mjs +105 -87
  77. package/plugins/huaweicloud-core/src/auth/credentials.mjs +95 -95
  78. package/plugins/huaweicloud-core/src/auth/service.mjs +63 -63
  79. package/plugins/huaweicloud-core/src/hcloud-cli.mjs +265 -265
  80. package/plugins/huaweicloud-core/src/mcp-server.mjs +129 -129
  81. package/plugins/huaweicloud-core/src/proxy/proxy-agent.mjs +155 -0
  82. package/plugins/huaweicloud-core/src/proxy/proxy-config.mjs +87 -0
  83. package/plugins/huaweicloud-core/src/risk-rule-engine.mjs +137 -137
  84. package/plugins/huaweicloud-core/src/safety-policy.mjs +302 -302
  85. package/plugins/huaweicloud-core/src/sandbox/hdkitservice-api.mjs +91 -87
  86. package/plugins/huaweicloud-core/src/sandbox/hwlink-api.mjs +162 -153
  87. package/plugins/huaweicloud-core/src/sandbox/session-manager.mjs +112 -105
  88. package/plugins/huaweicloud-core/src/search-market.mjs +174 -169
  89. package/plugins/huaweicloud-core/src/setup-cli.mjs +2017 -1594
  90. package/plugins/huaweicloud-core/src/tools.mjs +1008 -993
  91. package/plugins/huaweicloud-core/src/ws-exec/hwlink-exec-client.js +427 -427
  92. package/plugins/huaweicloud-core/src/ws-exec/hwlink-fair-queue.js +132 -132
  93. package/plugins/huaweicloud-core/src/ws-exec/hwlink-multiplexer.js +227 -227
  94. package/plugins/huaweicloud-core/src/ws-exec/hwlink-packet.js +202 -202
  95. package/plugins/huaweicloud-core/src/ws-exec/hwlink-terminal-channel.js +158 -158
  96. package/plugins/huaweicloud-core/src/ws-exec/index.js +19 -19
  97. package/plugins/huaweicloud-core/src/ws-exec/ws-exec-client.js +338 -338
@@ -1,65 +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` to read the agreement, then respond `y` to accept. Do not pipe `echo "y" |` — you must review the terms first.
22
- 3. **Configure credentials (unified)**: `npx huaweicloud-devkit auth init` — prefer this over `hcloud configure init`, which only covers KooCLI.
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 `npx huaweicloud-devkit auth init` (unified, interactive, recommended) or `hcloud configure init` (KooCLI only) 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 | Run `hcloud version` to read and accept the agreement. Review the terms before responding `y` |
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`
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` to read the agreement, then respond `y` to accept. Do not pipe `echo "y" |` — you must review the terms first.
22
+ 3. **Configure credentials (unified)**: `npx huaweicloud-devkit auth init` — prefer this over `hcloud configure init`, which only covers KooCLI.
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 `npx huaweicloud-devkit auth init` (unified, interactive, recommended) or `hcloud configure init` (KooCLI only) 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 | Run `hcloud version` to read and accept the agreement. Review the terms before responding `y` |
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`
@@ -1,111 +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
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
@@ -1,122 +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
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