Configure Alibaba Cloud CLI
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:GetRoleram:ListPoliciesForRoleram: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.
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:
Identify the CLI tool that requires authorization, such as
aliyun elasticsearch ListAllNode.Go to the OpenAPI Explorer and search for the API name, such as
ListAllNode.On the API documentation page, find the Authorization Information section. The Action column shows the required RAM action.
Add the RAM action to the RAM role policy.
Example
To authorize the aliyun elasticsearch ListAllNode tool:
Incorrect: Granting
elasticsearch:ListAllNodedirectly fails because this RAM action does not exist.Correct: The OpenAPI documentation for the Elasticsearch service shows that the
ListAllNodeAPI requires theelasticsearch:DescribeInstanceRAM 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
In the digital employee creation flow, go to the Tool Execution step, find Alibaba Cloud CLI, and turn on the switch.
Configure the tool rules by using one of the following editing modes:
Visual Editor
Select the Visual Editor mode.
Click Add Rule.
In the rule configuration, select the target product, such as Ess - Auto Scaling.
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.
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.
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 |
| Specifies whether to enable Alibaba Cloud CLI. Set to |
| The execution mode. Valid values: |
| The product identifier that corresponds to the RAM code, such as |
| The API version of the product. |
| The allowed RAM actions in |
Entry 2: Configure an existing digital employee
Go to the details page of the target digital employee.
Click the Settings tab.
In the left-side navigation pane, click Tool Execution.
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-hangzhouDuring 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:
Check whether the RAM role associated with the digital employee is granted the RAM action that the API requires. For example,
aliyun ecs RunCommandrequires theecs:RunCommandpermission. 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.Check whether the required permission is included in the default role. By default, a digital employee is associated with the
AliyunServiceRoleForSTAROpsservice-linked role. Its system policyAliyunServiceRolePolicyForSTAROpsgrants only read-only permissions such asecs:List*. Write permissions such asecs:RunCommandare not included, so commands that modify resources are denied under the default permissions.
The default service-linked role has the following limitations:
Service-linked roles do not support custom policies. Attaching a custom policy returns the
NotSupport.ServiceLinkedRoleerror.The role drop-down list on the digital employee configuration page shows only
AliyunServiceRoleForSTAROps. Replacing it with a custom RAM role is not supported.