×
☰ See All Chapters

How to configure AWS CLI

Step 1: Create AWS accessKey and secretKey to connect from CLI to AWS

Click on your account and select Security Credentials.

how-to-configure-aws-cli-0
 

Scroll a bit down and Click on “Create access key”

how-to-configure-aws-cli-1
 

Select the consent check box and click on “Create access Key”

how-to-configure-aws-cli-2
 

Once done, save the access key and secrete key in a secure place. The former serves the same function as a login name, and the latter acts like its password.

how-to-configure-aws-cli-3
 

Step 2: Configure AWS CLI

Open the terminal on your computer (PowerShell on Windows or a shell on Linux and macOS, not the AWS Management Console), and run aws configure. You’re asked for four pieces of information:

  1. AWS access key ID: Use the access key you saved from previous step 

  2. AWS secret access key: Use the secret key you saved from previous step 

  3. Default region name: Enter us-west-2 

  4. Default output format: Enter json 

In the end, the terminal should look similar to this:

how-to-configure-aws-cli-4
 

The CLI is now configured, It’s time to test whether the CLI works. Switch to the terminal window, and enter aws ec2 describe-regions to get a list of all available regions:

how-to-configure-aws-cli-5
 

Step 3: Test AWS CLI

Execute the below command to get a list of all running EC2 instances of type t2.micro so you can see what is running in your AWS account.

aws ec2 describe-instances --filters "Name=instance-type,Values=t2.micro"

how-to-configure-aws-cli-6
 

All Chapters
Author