AWS CLI — Installation and Configuration
This post will help you get started with the AWS CLI by creating a new user and configuring the security credentials.
Amazon Web Services (AWS)is a powerful cloud service platform offering services from web servers to satellite control systems. Millions of organizations from startups to leading government agencies like NASA use AWS to power their data centers.
AWS offers three ways to interact with its services. The web console, the software development kit (SDK) and the command-line interface (CLI). In this article, we will see how you can get started with the AWS CLI.
Creating a New User
Assuming you have an AWS account created (which is pretty straightforward), go to your dashboard. From Services, choose “IAM”
In your IAM dashboard, choose ‘Users’ from the menu to your left and click on “Add User”. You should get a prompt from AWS to enter a username along with access types.
Provide a username and check “Programmatic access”. If you want the new user account to have web console access as well, check the “AWS Management Console Access” option. But for our initial setup, the latter is not necessary.
Once you click “Next”, you should be presented with the “Permissions” menu. Here you have the option of creating a new group. Groups are a collection of policies while policies define the permissions associated with each AWS resource. Check out this documentation to learn more about groups and policies
Let’s create a new group called AdminGroup and assign the “AdministratorAccess” policy. This will allow the new user account to access all the AWS services via CLI. Providing administrator access to user accounts is not advised unless the user account truly needs admin privileges.
After you create the group, skip the tags section and your final review section should look similar to this:
Click on “Create User”. You should see the screen with the new user created along with the Access Key ID and Secret Access Key. We will need it later.
If you have made it so far, good job!
Install the CLI
Let’s install the AWS CLI. I am on a Mac, so if you are on a PC or a Linux box, you can find help here. Type the following command.
$ pip3 install awscli --upgrade --user
This should install AWS CLI on your system. To check the installation, type
$ aws --version
for which you should see something like this
aws-cli/1.16.224 Python/2.7.16 Darwin/19.0.0 botocore/1.12.214
Note: It is highly likely that you will face issues during installation if you are a beginner, so feel free to ask for help in the comments.
Configure security credentials
Once your CLI setup is complete, you have to configure it with your security credentials from the user account that you just created.In your terminal, type the following command:
$ aws configure
The screen will prompt you to enter your security credentials. Go back to the console and get the access key id and secret access key. Choose the region as ‘us-east-1’ (more on this later).
You won’t receive any output after you configure your security credentials. So let’s check if your security credentials have been configured properly. Type the following command:
$ aws s3 ls
If you don’t get any response, your CLI configuration is successful. If not, you will receive the following error.
An error occurred (InvalidAccessKeyId) when calling the ListBuckets operation: The AWS Access Key Id you provided does not exist in our records.
If you receive this error, double-check your access keys. Also, once you copy your access keys, you will not be shown again. You will have to create new access keys for the user.
If you have successfully installed and configured your AWS CLI, play with some common commands. Let me know the issues you faced (if any) in the comments section.
AWS CLI is a useful and powerful tool that helps you interact with all AWS services. In fact, the AWS SDK is just a wrapper on top of the AWS CLI. Keep watching our blog to learn about more AWS features and tips on preparing for AWS certifications.
Don’t forget to clap if you liked this article. Signup for our weekly newsletter and we will send you a summary of articles every week. No spam. No ads.