How to install and configure AWS CLI on MAC

Step 1: Download the aws cli installer package file

Download it via following link: https://awscli.amazonaws.com/AWSCLIV2.pkg.

The installation of aws cli will be done at the following location:

/usr/local/aws-cli

The installer will automatically create a symlink at following path:

/usr/local/bin/aws

Run the following command to further command the location of installation:

which aws

That will give you the following output: /usr/local/bin/aws

Step 2: Configure AWS CLI

Before moving ahead with AWS CLI configuration, make sure you have the following keys with you:

  • AWS Access Key ID: <Your IAM user AWS Access Key ID>
  • AWS Secret Access Key: <Your IAM user AWS Secret Access Key>
  • Default region name: <Your AWS region, like us-east-1>

Run the following command to configure aws cli:

aws configure

Enter the values asked by aws cli prompt, example:

AWS Access Key ID [None]: AWEDSFUAQN7DQGHU6E4U
AWS Secret Access Key [None]: AERT/lnQpERFSSYLQ7ERT
Default region name [None]: us-east-1
Default output format [None]: json

The AWS Access Key ID and AWS Secret Access Key will be different for your IAM user with which you want to login into AWS CLI.

The configure command will create a new folder at the following location:

~/.aws

That folder will contain the following two files:

  1. config
  2. credentials

Verify the content of those two files. The config will have the text like this:

[default]
region = us-east-1
output = json

and the credentials file will have your keys:

[default]
aws_access_key_id = AWEDSFUAQN7DQGHU6E4U
aws_secret_access_key = AERT/lnQpERFSSYLQ7ERT

Run any aws command against aws to verify that the set up was done correctly, you can run the following command :

aws s3 ls s3://YOUR_BUCKET 

Put any bucket path in place of YOUR_BUCKET in the above command. If it gives you the list of files that means the set up was done correctly.