Introduction to the AWS Command Line Interface
Using the AWS Command Line Interface
Although most AWS services can be managed through the console in Amazon's browser interface or via the APIs commonly used for programmatic access, there is a third way that, in many cases, can be very useful: the Command Line Interface (CLI). AWS has made software packages available for Linux, MacOS, and Windows that allows you to manage the main AWS services from a local terminal session's command line.
In this course, the Cloud Expert and Linux System Administrator David Clinton will tell you everything you need to know to get started with the AWS Command Line Interface and to use it proficiently in your daily operations. He will also provide many examples to clearly explain how command line connectivity really works.
Who should take this course
This is an intermediate course, as such you should already know the basic AWS concepts, and in particular of the services that described in this tutorial. Also, some experience with the Linux Command Line Interface is not strictly speaking necessary, but still quite useful.
If you want to boost your knowledge of AWS, EC2, S3, and RDS, we strongly suggest you take our other AWS courses. Also, self-test questions are available if you'd like to test and increase your knowledge.
If you have thoughts or suggestions for this course, please contact Cloud Academy at firstname.lastname@example.org.
Hi, and welcome to CloudAcademy.com's video series on the AWS-CLI, the Amazon Web Services Command Line Interface package. In this video, we'll discuss controlling output. The CLI, the Command Line Interface can return all kinds of important information, but you've got to be able to manage it for it to be useful.
AWS has some powerful tools to help you do that. As we mentioned in an earlier video, the .aws/config file, that is the file called config in the hidden directory aws in your home directory controls the default output format. It gives you three choices, JSON, text, or table. Generally JSON format is best for programming, it interfaces very well with programming languages. Text is best for scripting languages, and table format is best for human beings who actually want to read the downloaded data in a console. Each one obviously has it's use scenarios. There's another way however, to control the default output format, and that is using export. Let's try export aws_default_output=text. Now, let's query the IM data on my account, aws im list users. Which provides us with a easily readable, column defined printout of my user data. These four users, by the way, don't really exist, they were four rather common names I just used for convenience sake. Let's however do this again, using table instead of text as our default output. And once again, let's query IM.
This gives us the exact same data, just in a table format. One more time, rather than table, let's get the data as JSON. And one more time, we're gonna take the same data and it provides us with the output in an easily JSON readable format. Now let's see if we can take this JSON output and select only certain data points for printing. In this case, we'll begin with again aws im list users, but now we add the argument query, --query. We look to organize the data by users, after all the main category by which the data is already organized is under users. And we are going to take every username and every create date, and present that next to a title name and a title create date. So we have retrieved data concerning all four of our users, but only their create date, the date the accounts were created, and their names.
Let's try one more version of this organization of data. In this case, we're using the same --query argument, but rather than including the titles of each data field, name and create date, we will enclose the fields we're looking for in square brackets rather than curly braces.
And leave out the title, rather than name:username, it's going to be just username and then comma, and then create date, which will present us with the same data, just without the titles. Either way you see just the tip of the iceberg of the versatility that Amazon provides you with in managing just the data that comes from their interface. One more point, Amazon does advise the --query argument to be used primarily with text output format rather than JSON output format. It is, when you take into account the many platforms and configurations that it could be used in, more reliable. In other words, using text, you're more likely to get precisely the results you expect, rather than using JSON.
David taught high school for twenty years, worked as a Linux system administrator for five years, and has been writing since he could hold a crayon between his fingers. His childhood bedroom wall has since been repainted.
Having worked directly with all kinds of technology, David derives great pleasure from completing projects that draw on as many tools from his toolkit as possible.
Besides being a Linux system administrator with a strong focus on virtualization and security tools, David writes technical documentation and user guides, and creates technology training videos.
His favorite technology tool is the one that should be just about ready for release tomorrow. Or Thursday.