Command Structure
Start course

This course introduces you to the AWS Command Line Interface. 

Learning Objectives

  • Install and configure the AWS Command Line Interface
  • Manage CLI credential profiles
  • Structure CLI commands
  • Better control the outputted response data
  • Use input functionality to make working with the CLI easier  

Intended Audience

  • Those looking to get more familiar with the AWS Command Line Interface



Once you have credentials set up, it’s time to use the AWS CLI. Remember, with the CLI, all you’re doing is making API calls that are structured using a particular syntax. The syntax is as follows: 

Each command is broken up into four parts. The first part that remains consistent regardless of the command you type is the “aws” keyword. This is how the CLI knows you’re calling AWS. 

The second part is the service you’re calling, such as EC2, DynamoDB, S3, and more. 

Then you have the operation, which is the API call you’d like to make. For example, if you want to list your EC2 instances, you would use the describe-instances API call. Or if you wanted to create a dynamoDB table, you’d want to use the aws dynamodb create-table operation. 

After the operation, is the final part, which is the parameters you write to that API call. These parameters change based on the operation you run. For example, if you ran the ‘aws dynamodb create-table’ command, you would specify a parameter of ‘--table-name’, then you can specify a table name, such as cars. Or if you wanted to list details about a particular EC2 instance, you would use the ‘aws ec2 describe-instances’ operation with a parameter to specify the instance id using –instance-ids, and then specify an instance id.

Notice that each of these parameters is prefixed by two dashes.

All right, let’s take one of these commands and run it in the terminal. For example, I’ll run aws ec2 describe-instances –instance-ids and then I’ll specify an instance ID I know is in my account.   

Once I press enter and run this command, I get a response in the default output format that I specified in my default profile. In this case, you can see the output is in the YAML format, and it lists all details regarding the instance that has the ID that I specified. By pressing the down key or enter, I can go through each line of the response. Then, I can press the letter q to exit the response.

If you get stuck with structuring commands at any point, there is help functionality built into the CLI. For example, you can type in aws help and it will provide you a list of options, as well as a list of services you can use.

You can scroll on this list and see that there’s a service you may want to use in the future. Here, I see the service CE. Maybe I don’t know what that's abbreviated for - so I can take the help functionality one step further and use it with the service, so now the command would be ‘aws ce help’. This will provide a list of all operations I can perform with the service. 

You can then even take this one step further, and use help on the operation. Let’s take the first operation in the list, in this case, create-anomaly-monitor and use the command ‘aws ce create-anomaly-monitor help’. Then you can see what parameters this operation takes and any additional information about the operation you may need to know. 

So if you ever need some light bedtime reading, consider reading through the descriptions for one of these parameters - this information will definitely put you straight to sleep. Okay, that’s all for this one - see you next time. 

About the Author
Learning Paths

Alana Layton is an experienced technical trainer, technical content developer, and cloud engineer living out of Seattle, Washington. Her career has included teaching about AWS all over the world, creating AWS content that is fun, and working in consulting. She currently holds six AWS certifications. Outside of Cloud Academy, you can find her testing her knowledge in bar trivia, reading, or training for a marathon.