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 Cloud Academy.com's video series on AWS-CLI, the Amazon web services command line interface. This video will explore using the AWS-CLI to interface with your databases. We're going to look at two database types. DynamoDB is a no-SQL storage layer while RDS, relational database services, provides access to relational storage. We'll first look at DynamoDB. AWS DynamoDB list tables will list all the tables using DynamoDB that are currently on our system. There are none, which of course means we are going to have to create one. So let's paste this really long command line and try to break it down as clearly as we possibly can.
There are other ways of manipulating DynamoDB databases on AWS. You can use their web console. You can also create json files and cull the json files from the command line. This is a video series on the command line so we have to show you how to do it this way. AWS DynamoDB tells the system that we're going to use the AWS environment and DynamoDB within that environment. Create-table tells DynamoDB that we, of course, want to create a table. Its name will be clients. Its attribute definitions, that is the records that it's going to store, are defined as companyname and industry. We also need to specify key schema, either hash or range.
Let's see how this one works. Well we seem to have created the database. Of course, it's still empty. Let's populate it. This command will, as you can see, put an item, the following item, into the table name clients. The item is defined as data where company name is Sink Hole Industries and industry is financial advice. Let's try that. Seems to have worked. Let's do one more just to be complete. In this case, the company name will be Acme Widgets and the industry will be manufacturing. We seem to have two records now in our database, but at this point we haven't yet confirmed they're actually there. To do that, we can use AWS DynamoDB scan, table name; clients. We see our data is now properly stored in the database, which leaves us only one thing left to do, and that's clean up the mess we've made by deleting the database. You see the table status is deleting. It's not yet gone and we can show that it's not yet gone by once again running list tables. Clients is still there but within a few minutes, the table will be completely cleaned up and the list tables will return nothing. Now let's explore RDS. The command line here is just so long that I've put it into a script and we'll take a look at it in the script.
Rds.sh is the name of the script. I actually applied CHMOD, change mode, plus X and then the name of the script in order to make it executable. However, let's take a look line by line at the script. AWS RDS tells AWS we're going to use the RDS interface, relational database server.
Create database instance; the first argument is DB name, and we've called it our data. It could be any name you like but it is, along with these other six arguments, necessary. There are other arguments, by the way, that you could add.
At least 20 of them but these are the critical ones. The second argument; DB instance identifier has to be a unique name, our-db instance, in our case, that's what I chose. The third line; allocated storage, five gigabytes. That is, we are requesting five gigabytes of available storage. It could be one gigabyte, it could be 1,000 gigabytes, but you have specify how large your database could be.
The next line: DB instance class will be db.t1.micro. That is the smallest class of database server that we can use.
Obviously, if you want to see what other options are available, go to the browser console on the AWS website and you can browse through the complete list. The engine we're going to use, which database program are we going to use? In our case, MySQL. There are a number of other options. The master username must be selected. In our case, I just chose dbmaster.
And finally master user password. I've actually typed in the real password, verysecret. But you can be sure this database will be long destroyed before you're watching this video. That's the script. Control, X, delete. Now let's run the script; rds.sh. Everything seems to be working. There's nothing much else we can do from this end. Your job now is to go into your EC2 instance and link to and make use of the database from there.
There's one more piece of information, however, you're going to need that you don't yet have. That is, the end point, the URL you're going to use in your EC2 instance to access this particular database. Let's see if we can find it.
Let's run AWS RDS describe-db-instances to find our end point. It's not there and it won't necessarily be there for a couple of minutes. It takes a little while for the database to actually get up and running.
We'll try again in just a minute. That's it. We now have an end point. We're all set to go to our EC2 instance. Use this end point and the port 3306 to access the database. The only thing left for us now is to remove the database. This one will be of no value and its password, I'd say, is just a little bit compromised. Let us run aws.rds-delete-db-instance. DB instance identifier is our DB instance, which is the identifier, the ID, of this instance. But, we have to add the argument; skip final snapshot because there is another theoretical value that your instance could have called a final snapshot and delete DB instance would normally wait for that. We choose to skip it and just go with our DB instance as an identifier. The database is on the process of being shut down.
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.