Use Alibaba Cloud CLI to manage Tair (Redis OSS-compatible) resources
Alibaba Cloud CLI is a command-line tool built on OpenAPI. You can use it to call Tair (Redis OSS-compatible) API operations and manage Tair (Redis OSS-compatible) instances. The following example shows how to query Tair (Redis OSS-compatible) instances in a specific region.
Before you begin
Familiarize yourself with Alibaba Cloud CLI. For more information, see What is Alibaba Cloud CLI?
For complex tasks that involve multiple API operations, we recommend that you compile the commands into a shell script to improve efficiency.
Create a RAM user and grant permissions to the RAM user
If you have created a Resource Access Management (RAM) user and granted permissions to the user, you can skip this step.
-
To create a RAM user, perform the following steps:
-
Go to the Users page of the RAM console, and then click Create User.
-
Set Logon Name to redis-openapi-operator and Access Mode to Using permanent AccessKey to access.
-
Click OK. After the RAM user is created, save the AccessKey ID and AccessKey secret of the RAM user.
-
-
To grant permissions to the RAM user, perform the following steps:
-
Go to the Users page, find the RAM user that you created, and then click Add Permissions in the Actions column.
-
In the panel that appears, enter
AliyunKvstorein the search box and then select the AliyunKvstoreReadOnlyAccess policy.NoteThe AliyunKvstoreReadOnlyAccess policy provides read permissions on Tair instances, and the AliyunKvstoreFullAccess policy provides read and write permissions on Tair instances. You can also specify a custom policy based on your business requirements. For more information, see Identity management.
-
Click Grant permissions.
-
Install Alibaba Cloud CLI
You can also use Cloud Shell to debug Alibaba Cloud CLI commands online. For more information, see What is Cloud Shell?
Generate a CLI command
-
Go to the Debugging page of DescribeInstancesOverview in OpenAPI Explorer.
-
On the left-side Parameters tab, specify the required parameters. In this example, specify cn-hangzhou for the RegionId parameter.
-
Click the CLI Example tab in the right-side pane to view the CLI command that is generated with the specified parameters.
For example, the generated CLI command is
aliyun r-kvstore DescribeInstancesOverview --region cn-hangzhou --RegionId 'cn-hangzhou'.-
Click the
icon to open the command in Cloud Shell for debugging. -
Click the
icon to copy the CLI command to your clipboard, and then paste it into your local shell to run. Note-
When you paste the CLI command into your local shell for debugging, take note of the parameter formats. For more information about the parameter formats of Alibaba Cloud CLI commands, see Parameter formats.
-
By default, OpenAPI Explorer adds the
--regionoption to the generated CLI command. This overrides the region in the default identity credential and environment variable configurations. You can remove or keep this option based on your requirements.
-
-
Example
The following example calls the DescribeInstancesOverview operation to query instances in the China (Hangzhou) region (cn-hangzhou). For more information, see Generate and run CLI commands.
-
Run the following command:
aliyun r-kvstore DescribeInstancesOverview --region cn-hangzhou --RegionId 'cn-hangzhou' -
View the command output.
{ "Instances": [ { "ArchitectureType": "cluster", "Capacity": 1024, "ChargeType": "PostPaid", "ConnectionDomain": "r-bp1y****svonly41sr.redis.rds.aliyuncs.com", "CreateTime": "2023-11-27T05:42:50Z", "EngineVersion": "6.0", "InstanceClass": "tair.rdb.cluster.sharding.common", "InstanceId": "r-bp1y****svonly41sr", "InstanceName": "yaluTest", "InstanceStatus": "Normal", "InstanceType": "tair_rdb", "NetworkType": "VPC", "RegionId": "cn-hangzhou", "ResourceGroupId": "rg-acfm****zzrngoa", "VSwitchId": "vsw-bp1g****keaw3xvndvvz0", "VpcId": "vpc-bp1o****4yvz4kxeik3uu", "ZoneId": "cn-hangzhou-k" }, { "ArchitectureType": "cluster", "Capacity": 1024, "ChargeType": "PostPaid", "ConnectionDomain": "r-bp1s****lvbzmgedgj.redis.rds.aliyuncs.com", "CreateTime": "2024-03-04T05:08:46Z", "EngineVersion": "6.0", "InstanceClass": "tair.rdb.cluster.sharding.common", "InstanceId": "r-bp1s****lvbzmgedgj", "InstanceName": "LidTest", "InstanceStatus": "Normal", "InstanceType": "tair_rdb", "NetworkType": "VPC", "RegionId": "cn-hangzhou", "ResourceGroupId": "rg-acfm****zzrngoa", "VSwitchId": "vsw-bp12****3z4zu9k4dhaew", "VpcId": "vpc-bp1o****4yvz4kxeik3uu", "ZoneId": "cn-hangzhou-k" } ], "RequestId": "0E89ADAB-D582-5F49-9D7F-F482D15BE426", "TotalCount": 2 }