Configure Alibaba Cloud CLI

Updated at:

This topic describes how to configure Alibaba Cloud CLI for a digital employee to enable API calls through aliyun commands, and how to verify the configuration.

Prerequisites

Before you configure Alibaba Cloud CLI, verify that the required permissions are in place.

RAM user permissions

Your account must have permissions to read RAM role policies. Without these permissions, the Tool Execution page displays the error "RAM permission verification failed. Configuration is not allowed." and the Alibaba Cloud CLI configuration becomes read-only. Ask the Alibaba Cloud account owner to grant the following permissions:

  • ram:GetRole

  • ram:ListPoliciesForRole

  • ram:GetPolicyVersion

RAM role permissions

The RAM role associated with the digital employee must have the API permissions for the relevant products. Only actions listed in the RAM role policy are available for selection in the tool configuration interface.

Important

Alibaba Cloud CLI configuration uses the RAM permission system, not API tool names. You cannot use the tool name directly as the RAM action.

To find the correct RAM action:

  1. Identify the CLI tool that requires authorization, such as aliyun elasticsearch ListAllNode.

  2. Go to the OpenAPI Explorer and search for the API name, such as ListAllNode.

  3. On the API documentation page, find the Authorization Information section. The Action column shows the required RAM action.

  4. Add the RAM action to 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 documentation for the Elasticsearch service shows that the ListAllNode API requires the elasticsearch:DescribeInstance RAM action. Grant this action in the RAM role policy.

Configuration methods

You can configure Alibaba Cloud CLI during digital employee creation or from the settings page of an existing digital employee. Both paths use the same procedure.

Entry 1: Configure during digital employee creation

  1. In the digital employee creation flow, go to the Tool Execution step, find Alibaba Cloud CLI, and turn on the switch.

  2. Configure the tool rules by using one of the following editing modes:

Visual Editor

  1. Select the Visual Editor mode.

  2. Click Add Rule.

  3. In the rule configuration, select the target product, such as Ess - Auto Scaling.

  4. In the RAM Action area, select the authorization scope:

    • All API: The digital employee can call all authorized API operations for the product.

    • Specify RAM Action: Click Select Action to choose specific operations, or click Import from RAM to import existing permissions from the RAM role.

  5. Set the execution mode:

    • Auto Execute: The digital employee runs the tool without manual confirmation.

    • Ask for Confirmation: The digital employee asks for confirmation before each call. Use this mode for write or sensitive operations.

  6. Click OK.

Script Editor

Select the Script Editor mode to write the tool configuration in JSON format.

Configuration example:

{
  "enable": true,
  "statements": [
    {
      "decision": "user_ack",
      "product": "Domain",
      "apiVersion": "2018-01-29",
      "actions": [
        "domain:QueryDomain",
        "domain:QueryCommonInfo"
      ]
    }
  ]
}

Field

Description

enable

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

decision

The execution mode. Valid values: allow (auto-execute) and user_ack (ask for confirmation).

product

The product identifier that corresponds to the RAM code, such as Ess.

apiVersion

The API version of the product.

actions

The allowed RAM actions in <RAM Code>:<ActionName> format.

Entry 2: Configure an existing digital employee

  1. Go to the details page of the target digital employee.

  2. Click the Settings tab.

  3. In the left-side navigation pane, click Tool Execution.

  4. Configure the tool rules in either Visual Editor or Script Editor mode as described in the preceding sections.

Verify the configuration

After configuration, verify that Alibaba Cloud CLI works as expected by using one of the following methods.

Method 1: Trigger through a skill

In the SKILL.md file of a skill, specify the aliyun command for the target query or operation. The digital employee calls the corresponding CLI tool when it runs the skill.

Example skill description snippet:

**Verify instance exists and get basic information:**

```bash
aliyun ecs describe-instances \
  --biz-region-id <REGION_ID> \
  --region <REGION_ID> \
  --instance-ids '[\"<INSTANCE_ID>\"]'
```

Method 2: Test in the dialog

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

aliyun ecs DescribeInstances --RegionId cn-hangzhou
Note

During testing, set the execution mode to Ask for Confirmation so you can verify whether the tool is triggered correctly. After verification, switch to Auto Execute mode.

FAQ

A command fails after Alibaba Cloud CLI is configured

A command fails with the Forbidden.RAM error even though the API is already authorized in the Alibaba Cloud CLI tool rules. The error shows ImplicitDeny as the deny type and aliyunserviceroleforstarops as the current identity.

This error indicates that the RAM role associated with the digital employee does not have the RAM action that the API requires. Authorizing an action in the tool rules does not grant that permission to the RAM role.

To troubleshoot the issue, follow these steps:

  1. Check whether the RAM role associated with the digital employee is granted the RAM action that the API requires. For example, aliyun ecs RunCommand requires the ecs:RunCommand permission. For information about how to look up the RAM action of an API in OpenAPI Explorer, see the RAM role permissions section of this topic.

  2. Check whether the required permission is included in the default role. By default, a digital employee is associated with the AliyunServiceRoleForSTAROps service-linked role. Its system policy AliyunServiceRolePolicyForSTAROps grants only read-only permissions such as ecs:List*. Write permissions such as ecs:RunCommand are not included, so commands that modify resources are denied under the default permissions.

Important

The default service-linked role has the following limitations:

  • Service-linked roles do not support custom policies. Attaching a custom policy returns the NotSupport.ServiceLinkedRole error.

  • The role drop-down list on the digital employee configuration page shows only AliyunServiceRoleForSTAROps. Replacing it with a custom RAM role is not supported.