Skip to content

CLI Tools

The AWS CLI tools are used for interacting with the AWS API on the command line. Here's a screenshot of what this can look like, for reference:

A new pipeline in detail

Here you're just looking at the results of the aws --version command followed by aws ec2 describe-instances.

The official documentation for the AWS CLI tools offers comprehensive coverage of any questions you might have, but let's go over installing the tools in our Ubuntu Virtual Machine.


There are two versions of the AWS CLI tools: v1 and v2. Install v2 to ensure you're using the latest release candidate and can follow along with any aws commands we use throughout this book.

Technically Speaking

In theory you don't actually need the AWS CLI tools to continue following through this book, but they're used and references so often in the real-world that it's important that you understand that they exist, how you can install them and how-to use them.


The quickest and easiest way to install the latest AWS CLI tools (v2) is using this single command:

curl "" -o "" && \
unzip && \
sudo ./aws/install

After that's complete you'll get a message along these lines:

You can now run: /usr/local/bin/aws --version

And if take this suggestion and run the command we get this (your results might vary slightly):

$ aws --version
aws-cli/2.2.31 Python/3.8.8 Linux/5.11.0-27-generic exe/x86_64.ubuntu.20 prompt/off

Pre-existing Install

If you've already got the latest v2 version of the tool, you'll see a message like this when installing:

Found preexisting AWS CLI installation: /usr/local/aws-cli/v2/current. Please rerun install script with --update flag.

You can move on and you'll be able to work with this book going forward.

Other Platforms

If you're not working with a Ubuntu VM like we are, then you'll have to find and follow the installation instructions that are relevant to your use case.

More platforms and details can be found in the official documentation.

Configuring Credentials

Now that you've (hopefully) installed the AWS CLI tools, you can run the infamous aws configure command (it's infamous in that you'll see it a lot in tutorials and around the Internet). This command is used to configure you like AWS configuration files, usually located at ~/.aws/config and ~/.aws/credentials.

The command is simple enough and the answers to the prompts is equally simple:

$ aws configure
AWS Access Key ID: 
AWS Secret Access Key: 
Default region name: 
Default output format: 

You're going to supply the details you got when creating your new IAM User in the previous section, with the exception of two of the prompts: the region and the output format.

For the region the answer will depend on your location. I'm in Brisbane, Australia, so Sydney is my closest region. I therefore pick ap-southeast-2 as my default region. It's the default region because it's selected when you perform tasks against the AWS API using either the tools we've just installed or Software Development Kit (SDK) that uses the AWS configuration. All this really means is you don't have to set a region every time - your default will be used unless you specify something else.

As for the output format: I simply press Enter and accept the default, which I believe is None which in turn means "plain text". There are other options but I've never found a need to change this value.

Once you've executed this command and provided details to the prompts you'll have two new files: ~/.aws/config and ~/.aws/credentials.

There's no need to cover these files in detail at this point. Instead let's move for now.


Now we're going to move into on the topic of Terraform.

Last update: August 24, 2021