Community Blog Cloud Automation Management with Alibaba Cloud Shell

Cloud Automation Management with Alibaba Cloud Shell

In this blog, we will discuss several ways to make cloud management more effective and automated through Alibaba Cloud's CLI and the Cloud Shell product.

By Afzaal Ahmad Zeeshan, Alibaba Cloud Community Blog author and Alibaba Cloud MVP.

A few decades back, businesses feared replacing human efforts with tools and services; they preferred relying more on human resources even for the trivial, labor-intensive, repetitive tasks unless forced otherwise-some due to the fact that humans were not fully utilizing the machine, and some due to the fact that some modern tools and software were not ready in the market.

However, this norm has greatly shifted in recent times, and businesses are adopting the practices which ensure high productivity involving fewer human efforts in a cost-effective budget. This adaptation is mainly based on automating the manual task or replacing expensive third-party tools and services with a few lines of automatic scripts written either in any scripting language such as python, ruby or batch/shell commands.

Note that if you are aware of basic software engineering principles, and how they help us build better software, such as Agile methodologies, or DevOps, then this article would be a great fun for you to read as we will explore the same concepts of automation and use Alibaba Cloud CLI to automate our tasks, whether it's on our own machines, in the browser or on our CI/CD servers.

Managing Alibaba Cloud Services Automatically

This article explains all the significant use-cases for when automating Alibaba Cloud services can yield better results than spending human resources and so many bucks on it. The primary reason to consider automation is to avoid the human friction. Agile methodologies always encourage the usage of automation scripts over manual tasks. You want to have your website deployed? Why not write a PowerShell or bash script that does that for you? Once we understand the benefits of automation for basic tasks-such as polling number of active users, or current CPU/RAM consumption-we extend the automations to a broader set of features and tasks. We start using the same automation tools and scripts, to automate more complex jobs, such as maintaining high-availability of our web servers, or migration of cloud resources from one region to another. The list goes on, but we will try to keep it very basic for you here.

The following are the generalized ways that commonly are offered by any cloud provider to manage all its services, preferably in one place.

Main Dashboard or Alibaba Cloud Portal

Alibaba Cloud portal is the most used and common way of monitoring the performance of your services and resources (which you are subscribed to) in a visualized and direct way-also it lets you create new resources right from your browser. You can enable different alerts with different events. Detailed reports, understandable monitoring logs, resource usage charts, and much other useful information is provided there. Teams can analyze these reports manually after some specified period and make some decisions mutually.

The problem with this approach is that since this is browser-based, someone must be available as a user to trigger the actions, thus creating a friction that demands the users to intervene and perform an action.

Note: I am aware that this can be automated using automation frameworks like Selenium, but that only makes tasks complex, prone to errors and less secure.

Supported SDKs Allowing Multiple Programming Languages

Another way of managing these cloud resources is the Alibaba Cloud's provided SDKs, which supports multiple languages. We can program the required automation functionality or use the available functions to automate our desired actions and event handling.

Alibaba Cloud Shell to Automate Cloud Resources

The third approach (which is also the main subject of this article) is to use a dedicated service provided by Alibaba Cloud that is Alibaba Cloud Shell. This is a cross-platform command-line service which allows you to manage Alibaba Cloud resources following a highly convenient and streamlined processes.

First, let me explain the few different ways of accessing the Alibaba Cloud CLI.

Launching Alibaba Cloud CLI

This shell service provided by Alibaba Cloud uses your base credentials or cloud access tokens to login and perform all the operations you intend to perform using shell scripts. The ultimate benefit is that the Cloud Shell allows you to write, manage, execute and view these commands by launching the command-line tool right from your web-browsers, making things flexible by killing the overhead of installing and managing anything at times when you must manage and view cloud resources.

The 2 ways to access the CLI are:

  1. Alibaba Cloud Portal
  2. Alibaba Cloud CLI


In the portal you can access the automation shell from the top right navigation menu-the shell icon is titled "Cloud Shell" if you access it from the menu. After it opens properly, you can execute the commands,


You can perform several commands on the Cloud Shell, for example here is a common command that I have executed showcasing the OSS buckets that my account currently has. For those of you who follow my articles, you will see that these are the same buckets I used in the article where I discussed the "hot vs. cold" data, remember?

Execute the following commands on your Cloud Shell instance:

$ aliyun oss ls


But this is not capable of automating the script in an automation environment-such as PowerShell, bash, or other integrated automation scripting environments.

Installing shell would be necessary when you want to execute automated jobs on your own virtual or physical machines, and to further automate the tasks. Ensuring certification and security policies while connecting to the Alibaba Cloud infrastructure as well as your own machine. On the other side, when you start a shell from your browser, a virtual machine with the admin rights is automatically allocated to your shell instance, Linux is the default running operating system on this machine which comes with pre-installed multiple native management and security tools.

You can download the Alibaba Cloud CLI from here, the command-line features are similar to what you will experience with the in-browser product. But you can extend the native CLI with other tools too.

Alibaba Cloud Shell ¨C Features and Benefits

Easy, Secure and Stable

Cloud Shell is handy to get started; there no pre-requisites and burdensome installation requirements. It comes with all the settings configured. For security and ease purposes, dedicated instances are provided to the user, where all resources require identity verification. In the same way, while working directly from the browser, a separate virtual machine gets created and destroyed every time you launch and close our CLI instance.

You can also consider saving your scripts on the cloud and running them from there-such as from the services like OSS-and that can help you further automate the jobs.

Range of Cloud Management Tools

Cloud shell provides a comprehensive list of pre-installed tools. These tools involve management tools as well as system control tools. For example, using CLI and Terraform, you can write API calls or directly call multiple cloud APIs for management purposes-a complete DevOps cycle can be implemented, or a regular clean up job can be performed on a data warehouse. Similarly, pre-installed system tools ensure ease in performing all the necessary tasks of daily infrastructure management.

Easy Maintenance Cost Reduction

With Cloud Shell, you can run commands to manage the Alibaba Cloud resources or services that you have purchased. You can also use shell scripts to schedule operation executions. It enables you to quickly and precisely execute management actions without using any development or maintenance systems. This reduces costs and the chance of human errors and friction during the development and deployment processes.

For creation, configuration, increasing and decreasing the active servers count, and many other operations which you perform daily or occasionally to manage all the cloud resources you have purchased, Cloud Shell gives you instant access to manage all these resources-just like we saw above, we can list the OSS buckets, but we can also perform actions, such as creating objects or deleting the objects that are older than a specific date-and the related tasks. Moreover, you can execute the automated scripts to perform core maintenance and deployment tasks too, following are some such use-cases:

  • To balance traffic load coming from any specific region or location, you can automatically up and run a server with specified configurations-the actual benefit of the load balancing and cloud automation!
  • Automated scripts can be written to download and install the required list of tools, per se, which are required to run your application on any of the configured machines-or you can use the backed-up copies of your VM and have your Cloud Shell create instances for VM using those copies.
  • An automated polling job can be written to examine the current status of already running server nodes, and pre-alerts can be configured in case of any expected failover such as crash or memory exhaust, and Cloud Shell can even take actions such as creating new instances or removing instances when no longer needed.
  • Your automated job can perform network configuration, such as Firewall settings, license management, and certification agreements can also be redeemed automatically.
  • For example, you have a bunch of automated scripts either to clean up memory, backing up your log file, or to perform stress testing on any of your recently changed settings in your application. The use case is to run all these individual automated scripts in a pre-defined order collectively and automatically.
  • You can schedule different maintenance and cleaning jobs; Start-of-day and End-of-day routines etc.

In a nutshell, automating your manual and time-taking management tasks using Cloud Shell gives you immense ease in managing cloud resources and their dependencies. This way, while writing your own automated scripts, you will have more control to make changes as per your requirement and company's standards. Also, huge amount of cost reduces in a time-efficient manner.

0 0 0
Share on


9 posts | 1 followers

You may also like



9 posts | 1 followers

Related Products