
Alibabacloud Ram Permission Diagnose
- 418 installs
- 208 repo stars
- Updated August 4, 2026
- aliyun/alibabacloud-aiops-skills
alibabacloud-ram-permission-diagnose is an Alibaba Cloud agent skill that parses RAM AccessDenied and 403 errors with the aliyun CLI, traces missing actions, explicit denies, or trust policy gaps, and recommends least-pr
About
alibabacloud-ram-permission-diagnose is an official Alibaba Cloud AIOps skill for developers and platform engineers hitting NoPermission or 403 errors during deploys, Terraform applies, or SDK calls. The workflow parses RAM error payloads, decodes diagnostic details through aliyun CLI RAM commands—requiring aliyun CLI version 3.3.3 or higher—and distinguishes missing actions, explicit denies, and trust policy misconfigurations. A quick path handles common cases while a deep path runs gap analysis against attached policies before generating least-privilege recommendations developers can apply. Install with npx skills add aliyun/alibabacloud-aiops-skills --skill alibabacloud-ram-permission-diagnose. Credentials arrive via AccessKey environment variables or Aliyun CLI profiles; cloud services should prefer EcsRamRole profiles over long-lived keys. The skill ships in the alibabacloud-aiops-skills collection maintained by Alibaba Cloud for agent-assisted operations where raw error strings hide the exact policy gap.
- Parses RAM deny reasons for specific API actions
- Compares required vs granted policy statements
- Suggests minimal policy patches without over-permissioning
- Supports cross-account and service-linked role checks
- Fits agent-driven incident response on Alibaba Cloud
Alibabacloud Ram Permission Diagnose by the numbers
- 418 all-time installs (skills.sh)
- Ranked #539 of 2,203 Security skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/aliyun/alibabacloud-aiops-skills --skill alibabacloud-ram-permission-diagnoseAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 418 |
|---|---|
| repo stars | ★ 208 |
| Last updated | August 4, 2026 |
| Repository | aliyun/alibabacloud-aiops-skills ↗ |
How do you diagnose Alibaba Cloud RAM AccessDenied errors?
Diagnose denied Alibaba Cloud RAM actions, trace policy gaps, and recommend least-privilege fixes when agents or apps hit AccessDenied during deploys or API calls.
Who is it for?
Platform engineers debugging Alibaba Cloud RAM 403 errors who have aliyun CLI 3.3.3+ and need structured gap analysis.
Skip if: Developers on AWS IAM, Azure RBAC, or GCP IAM who need cloud-agnostic identity troubleshooting without Alibaba Cloud RAM.
When should I use this skill?
An Alibaba Cloud API call, deploy, or agent action returns AccessDenied, NoPermission, or RAM-related 403 errors.
What you get
RAM permission gap analysis, root-cause classification, and least-privilege policy recommendations
- RAM gap analysis report
- least-privilege policy recommendations
By the numbers
- Requires aliyun CLI version 3.3.3 or higher
- Published as alibabacloud-ram-permission-diagnose v0.0.2 in the official skills repository
Files
RAM Permission Diagnosis and Repair
Installation
Pre-check: Aliyun CLI >= 3.3.3 required
Run aliyun version to verify >= 3.3.3. If not installed or version too low,run curl -fsSL https://aliyuncli.alicdn.com/setup.sh | bash to update,or see references/cli-installation-guide.md for installation instructions.Pre-check: Aliyun CLI plugin update required
[MUST] run aliyun configure set --auto-plugin-install true to enable automatic plugin installation.[MUST] run aliyun plugin update to ensure that any existing plugins are always up-to-date.At the start of the Core Workflow (before any CLI invocation): [MUST] Enable AI-Mode — AI-mode is required for Agent Skill execution. Run the following commands before any CLI invocation:
aliyun configure ai-mode enable
aliyun configure ai-mode set-user-agent --user-agent "AlibabaCloud-Agent-Skills/alibabacloud-ram-permission-diagnose"[MUST] Disable AI-Mode at EVERY exit point — Before delivering the final response for ANY reason, always disable AI-mode first. This applies to ALL exit paths: workflow success, workflow failure, error/exception, user cancellation, session end, or any other scenario where no further CLI commands will be executed. AI-mode is only used for Agent Skill invocation scenarios and MUST NOT remain enabled after the skill stops running.
aliyun configure ai-mode disable[MUST] CLI User-Agent — Every aliyun CLI command invocation must include: --user-agent AlibabaCloud-Agent-Skills/alibabacloud-ram-permission-diagnose
Execution constraint: When executingaliyunCLI commands directly (not generating commands for the user to copy), always append--user-agent AlibabaCloud-Agent-Skills/alibabacloud-ram-permission-diagnose. Do not add this flag to commands shown to users in Path B output or Path C console guidance.
Overview
When a RAM permission error is detected, run through these steps:
1. Quick Analysis — parse raw error fields (no tool calls), output a brief summary, ask the user to choose analysis depth 2. Deep Analysis — (only if user selects path B) decode if needed, run gap analysis, classify root cause 3. Generate Recommendations — least-privilege authorization plan 4. Execute Repair — present repair options and wait for user to choose
Permission level (L0–L3) is the agent's internal routing state, inferred implicitly from API call results during the flow. It determines diagnostic depth and available repair paths. Never declare or describe the level to the user. See references/diagnose-flow.md for level definitions.
---
Step 1: Quick Analysis
Parse raw error fields without any tool calls, then let the user decide how deep to go.
1a. Extract from raw error
error_code: e.g.,NoPermission,Forbidden,InvalidSecurityTokenmissing_action: e.g.,ecs:StopInstanceprincipal_type:SubUser/AssumedRoleUser/RootUser(fromAuthPrincipalType)principal_display_name: UserId or role:session (fromAuthPrincipalDisplayName)no_permission_type:ImplicitDenyorExplicitDeny(fromNoPermissionType)policy_type: e.g.,AccountLevelIdentityBasedPolicy,AssumeRolePolicy(fromPolicyType)encoded_message: retainEncodedDiagnosticMessageif present, for use in Step 2 if needed
1b. Output brief summary
Based on the extracted fields, output a concise summary: who is affected, what action is missing, initial root cause inference.
1c. Present depth choice and wait for selection
Present the following and wait for the user to select — do not proceed until a choice is made:
- A. Quick path (recommended when: ImplicitDeny + all key fields present + common service) — skip Step 2, generate recommendations directly from raw fields and built-in knowledge
- B. Deep path (recommended when: ExplicitDeny, missing fields, or unfamiliar service) — run full Step 2 analysis for a more precise result.
Requires two optional permissions:ram:DecodeDiagnosticMessage(decode encoded errors) and system policyAliyunRAMReadOnlyAccess(gap analysis). Missing permissions limit specific capabilities but the flow continues.
- Skip — stop here; output manual troubleshooting links
Mark the recommended option clearly and briefly explain why.
If user selects A: proceed to Step 3. Note in the recommendation that it is based on quick analysis; the user can request deep analysis at any time.
If user selects B: proceed to Step 2.
If user selects Skip: output error summary, links to RAM documentation (https://help.aliyun.com/document_detail/93733.html) and RAM console (https://ram.console.aliyun.com/policies), and a note on how to restart diagnosis.
Edge case — ExplicitDeny with path A forced: if NoPermissionType = ExplicitDeny and the user still selects A, explain that the specific Deny policy cannot be identified without deep analysis, and provide a limited recommendation with explicit uncertainty noted.
---
Step 2: Deep Analysis
Entered only when the user selects path B in Step 1.
First attempt classification using the raw fields from Step 1. DecodeDiagnosticMessage is a supplement — invoke it only when raw data is insufficient to classify with confidence.
Decode when raw data alone cannot resolve the root cause: e.g., ExplicitDeny is present (need MatchedPolicies), AccessDeniedDetail was absent, or PolicyType is missing. For cases where NoPermissionType, AuthAction, AuthPrincipalType, and PolicyType are all available and point to a clear root cause, skip decode and proceed directly.
Transcribe EncodedDiagnosticMessage from the raw error and call:
aliyun ram decode-diagnostic-message --encoded-diagnostic-message "<transcribed-value>"If the call returns EntityNotExist, re-run the original failing command and save its output to a temp file (use the system temp dir; name the file after the command context, e.g. /tmp/aliyun_ecs_stopinstance.txt). Extract EncodedDiagnosticMessage from the file and retry the decode. If the field is not found in the file, mark as L0 and continue.
If SubUser identity needs UserName resolution before gap analysis, see references/diagnose-flow.md → Identity Resolution. If resolution fails, mark as L0 and continue.
Root cause categories:
- MissingAction — identity policy lacks the required Action (most common)
- ExplicitDeny — a Deny statement blocks access (may be identity policy or CP control policy)
- TrustPolicy — role trust policy does not allow the caller to assume the role
- STSInsufficient — STS temporary credential lacks permission; root cause is on the originating Role
- TokenExpired — STS token has expired
- SLRMissing — service-linked role has not been created
- ResourcePolicy — resource-side policy (e.g., OSS Bucket Policy) is restricting access
For gap analysis trigger rules and per-root-cause handling details, see references/diagnose-flow.md.
Gap analysis (when triggered): query current policies attached to the identity, then compare against the required Action. Use ListPoliciesForUser (SubUser), ListPoliciesForRole (AssumedRoleUser), or ListControlPolicies (RootUser). For Custom policies, fetch the policy document with GetPolicyVersion. System policies: use built-in knowledge, do not call GetPolicyVersion.
When permissions are insufficient: if DecodeDiagnosticMessage fails (L0) or policy queries fail (L1), inform the user of the limitation and provide ready-to-use permission request materials for a RAM admin — two independent options: ① decode permission (ram:DecodeDiagnosticMessage) as a custom policy; ② RAM read access via system policy AliyunRAMReadOnlyAccess (covers gap analysis). Either or both can be requested independently. Then continue to Step 3 without waiting.
---
Step 3: Generate Recommendations
Before generating, check for caller skill permission hints (see references/diagnose-flow.md → Coverage Check).
Knowledge source priority: 1. Built-in knowledge — for popular services (ECS, OSS, RDS, FC, SLB, VPC, SLS, STS, etc.), use known Action semantics directly. Reference references/hot-services-ram.md. 2. Caller skill hints — if ram-policies.md was found, use as supplementary context 3. Web search — search {product} RAM authorization site:help.aliyun.com; prefer manually maintained docs with business examples over auto-generated Action tables 4. System policy fallback — recommend AliyunXxxReadOnlyAccess or AliyunXxxFullAccess with a note to tighten further
Custom policy naming: suggest a name based on service and task semantics (e.g., ai-agent-ecs-permissions), confirm once, reuse in the same session.
System policy: attach directly with a single command, no naming needed.
For the Trust Policy root cause path, recommendations differ — see references/diagnose-flow.md → Handling Each Root Cause.
After presenting the recommendation, add a brief note: the current plan is a starting point; the user can request further refinement at any time — for example, scoping down to specific resources, adding conditions, or using resource-level policies (such as OSS bucket policies) instead of identity-level grants.
---
Step 4: Execute Repair
Before executing any write operation, present the change summary and all available paths to the user, then wait for the user to select a path — do not proceed or output any commands until the user has chosen:
- Target (user or role name)
- Change summary (policy name, action, undo method)
- Path options (always present all that are available for the current level — never skip any):
- A. Direct CLI execution — agent runs commands now (only at L2)
- B. Output CLI commands — user copies and runs in their own terminal (all levels)
- C. Console guidance — step-by-step in RAM console (all levels)
- Skip — do not execute
For pre-query requirements before write operations, and full CLI command examples, see references/ram-cli-commands.md and references/diagnose-flow.md.
Path A: agent executes via Bash. On success → L3 confirmed; report result and undo command. On NoPermission → switch to Path B automatically.
Path B at L0/L1: output incremental Statement JSON only, with a note that existing policies could not be read and the user must merge manually.
Path B at L2: offer two sub-options: ① incremental Statement only, ② complete merged policy JSON.
Path C: provide the RAM console entry (https://ram.console.aliyun.com/policies) and step-by-step instructions for completing the change in the console UI.
After repair, suggest the user retry the previously failed operation. Offer to retry on their behalf if requested.
Diagnose Flow Reference
Detailed decision logic for RAM permission diagnosis. Consult this file when encountering complex or ambiguous scenarios.
---
Identity Resolution
AuthPrincipalType and AuthPrincipalDisplayName are available in the raw error's AccessDeniedDetail — no decode needed. Resolve UserName before gap analysis when identity type is SubUser:
AuthPrincipalType | AuthPrincipalDisplayName format | Resolution |
|---|---|---|
SubUser | Numeric UserId (e.g., 206007273725819551) | Call aliyun ims get-user --user-id <DisplayName>, use returned User.UserName |
AssumedRoleUser | roleName:sessionName (e.g., my-role:session-1) | Take the part before the colon as RoleName — no API needed |
RootUser | Primary account identifier | Use directly — no resolution needed |
If GetUser fails (insufficient permission): mark as L0, fall back to raw error text.
---
Permission Level (L0–L3)
Levels are implicit routing state — never declare or describe them to the user.
| Level | Confirmed When | Effect |
|---|---|---|
| L0 | DecodeDiagnosticMessage returns NoPermission | Root cause from raw text only; repair: Path B (incremental) + Path C |
| L1 | Decode succeeds, but policy query returns NoPermission | Skip gap analysis; repair: Path B (incremental) + Path C |
| L2 | Policy query returns results | Full gap analysis; repair: Path A (tentative) + Path B (with merge) + Path C |
| L3 | Write operation succeeds | Repair done; report result and undo command |
Insufficient permission criteria: ErrorCode NoPermission, Forbidden, or AccessDenied.
If user reports they have updated their own permissions: re-run Step 2 policy query to refresh level state.
---
Root Cause Classification Decision Tree
ExplicitDeny = true?
├─ Yes → Explicit Deny path
│ NoPermissionPolicyType = ControlPolicy?
│ ├─ Yes → Root cause: CP control policy (out of scope, guide to manual)
│ ├─ No (AccountLevelIdentityBasedPolicy) → Root cause: own policy Deny (fixable)
│ └─ Unknown (field absent) → Query both ListPoliciesForUser + ListControlPolicies
│
└─ No (or no decoded info) → Missing Action path
├─ PolicyType = AssumeRolePolicy → Root cause: role trust policy not allowing caller
├─ MissingAction = sts:AssumeRole, PolicyType absent
│ → Medium confidence: trust policy OR identity policy missing sts:AssumeRole
│ Describe both; guide user to verify before choosing repair direction
├─ PrincipalARN contains AssumedRole/STS token → Root cause: STS credential insufficient
├─ ErrorCode = InvalidSecurityToken → Root cause: STS token expired
├─ Message contains ServiceLinkedRole → Root cause: SLR missing
├─ Error from OSS Bucket Policy etc. → Root cause: resource-side policy
└─ Other → Root cause: missing Action (most common)Key principle: When DecodeDiagnosticMessage succeeds and NoPermissionPolicyType has a clear value, treat it as authoritative. Do not append additional verification API calls to check other possible root causes.
---
Gap Analysis Trigger Rules
| Root Cause | Trigger Gap Analysis | Notes |
|---|---|---|
| Missing Action | ✅ Must query | Query by identity type (see below) |
| Explicit Deny (NoPermissionPolicyType=AccountLevelIdentityBasedPolicy) | ✅ Query | Locate the Deny statement |
| Explicit Deny (NoPermissionPolicyType unknown) | ✅ Query + ListControlPolicies | Both policy and CP layer |
| Explicit Deny (NoPermissionPolicyType=ControlPolicy) | ❌ Skip | CP level, guide to manual |
| Trust Policy path | ✅ GetRole only | Get target role trust policy |
| SLR missing / resource-side policy / token expired | ❌ Skip | Direct output only |
Identity type → Query API (for root causes that trigger gap analysis):
| Identity Type | AuthPrincipalType | Query API |
|---|---|---|
| RAM user | SubUser | ListPoliciesForUser (UserName from Step 1) + GetPolicyVersion (Custom only) |
| RAM role | AssumedRoleUser | ListPoliciesForRole (RoleName from DisplayName) + GetPolicyVersion (Custom only) |
| Primary account | RootUser | ListControlPolicies directly |
System policies: Use built-in knowledge to infer coverage — do not call GetPolicyVersion.
---
Repair Pre-Query Rules
| Repair Type | Pre-query Required | Notes |
|---|---|---|
| Attach system policy | None | Pure write |
| Create new custom policy | None | Agent generates content |
| Append Action to existing custom policy | GetPolicyVersion + ListPolicyVersions | Must include all existing + new Actions in new version |
| Modify role Trust Policy | GetRole | Can reuse Step 2 result if already fetched |
| Create SLR | None | Pure write |
---
Coverage Check (for caller skill permission hints)
Before generating recommendations in Step 3:
1. Scan conversation context for the most recent Base directory: <path> injected by a skill invocation 2. If found, try reading <path>/references/ram-policies.md 3. If either file is read, perform a Coverage Check:
- Does the actual missing Action from the error appear covered? (exact match, wildcard, or reasonably implied)
- If clearly NOT covered: include the missing Action in the primary recommendation; add note: "⚠ The Action
{missing_action}triggered by this error is not declared in the skill's permission hints file and has been automatically added. Consider notifying the skill maintainer to updatereferences/ram-policies.md." - Otherwise: use file as supplementary context, normal flow continues
4. If no file found: skip silently, no impact on flow
---
Handling Each Root Cause
Missing Action / own policy Deny: Proceed to Step 3 recommendations → Step 4 repair.
Role trust policy not allowing caller (PolicyType=AssumeRolePolicy or medium-confidence sts:AssumeRole):
- Explain: trust policy of the target role must be updated to add the caller's ARN to Principal
- If role name is known: provide modification command directly (see
references/ram-cli-commands.md→ Trust Policy section) - If unknown: provide
aliyun ram list-rolesand a template for the user to fill in - Also note: caller's identity policy must also have
sts:AssumeRole(seeAliyunSTSAssumeRoleAccess) - For medium-confidence: describe both possible root causes and guide user to verify first
STS credential insufficient:
- Explain: using STS temporary credential; missing permission must be added to the Role that generated the STS
- Provide Role name (from PrincipalARN) and suggested actions; do not auto-repair
STS token expired: Prompt user to re-obtain STS token; provide renewal command.
SLR missing: Provide creation command:
aliyun resourcemanager create-service-linked-role --service-name <service>.aliyuncs.comCP control policy: Beyond single-account RAM scope; contact ResourceDirectory administrator.
Resource-side policy (OSS Bucket Policy etc.): Explain distinction; provide resource-side modification guidance; do not follow RAM repair flow.
Alibaba Cloud RAM Permission ErrorCode Reference
Insufficient Permission (requires authorization repair)
| ErrorCode | Description | Typical Scenario |
|---|---|---|
NoPermission | The current identity does not have permission to perform this operation | Most common — RAM user/role missing the required Action |
Forbidden | Operation denied | Some services use this code instead of NoPermission |
AccessDenied | Access denied | Commonly used by OSS, STS, and other services |
Forbidden.RAM | Denied by RAM policy | Contains information related to RAM sub-accounts |
Forbidden.NotSupportRAM | This operation does not support RAM sub-accounts | Requires primary account operation or special authorization |
STS / Token Issues (requires renewal or reconfiguration)
| ErrorCode | Description | How to Handle |
|---|---|---|
InvalidSecurityToken.Expired | STS Token has expired | Re-run AssumeRole to obtain a new token |
InvalidSecurityToken.MismatchWithAccessKey | Token does not match the AK | Verify that AK/SK/Token all come from the same AssumeRole call |
InvalidSecurityToken | Token is invalid | Check token format and validity |
SecurityTokenExpired | Security token expired (used by some services) | Same as above — re-obtain token |
Service-Linked Role Issues (requires creating an SLR)
| ErrorCode | Description | How to Handle |
|---|---|---|
ServiceRoleNotFound | Service-linked role does not exist | Create the SLR for the corresponding service |
ServiceLinkedRoleNotExist | Same as above (used by some services) | Create the SLR for the corresponding service |
Permission Level Probing Reference
The following ErrorCodes indicate the identity has permission but the parameter or resource has an issue — they do not indicate insufficient permission. Encountering these codes during probing means the permission exists at that level:
InvalidParameter,MissingParameterEntityNotExist,EntityNotExistsNotFound,ResourceNotFoundInvalidInput
The following ErrorCodes explicitly indicate insufficient permission — stop probing and record the level upon encountering them:
NoPermission,Forbidden,AccessDeniedForbidden.RAM,Forbidden.NotSupportRAM
Popular Services RAM Action Reference
Used for Step 3 built-in knowledge priority. The following Actions are grouped by common task scenarios and can be used directly to generate minimum-privilege policies.
ECS (Elastic Compute Service)
Common Action Groups
| Scenario | Required Actions | Resource Pattern |
|---|---|---|
| List / describe instances | ecs:DescribeInstances, ecs:DescribeInstanceStatus | acs:ecs:*:*:instance/* |
| Start / stop instances | ecs:StartInstance, ecs:StopInstance, ecs:RebootInstance | acs:ecs:*:*:instance/* |
| Create instances | ecs:RunInstances, ecs:DescribeImages, ecs:DescribeSecurityGroups | acs:ecs:*:*:* |
| Change instance type | ecs:ModifyInstanceSpec, ecs:DescribeResourcesModification | acs:ecs:*:*:instance/* |
| Disk snapshots | ecs:CreateSnapshot, ecs:DescribeSnapshots, ecs:DescribeDisks | acs:ecs:*:*:disk/* |
| Security group management | ecs:DescribeSecurityGroups, ecs:AuthorizeSecurityGroup, ecs:RevokeSecurityGroup | acs:ecs:*:*:securitygroup/* |
Recommended System Policies
- Read-only operations:
AliyunECSReadOnlyAccess - Operational access (no create/delete):
AliyunECSOperatorAccess - Full control:
AliyunECSFullAccess
---
OSS (Object Storage Service)
Common Action Groups
| Scenario | Required Actions | Resource Pattern |
|---|---|---|
| Read objects | oss:GetObject, oss:HeadObject | acs:oss:*:*:<bucket-name>/* |
| Upload objects | oss:PutObject, oss:InitiateMultipartUpload, oss:UploadPart | acs:oss:*:*:<bucket-name>/* |
| Delete objects | oss:DeleteObject | acs:oss:*:*:<bucket-name>/* |
| List objects | oss:ListObjects, oss:ListBuckets | acs:oss:*:*:<bucket-name> |
| Bucket management | oss:CreateBucket, oss:DeleteBucket, oss:GetBucketInfo | acs:oss:*:*:* |
Recommended System Policies
- Read-only:
AliyunOSSReadOnlyAccess - Full control:
AliyunOSSFullAccess
---
RDS (Relational Database Service)
Common Action Groups
| Scenario | Required Actions | Resource Pattern |
|---|---|---|
| Query instances / databases | rds:DescribeDBInstances, rds:DescribeDBInstanceAttribute | acs:rds:*:*:dbinstance/* |
| Create database accounts | rds:CreateAccount, rds:DescribeAccounts | acs:rds:*:*:dbinstance/* |
| Backup management | rds:CreateBackup, rds:DescribeBackups | acs:rds:*:*:dbinstance/* |
| Change instance type | rds:ModifyDBInstanceSpec | acs:rds:*:*:dbinstance/* |
| Whitelist management | rds:ModifySecurityIps, rds:DescribeDBInstanceIPArrayList | acs:rds:*:*:dbinstance/* |
Recommended System Policies
- Read-only:
AliyunRDSReadOnlyAccess - Full control:
AliyunRDSFullAccess
---
FC (Function Compute)
Common Action Groups
| Scenario | Required Actions | Resource Pattern |
|---|---|---|
| Invoke functions | fc:InvokeFunction | acs:fc:*:*:services/*/functions/* |
| Query functions | fc:GetFunction, fc:ListFunctions, fc:GetService | acs:fc:*:*:services/* |
| Deploy functions | fc:CreateFunction, fc:UpdateFunction, fc:CreateService | acs:fc:*:*:* |
| Trigger management | fc:CreateTrigger, fc:UpdateTrigger, fc:ListTriggers | acs:fc:*:*:services/*/functions/*/triggers/* |
Recommended System Policies
- Read-only:
AliyunFCReadOnlyAccess - Full control:
AliyunFCFullAccess
---
SLB (Server Load Balancer)
Common Action Groups
| Scenario | Required Actions | Resource Pattern |
|---|---|---|
| Query instances | slb:DescribeLoadBalancers, slb:DescribeLoadBalancerAttribute | acs:slb:*:*:loadbalancer/* |
| Listener management | slb:CreateLoadBalancerHTTPListener, slb:StartLoadBalancerListener | acs:slb:*:*:loadbalancer/* |
| Backend servers | slb:AddBackendServers, slb:RemoveBackendServers | acs:slb:*:*:loadbalancer/* |
Recommended System Policies
- Read-only:
AliyunSLBReadOnlyAccess - Full control:
AliyunSLBFullAccess
---
VPC (Virtual Private Cloud)
Common Action Groups
| Scenario | Required Actions | Resource Pattern |
|---|---|---|
| Query VPCs / VSwitches | vpc:DescribeVpcs, vpc:DescribeVSwitches | acs:vpc:*:*:vpc/* |
| Security groups / routing | vpc:DescribeRouteTables, vpc:DescribeRouteEntryList | acs:vpc:*:*:routetable/* |
| EIP management | vpc:AllocateEipAddress, vpc:AssociateEipAddress, vpc:DescribeEipAddresses | acs:vpc:*:*:eip/* |
Recommended System Policies
- Read-only:
AliyunVPCReadOnlyAccess - Full control:
AliyunVPCFullAccess
---
SLS (Log Service)
Common Action Groups
| Scenario | Required Actions | Resource Pattern |
|---|---|---|
| Query logs | log:GetLogStore, log:GetLogs, log:ListLogStores | acs:log:*:*:project/* |
| Write logs | log:PostLogStoreLogs | acs:log:*:*:project/*/logstore/* |
| Project management | log:CreateProject, log:ListProject | acs:log:*:*:* |
Recommended System Policies
- Read-only:
AliyunLogReadOnlyAccess - Full control:
AliyunLogFullAccess
RAM-Related aliyun CLI Command Reference
All commands are executed via thealiyunCLI. Credentials must be configured in advance (aliyun configure).
Diagnostic Commands
Decode Encrypted Diagnostic Message
Transcribe EncodedDiagnosticMessage from the error output and call directly:
aliyun ram decode-diagnostic-message --encoded-diagnostic-message "<transcribed-value>"If EntityNotExist is returned (transcription error), re-run the original failing command to a temp file and extract the token:
aliyun <product> <operation> [params] > /tmp/<context>.txt 2>&1
aliyun ram decode-diagnostic-message \
--encoded-diagnostic-message "$(grep -o 'EncodedDiagnosticMessage:[^ ]*' /tmp/<context>.txt | cut -d: -f2)"Query Current Identity
aliyun ram get-userResolve User Identity (UserId → UserName)
When DecodeDiagnosticMessage returns AuthPrincipalType = SubUser, the AuthPrincipalDisplayName is a numeric UserId that cannot be used directly in RAM APIs. Use the following command to resolve the UserName:
aliyun ims get-user --user-id <UserId>
# Use User.UserName from the response for subsequent RAM operationsList Policies Attached to a User
aliyun ram list-policies-for-user --user-name <username>List Policies Attached to a Role
aliyun ram list-policies-for-role --role-name <rolename>Read Policy Content (get current version document)
# First get the policy default version
aliyun ram get-policy --policy-name <policy-name> --policy-type Custom
# Read the policy document for a specific version
aliyun ram get-policy-version \
--policy-name <policy-name> \
--policy-type Custom \
--version-id <version-id>List Policy Versions
aliyun ram list-policy-versions \
--policy-name <policy-name> \
--policy-type Custom---
System Policy Repair Commands
Attach System Policy to a RAM User
aliyun ram attach-policy-to-user \
--policy-name <system-policy-name> \
--policy-type System \
--user-name <username>Attach System Policy to a RAM Role
aliyun ram attach-policy-to-role \
--policy-name <system-policy-name> \
--policy-type System \
--role-name <rolename>Detach System Policy
# Detach from user
aliyun ram detach-policy-from-user \
--policy-name <system-policy-name> \
--policy-type System \
--user-name <username>
# Detach from role
aliyun ram detach-policy-from-role \
--policy-name <system-policy-name> \
--policy-type System \
--role-name <rolename>---
Custom Policy Repair Commands
Create Custom Policy (first time)
aliyun ram create-policy \
--policy-name <policy-name> \
--policy-document '{"Version":"1","Statement":[{"Effect":"Allow","Action":["svc:Action"],"Resource":"acs:svc:*:*:*"}]}'Attach Custom Policy to a User
aliyun ram attach-policy-to-user \
--policy-name <policy-name> \
--policy-type Custom \
--user-name <username>Attach Custom Policy to a Role
aliyun ram attach-policy-to-role \
--policy-name <policy-name> \
--policy-type Custom \
--role-name <rolename>Append New Actions (update policy version)
# Step 1: Get current policy content (check version first)
aliyun ram get-policy --policy-name <policy-name> --policy-type Custom
# Note the DefaultVersion field value, e.g., v3
# Step 2: Read the current version document
aliyun ram get-policy-version \
--policy-name <policy-name> \
--policy-type Custom \
--version-id v3
# Step 3 (if 5 versions already exist): delete the oldest non-default version
aliyun ram delete-policy-version \
--policy-name <policy-name> \
--version-id v1
# Step 4: Create new version (complete JSON with existing + new Actions)
aliyun ram create-policy-version \
--policy-name <policy-name> \
--policy-document '{"Version":"1","Statement":[...all Actions...]}' \
--set-as-default trueDetach Custom Policy
# Detach from user
aliyun ram detach-policy-from-user \
--policy-name <policy-name> \
--policy-type Custom \
--user-name <username>
# Detach from role
aliyun ram detach-policy-from-role \
--policy-name <policy-name> \
--policy-type Custom \
--role-name <rolename>Delete Custom Policy (all versions + the policy itself)
# First delete all non-default versions
aliyun ram delete-policy-version --policy-name <policy-name> --version-id v1
# ...repeat until only the default version remains
# Then delete the policy (automatically removes the last version)
aliyun ram delete-policy --policy-name <policy-name>---
Role Trust Policy Repair Commands
Use this sequence when root cause is "trust policy not allowing caller":
# Step 1: Get current trust policy content
aliyun ram get-role --role-name <role-name>
# Note the AssumeRolePolicyDocument field
# Step 2: Update trust policy (add caller ARN to Principal.RAM array)
aliyun ram update-role \
--role-name <role-name> \
--new-assume-role-policy-document '{"Statement":[{"Action":"sts:AssumeRole","Effect":"Allow","Principal":{"RAM":["acs:ram::<account-id>:root","acs:ram::<account-id>:user/<caller-username>"]}}],"Version":"1"}'
# Undo: restore original Principal by calling UpdateRole again with original JSON
aliyun ram update-role \
--role-name <role-name> \
--new-assume-role-policy-document '<original-json>'If caller identity policy also lacks sts:AssumeRole, attach the system policy:
aliyun ram attach-policy-to-user \
--policy-name AliyunSTSAssumeRoleAccess \
--policy-type System \
--user-name <username>
# Undo
aliyun ram detach-policy-from-user \
--policy-name AliyunSTSAssumeRoleAccess \
--policy-type System \
--user-name <username>If role name is unknown, list roles first:
aliyun ram list-roles---
Service-Linked Role Commands
# Create a service-linked role
aliyun resourcemanager create-service-linked-role \
--service-name <service>.aliyuncs.com
# Check whether a service-linked role exists
aliyun ram get-role --role-name AliyunServiceRole<ServiceName>---
CP Control Policy Query Commands (ResourceDirectory)
# List all control policies
aliyun resourcemanager list-control-policies
# View a specific control policy's content
aliyun resourcemanager get-control-policy --policy-id <policy-id>RAM Hints for ram-permission-diagnose Skill
<!-- ram-hints-version: 1 -->
Action Permission Mapping
Diagnostic Operations (read-only)
| Operation | Required Actions | Optional Actions | Resource Pattern |
|---|---|---|---|
| Decode encrypted diagnostic message (L1) | ram:DecodeDiagnosticMessage | - | acs:ram:::* |
| Query current user info (L2) | ram:GetUser | - | acs:ram:::user/* |
| List policies attached to a user (L2) | ram:ListPoliciesForUser | - | acs:ram:::* |
| List policies attached to a role (L2) | ram:ListPoliciesForRole | - | acs:ram:::* |
| Read policy content (L2) | ram:GetPolicy,ram:GetPolicyVersion | - | acs:ram:::policy/* |
| List policy versions (L2) | ram:ListPolicyVersions | - | acs:ram:::policy/* |
| Query CP control policies (L2) | ram:ListControlPolicies,ram:GetControlPolicy | - | acs:ram:::* |
Repair Operations (write — required for L3)
| Operation | Required Actions | Optional Actions | Resource Pattern |
|---|---|---|---|
| Create custom policy | ram:CreatePolicy | - | acs:ram:::policy/* |
| Attach policy to user | ram:AttachPolicyToUser | - | acs:ram:::* |
| Attach policy to role | ram:AttachPolicyToRole | - | acs:ram:::* |
| Update policy version | ram:CreatePolicyVersion,ram:DeletePolicyVersion | ram:ListPolicyVersions | acs:ram:::policy/* |
| Detach policy from user | ram:DetachPolicyFromUser | - | acs:ram:::* |
| Detach policy from role | ram:DetachPolicyFromRole | - | acs:ram:::* |
Recommended System Policies
- Diagnostic only (L1+L2):
AliyunRAMReadOnlyAccess - Full functionality (L1+L2+L3):
AliyunRAMFullAccess
Official RAM Documentation
- https://help.aliyun.com/document_detail/28630.html (RAM authorization action list — manually maintained)
Related skills
How it compares
Pick alibabacloud-ram-permission-diagnose over generic IAM prompts when errors come from Alibaba Cloud RAM and you need aliyun CLI-backed gap analysis.
FAQ
Which aliyun CLI version does alibabacloud-ram-permission-diagnose require?
alibabacloud-ram-permission-diagnose requires aliyun CLI version 3.3.3 or higher because RAM diagnostic subcommands used for decoding AccessDenied errors depend on that CLI release level.
What failure types does alibabacloud-ram-permission-diagnose distinguish?
alibabacloud-ram-permission-diagnose classifies missing action permissions, explicit deny statements, and trust policy issues after parsing RAM error messages and running gap analysis against attached policies.
How do developers authenticate for alibabacloud-ram-permission-diagnose?
Developers authenticate with ALIBABACLOUD_ACCESS_KEY_ID and ALIBABACLOUD_ACCESS_KEY_SECRET environment variables or Aliyun CLI profiles; cloud workloads should prefer EcsRamRole profiles over plaintext AccessKey pairs.