AWS CLI Tutorial – How to Install, Configure and Use AWS CLI
- CourseWizz
- Sep 3, 2023
- 3 min read
Updated: Sep 20, 2023

Install
Installing the AWS CLI is dead easy. Your best bet is heading over to this AWS webpage which gives you detailed instructions on how to get started for each operating system.
But, if you're on a Mac 💻 like me then stay here! 😉
Step 1: Copy and paste the following into your terminal:
curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
sudo installer -pkg AWSCLIV2.pkg -target /
What does this do? Well the first command uses the curl command line tool to download the AWS CLI package from AWS.
The second command then installs the AWS CLI package using the built in Mac installer.
Step 2: Check installation was successful:
To make sure AWS CLI is correctly set up in your $PATH, run the "which aws" command to print out the location of install.
Now run "aws --version" to check the CLI itself is working (you should see the cli version printed out).
which aws
aws --version

How easy was that?
Configuration
Head over to the AWS console, sign in and complete the following steps. If you haven't already made an AWS account check out this CourseWizz tutorial.
Step 1: Click on the Account name dropdown.

Step 2: Click on Security and Credentials

Step 3: Click on Create Access Key button:
This will create a root user Access Key. In practice you should create IAM roles and assign least privileged permissions and generate keys for each role.

Step 4: Confirm you are happy to create key and click Create access key button

Step 5: Success, you now have both Access Key and Secret Access Key:
Keep these (especially the secret) stored securely. After clicking done you will no longer be able to access the secret key!

Back to the Terminal
Now we have everything we need to configure the AWS CLI. Open your terminal back up and type in the following command:
aws configure

I have already completed the configure step hence it shows my obscured keys. But those doing it for the first time will need to:
1) Copy and Paste Access Key
2) Copy and Paste Secret Access Key
3) Specify default AWS region
4) Specify default output format. I choose json as it's my preferred although there are other options like standard text and yaml
Congratulations, you should now be configured to use the AWS CLI 🎉
Use
So what can i do with the newly installed AWS CLI?
You can do pretty much everything that can be done in the online AWS Console. But now, instead of opening up your browser and signing in, you can open the terminal and get straight to it.
Let's do something with it...
We will start simple, let's create a private S3 bucket called coursewizztestbucket and we are going to upload a something.txt file to it.
Type the following into the cli:
aws s3api create-bucket
--bucket coursewizztestbucket
--region eu-west-2
--create-bucket-configuration LocationConstraint=eu-west-2
This command tells AWS CLI to use the create-bucket function of the S3 api. Additional options can be provided, options are denoted by -- and the following string is the value.
In this example we included --bucket --region --create-bucket-configuration. These are the minimum required options to create an S3 bucket.
If your bucket has been successfully created you will expect to see a JSON object with the location property printed:

Great now we've made a bucket!
It looks quite empty, shall we put something inside?
Create a text file called "something.txt" and open the editor in the terminal.
touch something.txt
nano something.txt
"touch something.txt" creates a new file called something.txt.
"nano something.txt" opens nano, which is a terminal based editor. Now we can write something.

To exit nano:
Press Ctrl x which will ask if you want to keep file changes. Press y for yes.
Now you will be asked what filename you want to write to, it should be pre-filled with something.txt, so press enter.


Now we want to upload something.txt to our newly created S3 bucket.
Lets enter the following command:
aws s3api put-object
--bucket coursewizztestbucket
--body something.txt
--key something
This time we are using put-object of the S3 api which uses a HTTP PUT request to upload a blob (our file something.txt) to S3. The options passed are bucket (specifies the bucket), body (file we are uploading) and key (unique name or id for the object in S3). See here for the full documentation of put-object.
If the upload was successful you should expect to see a JSON response with ETag and ServerSideEncryption properties printed like so:

Now we have a bucket that is filled with something 😄
Summary
As you can see using the AWS CLI is nice, fast and easy! With some practice, you'll master the AWS APIs, allowing you to swiftly launch instances, upload files to S3, or handle any other task with ease.
For comprehensive AWS CLI guidance, refer to the AWS User Guide - especially if you're not yet an expert!
Frequently Asked Questions
What is the AWS CLI?
The AWS CLI (Command Line Interface) is a unified tool to manage your AWS services. Using the CLI, you can execute commands in your terminal to perform AWS tasks, like launching and managing EC2 instances or managing data in S3 buckets.
Why should I use the AWS CLI over the AWS Management Console?
The AWS CLI provides a way to automate tasks through scripts and offers a consistent interface regardless of the AWS service you're using. While the Management Console is user-friendly and visual, the CLI can be more efficient for repetitive tasks, bulk actions, or when you need to integrate AWS operations into scripts or other tools.
How do I update the AWS CLI?
Depending on how you installed the AWS CLI, you can typically update it using a package manager like pip for Python installations. Always refer to the official AWS documentation for specific instructions.
Is the AWS CLI free to use?
While the AWS CLI tool itself is free to download and use, executing commands that interact with AWS services may incur costs. Always make sure to understand the pricing for the specific AWS services you're interacting with.
Can I use AWS CLI on any operating system?
Yes, the AWS CLI is available for Windows, macOS, and Linux. Installation procedures vary slightly between operating systems.
How do I troubleshoot issues with the AWS CLI?
The AWS CLI provides error messages and logs to help identify issues. Additionally, you can increase the command output verbosity (e.g., --debug) to get more detailed information. The official AWS documentation and AWS forums are also great resources for troubleshooting.
Is there a way to autocomplete commands in AWS CLI?
Yes, the AWS CLI supports command completion for bash, zsh, and fish shells. This feature can save time by helping you quickly fill in commands and arguments.
How secure is it to use AWS CLI?
AWS CLI uses the same underlying security mechanisms as the AWS SDKs and the AWS Management Console. Always ensure you protect your access and secret keys and avoid hardcoding them in scripts. Consider using IAM roles and AWS CLI profiles to manage access securely.
Can I use AWS CLI in conjunction with AWS SDKs?
Absolutely! While the AWS CLI is built using Python (repository), you can use it alongside other AWS SDKs for different programming languages to build and manage your AWS applications.
Where can I find more advanced AWS CLI tutorials?
The AWS official documentation is a comprehensive resource for both beginners and advanced users. AWS also offers training and certification courses that dive deeper into specific services and use cases.
Comments