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.
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.
Agree to the license terms then click Continue.
Choose whether to install for the current user or all users then click Continue.
Test the installation
Test the installation was successful by opening a terminal and running the following command:
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.
Step 2: Create IAM user with programmatic access
Login to the AWS management console then search for IAM in the Find services text field.
Click Add user.
Enter the name of the user, tick the Programmatic access check box, then click the Next: Permissions button.
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.
Enter any tags you would like to help you keep users organized then click Next: Review.
Click the Download .csv button to save the access key and secret to your local machine. Make sure it is saved before clicking Close.
The user is now created and we are ready to configure the AWS CLI with the credentials we downloaded above.
Step 3: Configure Credentials
Open the macOS terminal and run the following command:
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
That’s it. We are now ready to deploy and manage services using the AWS CLI.