In many of my blog posts, I often have this as a given assumption or as a prerequisite to continuing and in some of them, I have brief snippets for how to set up your local operating system environment configured with all the installs, files, and keys so that you can do local development and use the AWS CLI against your Amazon Webservices account. I figured it might be helpful to have a dedicated article that acts as a quick reference to getting this setup that I can use in my future posts – and of course, also help as a reference in case you find the contents useful here as well.
This is all of course detailed in the AWS CLI docs – but this article is a hopefully a more concise how to guide than the encyclopedic treatment we are often subjected to by AWS’ documentation.
Now note one thing – the process is much quicker and also mostly operating system independent if you have Python installed on your local machine. But regardless, I will cover the alternatives.
Also note, I am still making one assumption – that you have access to an AWS account. Covering that is out of scope and definitely will not make this guide concise.
Create an AWS Access Key under your IAM user
AWS Access Keys are required for local development environments in order to do use the AWS CLI. They are also needed when using the various AWS SDKs. Creating one should be your first step.
Navigate to IAM on your account and select your user. Go to the Security Credentials tab and select create Access Key.
An Access Key and Secret will be created for you.
NOTE DOWN the access key secret as this will not be revealed again and if you lose it you will need to create a new key. Not a huge hurdle, but why repeat work?


Installing the AWS CLI libraries locally
This is based on your operating system – but is both fast and easy if you have and are familiar with the package installer for Python – pip. I will cover the major OS specific steps, and the Python way.
If you use Python
The process is the same whether you have macOS, Linux or Windows – open up a terminal window of your choice – in Windows this can be be either Git Bash or Command Prompt or wherever you run your standard Python command line terminal.
pip install awscli
Easy peasy. You are ready to move on to the setting up the credentials files – scroll below the OS specific steps in this section.
On Linux Operating Systems
Three steps to follow as shown below unless you want to change from the defaults (which I am not covering)
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
#or for ARM
curl "https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
On macOS
There is a GUI based installer – but in interests of keeping the setup as fast and concise as possible, I am not covering that. Just two quick command line steps to follow.
curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
sudo installer -pkg AWSCLIV2.pkg -target /
On Windows
Download and run the GUI installer – unless you have pip locally you have to do the msi download.
https://awscli.amazonaws.com/AWSCLIV2.msi
Verifying the AWS CLI installation
On all operating systems, open your normal choice of command line terminal and run the following to verify all is good installation wise.
aws --version
Assuming all is good – you have a small configuration setup to do next to hook up the CLI with your AWS Account using the Access Key you created
Creating your AWS credentials file
AWS SDKs and CLIs use your Access Key with secret to make connections to your AWS account. As long as the key is active and you have sufficient personal privileges to perform a particular action on your AWS account – things will work.
We will be creating a folder (or directory based on your terminology) titled “.aws” and under that we will need to create file titled “credentials” in one of these locations depending on your OS.
#Windows
C:\Users\<your_windows_username>\.aws\credentials
#Linux Based
~/.aws/credentials
As mentioned, I am working with all the AWS defaults here – if you need to use different locations to store your credential file, then make changes accordingly.
Adding your AWS Access Key and Secret to the credentials file
Inside your file, create the following replacing the Access Key, Secret and AWS region with your own values
[default]
aws_access_key_id = <ACCESS_KEY_ID>
aws_secret_access_key = <SECRET_KEY>
region=<YOUR_AWS_REGION>
This will become the default profile.
To add more (or not have a default) – simply add a profile name within the square braces. I personally like to name it by a reference to an AWS account so I know where I am running commands against.
[acme123_prod]
aws_access_key_id = <ACCESS_KEY_ID>
aws_secret_access_key = <SECRET_KEY>
region=<us-east-1>
[acme123_dev]
aws_access_key_id = <ACCESS_KEY_ID>
aws_secret_access_key = <SECRET_KEY>
region=<us-east-2>
And now you are all set to test if things worked
Testing connectivity from the AWS CLI to your AWS Account
To use any profile in your credentials file besides your default – you must first export (or set in windows) your profile name.
#Linux Based or using Git Bash on Windows
export AWS_PROFILE=acme123_prod
#Windows command prompt
set AWS_PROFILE=acme123_prod
Then lets run a simple command to list s3 buckets in your account.
aws s3 ls
And hopefully this worked for you.
Going from here
Of course play around with the CLI to get comfortable working with it.
For next steps, you can perhaps start getting familiar with AWS SAM to work with Cloudformation Templates or try something simple with the SDK.
If it suits your security needs, also see this article on setting up multifactor authentication with the AWS CLI.