Install AWS CLI

Installation and Configuration

AWS Command Line Interface (AWS CLI) has two versions. In this guide, we will install AWS CLI v2 on both Windows and Ubuntu, as this version is simpler and more fully supported than AWS CLI v1.

  • AWS CLI version 1 (v1): The original version of AWS CLI, still supported by AWS.
  • AWS CLI version 2 (v2): The latest version, supporting all new AWS features. Some features are only available in v2 and not in v1.
  1. Install AWS CLI
  • For Linux:
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
  • For Windows:
msiexec.exe /i https://awscli.amazonaws.com/AWSCLIV2.msi
  • For macOS:
sudo ln -s /folder/installed/aws-cli/aws /usr/local/bin/aws
sudo ln -s /folder/installed/aws-cli/aws_completer /usr/local/bin/aws_completer
  • In this workshop, we will install on Linux environment, using MobaXterm software.

AWS CLI

AWS CLI

  1. Verify AWS CLI installation:
aws --version

AWS CLI

  1. Create Default Profile

Use the aws configure command to set up AWS CLI. This command will prompt you to enter important information:

  • Access Key ID
  • Secret Access Key
  • AWS Region
  • Output format
aws configure

Enter the Access key ID and Secret Access Key of aws-cli-user, keep the remaining values as default:

AWS Access Key ID [None]: *aws-cli-user_Access Key ID*
AWS Secret Access Key [None]: *aws-cli-user_Secret Access Key*
Default region name [None]: *ap-southeast-1*
Default output format [None]: *json*

AWS CLI

This configuration is saved in the credentials file under the default profile. The default profile will be used by AWS CLI if no other profile is specified.

  1. Configure multiple profiles

To create another profile, for example devops, use the following command, enter the Access Key ID and Secret Access Key of the devops user, keep the remaining values as default:

aws configure --profile devops

AWS CLI

The profile contains Access Key ID and Secret Access Key to sign requests sent to AWS.

  1. Check profile configuration
aws configure

AWS CLI

  1. Check credentials information
cd ~/.aws/
ls
cat config

AWS CLI

  1. Check profile region
aws configure get region --profile devops

AWS CLI

  1. List configuration
aws configure list

AWS CLI

  1. List profiles
aws configure list-profiles

AWS CLI

You can edit or add profiles by directly updating the config and credentials files with a text editor on your operating system.