Note: This guide addresses Ubuntu distributions 16.04, 18.04, and 20.04
The AWS CLI (Command Line Interface) is a command line tool designed to help individuals interact with AWS. It’s often used in scripts to automate tasks or configured as bash alias’ to run tasks without clicking through the console. This guide contains step by step instructions on installing and configuring the AWS CLI on Ubuntu.
Install AWS CLI on Ubuntu
- Update the Apt package manager to get the latest packages.
$ sudo apt update
2. Apt install the AWS CLI
$ sudo apt install awscli -y
3. Verify AWS CLI has properly been installed by checking the version in your terminal.
$ aws --version aws-cli/1.18.69 Python/3.8.10 Linux/5.4.0-77-generic botocore/1.16.19
4. Obtain your AWS access and secret key by logging into the AWS console and going to IAM > Users and clicking on your user.
5. Click on the ‘Security’ tab and click ‘Create access key’. It should open a pop-up window with your keys. Keep this open while you perform the next step in your terminal.
6. Configure the AWS CLI to use your user. When it asks for your AWS Access Key and AWS Secret key enter them from the pop up window you kept open in step 5. The default region name is the region that all of your AWS CLI commands will run if you don’t specify a region, I recommend setting this to the location where the majority of your services are running.
User:~$ aws configure AWS Access Key ID [None]: XXXXX AWS Secret Access Key [None]: XXXXX Default region name [None]: us-west-2
7. Test that your credentials work by running an AWS CLI command. For example listing all of your S3 buckets. If this command doesn’t throw an error, you should be in the green.
User:~$ aws s3 ls 2020-07-05 15:36:03 bucket-test-1 2021-02-21 17:15:33 bucket-test-2