AWS CLI is a tool that pulls all the AWS services together in one central console, giving you easy control of multiple AWS services with a single tool. The acronym stands for Amazon Web Services Command Line Interface because, as its name suggests, users operate it from the command line. With it, you can control services manually or automate them with powerful scripts.
AWS is a secure cloud services platform that offers computing power, content delivery, database storage, and other infrastructure services for developers. Proponents point to its speed, flexible pricing, exemplary customer service, and a huge variety of services as benefits. The AWS CLI puts the icing on the cake by tying control of all those services together into one simple command line interface. It cuts out the user-friendly (but time-consuming, according to some) step of interacting with the system through a Graphical User Interface (GUI).
You can install the tool by downloading it from the AWS CLI resource page at Amazon. The page has download options for Windows, Mac, and Linux installations. It also has a beginner’s guide, a comprehensive reference manual, a user forum and a link to the GitHub project. Here are the install tools offered by Amazon:
To install AWS CLI, users sign up for an AWS account, get an access key ID and secret access key, then pick a (very simple!) install method depending on their system and software.
Those with a pip/Python system can simply run:
$ pip install --upgrade – user awscli
Amazon’s install documentation here also explains options to install Python/pip/CLI on linux, and how to install AWS CLI on MS Windows, macOS, or in a Virtual Environment. There’s also an option to install the tool with the Bundled Installer for Linux, Unix, or macOS. Overall, the install steps are as simple as downloading the archive, unpacking it, running the (short) install script and checking your work. There’s a great example tutorial here.
The following examples show the interface in action performing various tasks and demonstrate how powerful it can be.
The Amazon S3 service is Amazon’s Simple Storage Device. It provides basic online data storage in a pay-for-what-you-use plan. The data are stored in buckets. When using the standard GUI, deleting a bucket with several files and folders can be somewhat time-consuming. By using the AWS CLI, you can perform this task in just a few seconds with a single command:
$ aws s3 rb s3://bucket-name --force
Amazon Elastic Compute Cloud or EC2 is an Amazon web service that delivers simple web-scale cloud computing for developers. The example below shows how the command line tool makes it easy to start multiple EC2 instances.
$ aws ec2 start-instances --instance-ids i-4j3423ie i-32u89uf2
When you’re managing several EC2 instances, listing instances that have stopped and showing reasons for each can be a little problematical with the standard GUI. The example below shows how to use AWS CLI (and jq) to do this easily:
aws ec2 describe-instances --filters Name=instance-state-name,Values=stopped --region eu-west-1 --output json | jq -r .Reservations[].Instances[] .StateReason.Message
One of the main benefits is the ability to save substantial time. The savings comes in the form of easier installs, support of all services from one tool, moving beyond GUIs, and automating processes and commands with shell scripting.
Since the interface is a controller for all of Amazon’s web services, best practices for using it well are largely the same as those for AWS as a whole. Amazon has produced an avalanche of good documentation on its best practices that could fill a mass market paperback. The list contains best practices for architecting, web app hosting, security, email, IAM, DynamoDB, EC2, and Trusted Advisor. Below is a list of the top five best practices from programmer analyst Michael Sheehy.
For additional info and help with the interface, see the short list of resources below.
The Amazon Web Services Command Line Interface is a powerful tool to help you manage powerful cloud services. But Amazon isn’t the only cloud service around; in fact, at Stackify, we’re big fans of Azure and built our powerful APM solution, Retrace, with Azure in mind. If you’re on the fence about cloud providers, check out our Azure vs. AWS comparison.
If you would like to be a guest contributor to the Stackify blog please reach out to [email protected]