Alibaba Cloud CLI is a command-line tool built on OpenAPI. You can use it to manage ApsaraDB RDS instances from a shell. Learn how to install and configure the CLI and call ApsaraDB RDS APIs.
Prerequisites
New to Alibaba Cloud CLI? Start with What is Alibaba Cloud CLI?.
Install Alibaba Cloud CLI
Install Alibaba Cloud CLI for your operating system:
-
Windows: Install the CLI on Windows.
-
Linux: Install or update the CLI.
-
macOS: Install the CLI on macOS.
You can also debug CLI commands in Cloud Shell. What is Cloud Shell?
Configure Alibaba Cloud CLI
Your Alibaba Cloud account has full API access, which poses a security risk. Create and use a RAM user instead. Attach AliyunRDSReadOnlyAccess for read-only access or AliyunRDSFullAccess for full control over ApsaraDB RDS.
Configure your identity credentials, default region ID, and other settings before using the CLI. The CLI supports multiple credential types (Configure and manage identity credentials). This example uses AccessKey credentials.
-
Create a RAM user and grant the required service permissions (Manage RAM user permissions).
NoteApsaraDB RDS permission policies: Use RAM to implement access control.
-
Create an AccessKey pair for the RAM user. Record the
AccessKey IDandAccessKey secretfor credential configuration. -
Choose a region ID. The CLI sends API calls to the specified region. Available regions: Endpoints.
NoteThe
--regionoption overrides the default region in your credential configuration and environment variables. Command-line options. -
Configure AccessKey credentials under a profile named
AkProfileusing the RAM user's AccessKey pair. Configure and manage identity credentials.
Generate a sample CLI command
-
Go to the ApsaraDB RDS API reference in OpenAPI Explorer.
-
Search for the API in the left-side search box. On the Parameters tab, enter the required values. Next to the Parameters tab, click CLI Example to generate a sample command.
-
Click the
icon to open Cloud Shell and debug the command. -
Click the
icon to copy the CLI example to the clipboard. You can then paste it into your local shell to run it.-
When pasting a CLI example into your local shell, verify the parameter format. Understand command parameters.
-
OpenAPI Explorer adds a
--regionoption to sample commands by default, which overrides the region in your credentials and environment variables. Keep or remove it as needed.
-
-
Call cloud service APIs
Command structure
CLI commands follow this structure (Generate and call a command):
aliyun <command> <subcommand> [options and parameters]
Common command-line options
Use command-line options to modify command behavior or add functionality.
-
--profile<profileName>: Uses the specified profile, overriding default credentials and environment variables. -
--help: Displays help information for a command. Get help.
Examples
Example 1: List available ApsaraDB RDS APIs with --help. You can also check the API overview.
-
Run the command.
aliyun rds --help -
View the command output.
Example 2: Call the DescribeDBInstanceAttribute API to query instance details.
-
Run the command.
aliyun rds DescribeDBInstanceAttribute --region cn-hangzhou --DBInstanceId 'pgm-bp16k272p478****' -
View the command output.
NoteIf an API call fails, check the error code to verify your request parameters.
Use the request ID or error message with Alibaba Cloud OpenAPI Diagnostics to diagnose the issue.