home tools books contact

How to Install and Configure the AWS CLI on a Mac

The AWS CLI is a command line utility that lets you deploy and configure services on Amazon Web Services without needing to use the web user interface. This tutorial, will show you how to install it on a Mac and how to configure a user.

Advertisement

Introduction

The AWS CLI can be installed on macOS using the command line or by using the installer wizard. This tutorial will show you how to install it using the installer wizard.

Step 1: Install AWS CLI

Download the latest Amazon CLI installer package from the Amazon Website.

Double click on the downloaded AWSCLIV2.pkg package to start the installer.

Install AWS CLI 2 - Step 1

Click Continue.

Install AWS CLI 2 - Step 2

Click Continue.

Install AWS CLI 2 - Step 3

Click Continue.

Install AWS CLI 2 - Step 4

Agree to the license terms then click Continue.

Install AWS CLI 2 - Step 5

Choose whether to install for the current user or all users then click Continue.

Install AWS CLI 2 - Step 6

Click Continue.

Install AWS CLI 2 - Step 7

Click Install.

Install AWS CLI 2 - Step 8

Click Close.

Install AWS CLI 2 - Step 9

Advertisement

Test the installation

Test the installation was successful by opening a terminal and running the following command:

aws --version

The output should show the version number of the AWS CLI:

aws-cli/2.0.49 Python/3.7.4 Darwin/19.5.0 exe/x86_64

We are now ready to create a user account and configure the AWS CLI to use this account to manage services.

Advertisement

Step 2: Create IAM user with programmatic access

Login to the AWS management console then search for IAM in the Find services text field.

AWS Create IAM User - Step 1

Click Users.

AWS Create IAM User - Step 2

Click Add user.

AWS Create IAM User - Step 3

Enter the name of the user, tick the Programmatic access check box, then click the Next: Permissions button.

AWS Create IAM User - Step 4

Click Attach existing policies directly, tick the policies you want the user to have access to, then click the Next: Tags button. In the following example, I have given the user full administrator access, however it’s recommended that you give the user the least amount of privileges possible.

AWS Create IAM User - Step 5

Enter any tags you would like to help you keep users organized then click Next: Review.

AWS Create IAM User - Step 6

Click the Download .csv button to save the access key and secret to your local machine. Make sure it is saved before clicking Close.

AWS Create IAM User - Step 7

The user is now created and we are ready to configure the AWS CLI with the credentials we downloaded above.

AWS Create IAM User - Step 8

Advertisement

Step 3: Configure Credentials

Open the macOS terminal and run the following command:

aws configure

Enter the AWS Access Key ID and the AWS Secret Access Key when prompted. Choose the default region and output format of json and then the details will be saved to ~/.aws/credentials.

Now we can test to see if the credentials work by running a command, for example list the S3 buckets with:

aws s3 ls
tony@MacBook-Pro ~ % aws s3 ls
2020-02-16 22:20:36 graspingtech.com
Advertisement

Conclusion

That’s it. We are now ready to deploy and manage services using the AWS CLI.

Written by: Tony Mackay

AWS DevOps
Advertisement