Configure Alibaba Cloud CLI

Updated at:

The Alibaba Cloud CLI tool lets a custom digital employee directly call the OpenAPI operations of Alibaba Cloud services to run queries, change configurations, and perform O&M operations. For security, query operations (Get, List, Describe, and Query) run automatically by default; other operations run only after you confirm them; and the RAM role of the digital employee enforces the final permission boundary. This topic describes how to enable and manage the Alibaba Cloud CLI tool for a STAROps digital employee and how to use policy configurations to control the permission boundary with which the digital employee calls Alibaba Cloud service APIs.

Overview

The Alibaba Cloud CLI tool is an extension capability of custom digital employees. After the tool is enabled, the digital employee can recognize and run aliyun commands in a conversation and call the OpenAPI operations of the corresponding cloud service. This topic applies to account administrators, security administrators, and O&M users who configure the Alibaba Cloud CLI tool for custom digital employees.

The Alibaba Cloud CLI tool has the following key characteristics:

  • Enabled by default — The Alibaba Cloud CLI tool is enabled by default when a custom digital employee is created. You can also disable it manually in the settings of the digital employee.

  • Layered control — Each API call goes through four checks in sequence: the deny policy, the auto-pass policy, manual confirmation (human-in-the-loop, HIL), and RAM role permissions.

  • Permission separation — Tool policies control only whether the digital employee can initiate a call. Whether the call ultimately succeeds is determined by the permissions of the RAM role associated with the digital employee.

  • Custom role — If the permissions of the default service-linked role AliyunServiceRoleForSTAROps do not meet your scenario, you can select a custom RAM role.

Permission control model

The following details describe each decision layer:

  1. Deny policy (denyPolicy) — Has the highest priority. When a rule hits, the call is denied directly and does not go through the remaining decisions. If the deny policy is empty, no operation is denied.

  2. Auto-pass policy (autoPassPolicy) — When a rule hits, the API call is initiated directly without user confirmation. If the auto-pass policy is empty, the built-in default rules of STAROps are used.

  3. Manual confirmation (HIL) — Calls that match neither the deny policy nor the auto-pass policy require manual confirmation from the user before they can be initiated.

  4. RAM role permissions — All actual calls are ultimately constrained by the permissions of the RAM role associated with the digital employee. Tool policies do not replace RAM authorization.

Note

The deny policy is checked twice: once on the STAROps side and once on the open platform side, forming a double-layer fallback. Even if no rule hits on the STAROps side, the call may still be denied by the deny policy on the open platform side.

Default policies

Default auto-pass policy

If no auto-pass policy is configured, STAROps automatically uses the following built-in default rules to allow query operations:

  • *:Get*

  • *:List*

  • *:Describe*

  • *:Query*

    These operations run directly when the digital employee determines that a call is required, without per-call confirmation from the user.

Default service-linked role

A custom digital employee is associated with the service-linked role AliyunServiceRoleForSTAROps by default. Its system policy AliyunServiceRolePolicyForSTAROps covers read-only permissions on most cloud services and matches the default auto-pass policy.

Important

Service-linked roles do not support custom policies. If the permission scope of the default role does not meet your scenario, select a custom RAM role.

Prerequisites

Before you configure the Alibaba Cloud CLI tool, verify that the required permissions are in place. When a digital employee actually calls an API, it uses the permissions of its associated RAM role. Make sure that the RAM role is granted the RAM action that corresponds to each target API.

Permissions for your account

An Alibaba Cloud account has all permissions by default. A RAM user must be granted permissions by the Alibaba Cloud account or a RAM administrator.

RAM role permissions

Before you configure the Alibaba Cloud CLI tool, verify that the RAM role associated with the digital employee is granted the API permissions of the relevant products. Only actions that already exist in the RAM role are available for selection in the tool configuration interface.

The Alibaba Cloud CLI tool configuration is based on the RAM permission system, not on API tool names. You cannot use the tool name directly as a RAM action.

To find the correct RAM action:

  • Identify the target tool — Determine the name of the CLI tool that requires authorization, such as aliyun elasticsearch ListAllNode.

  • Check the OpenAPI reference — Go to the Alibaba Cloud OpenAPI portal and search for the API name, such as ListAllNode.

  • Get the actual RAM action — On the API reference page, find the Authorization Information section. The value in the Action column of the table is the RAM action.

  • Grant the permission in RAM — Use the actual RAM action that you found to grant permissions in the RAM role policy.

Example

To authorize the aliyun elasticsearch ListAllNode tool:

  • Incorrect — Granting elasticsearch:ListAllNode directly fails because this RAM action does not exist.

  • Correct — The OpenAPI reference for Elasticsearch shows that the ListAllNode API requires the elasticsearch:DescribeInstance RAM action. Grant this action in the RAM role policy, and the tool works.

Configuration methods

Configure a deny policy

With a deny policy, you can explicitly forbid certain API calls. For example, you can forbid delete operations on all products or forbid command execution operations. When a rule hits, the call is denied directly without manual confirmation (HIL). If the deny policy is empty, no operation is denied.

Scenario examples
  • Forbid all *:Delete* operations.

  • Forbid the ecs:RunCommand operation of ECS.

  • Forbid all high-risk operations that involve fees or role changes.

Visual editor
  1. In the Deny Policy area, click Add Deny Rule.

  2. Enter or select the action to deny in one of the following edit modes:

    • Wildcard Mode — Click a preset read/write operation shortcut tag (such as Delete*, Remove*, Modify*, Update*, Create*, Put*, Stop*, Release*, Get*, List*, Describe*, Query*, or Check*), or enter a custom wildcard pattern in the input field, such as *:Delete* or ecs:RunCommand.

    • Rule List — Select the target product. In the Select RAM Action dialog box, filter by operation type (write operations, read operations, list operations, or other operations), select the specific RAM actions to deny, and then click OK.

  3. Click Save to apply the configuration.

Script editor example

The following example shows a deny policy that blocks all delete operations and the ecs:RunCommand operation:

{
  "enable": true,
  "denyPolicy": [
    "*:Delete*",
    "ecs:RunCommand"
  ],
  "autoPassPolicy": []
}

Field

Description

enable

Specifies whether to enable Alibaba Cloud CLI. Set to true to enable the tool.

denyPolicy

The deny policy rule list. A call that hits a rule is denied directly. If the list is empty, no operation is denied.

autoPassPolicy

The auto-pass policy rule list. A call that hits a rule skips manual confirmation and runs directly. If the list is empty, the built-in default rules are used.

Each rule uses the <product identifier>:<action name> format and supports the * wildcard, for example, *:Delete* or ecs:RunCommand.

Important

The deny policy has the highest priority. Once a rule hits, the call is denied regardless of whether the RAM role has the corresponding permission.

Configure an auto-pass policy

With an auto-pass policy, you can customize which operations run directly without a confirmation prompt. If you do not configure an auto-pass policy, STAROps uses the built-in default rules *:Get*, *:List*, *:Describe*, and *:Query* by default.

Usage suggestions
  • Configure auto-pass only for low-risk, high-frequency query operations.

  • For operations that may incur fees or change resource states, keep the Ask for Confirmation mode so that these operations go through manual confirmation (HIL).

  • A custom auto-pass policy fully replaces the built-in default rules. Operations that do not match the custom policy all go through manual confirmation (HIL).

Visual editor
  1. In the Auto-Pass Policy area, click Add Auto-Pass Rule.

  2. Enter or select the action to run automatically in one of the following edit modes:

    • Wildcard Mode — Click a preset read/write operation shortcut tag, or enter a custom wildcard pattern in the input field, such as ecs:Describe* or vpc:Describe*.

    • Rule List — Select the target product. In the Select RAM Action dialog box, filter by operation type (write operations, read operations, list operations, or other operations), select the specific RAM actions to run automatically, and then click OK.

  3. Click Save to apply the configuration.

Script editor example

The following example shows an auto-pass policy that contains describe operations for ECS, VPC, and SLB:

{
  "enable": true,
  "denyPolicy": [],
  "autoPassPolicy": [
    "ecs:DescribeInstances",
    "ecs:DescribeDisks",
    "vpc:DescribeVpcs",
    "slb:DescribeLoadBalancers"
  ]
}
Note

The auto-pass policy controls only whether manual confirmation is skipped. The actual call still requires the RAM role of the digital employee to have the corresponding action permission. Otherwise, the call returns the Forbidden.RAM error.

Verify the configuration

After you complete the configuration, verify that the Alibaba Cloud CLI tool works as expected. Use one of the following methods.

Method 1: Test in the dialog box

Run an aliyun command in the dialog box with the digital employee:

aliyun ecs DescribeInstances --RegionId cn-hangzhou

Read-only query operations should be auto-passed and return results. Write operations or operations that do not match the auto-pass policy should trigger manual confirmation (HIL).

Method 2: Test the deny policy

Trigger an operation that the deny policy blocks. For example, if the deny policy contains the *:Delete* or ecs:RunCommand rule, trigger a matching operation. Verify that the call is denied directly without entering manual confirmation (HIL).

Method 3: Troubleshoot Forbidden.RAM permission errors

If a call is allowed by the tool policies but returns the Forbidden.RAM error, the RAM role of the digital employee does not have the required RAM action permission. Troubleshoot the issue as follows:

  1. Verify that the RAM role associated with the digital employee is granted the RAM action that corresponds to the target API. For information about how to find the RAM action, see the "RAM role permissions" section in this topic.

  2. If you use AliyunServiceRoleForSTAROps, verify that its system policy covers the RAM action.

  3. If the permissions of the default role are insufficient, switch to a custom RAM role and grant the required permissions.

Limits

Item

Description

Supported scope

Only custom digital employees support the Alibaba Cloud CLI tool. Built-in digital employees do not support it and require no configuration.

Permission boundary

Tool policies control only call decisions and do not supplement RAM role permissions. The final call result depends on whether the RAM role is authorized.

Service-linked role

AliyunServiceRoleForSTAROps contains only read-only permissions and does not support custom policies.

Deny policy priority

A call that hits the deny policy is denied directly. The deny policy takes precedence over the auto-pass policy and RAM role permissions.

FAQ

The Alibaba Cloud CLI tool is enabled. Why is my command not executed?

Troubleshoot in the following order:

  1. Check whether the command hits the deny policy. A command that hits the deny policy is denied directly.

  2. Check whether the command hits the auto-pass policy. A command that does not match enters manual confirmation (HIL) and waits for user confirmation.

  3. Check whether the RAM role of the digital employee has the RAM action permission for the API. Being allowed by the tool policy does not mean that the RAM role has the permission.

Why do read-only operations not enter manual confirmation (HIL)?

By default, *:Get*, *:List*, *:Describe*, and *:Query* operations hit the built-in default auto-pass rules and run directly. If you configure a custom auto-pass policy, the custom rules apply instead.

What do I do if the permissions of the service-linked role are insufficient?

When you create or update a custom digital employee, select a custom RAM role and grant the RAM action permissions that your scenario requires to that role.

After I configure a custom auto-pass policy, are the built-in default rules still in effect?

No. A custom auto-pass policy fully replaces the built-in default rules. To keep the default behavior, explicitly include the *:Get*, *:List*, *:Describe*, and *:Query* rules in your custom policy.