Below steps will show how to install AWS Cli on EC2 from scratch including the python install too.
AWS Cli Installation
Check your python version:
If you don't have python installed or it's an older version than '3.x' then follow below steps, If you have python version 3.x+ jump to step #7.
- yum install python-setuptools.
- You need to install python3* , try to find the right python by running 'yum list | grep -i python3' if nothing found then you need to try 'yum update -y' or enable the repo by following below command based on your distro and then run 'yum install python34'RHEL 7
sudo yum install –y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpmRHEL 6
sudo yum install –y https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpmCentos 7 64-bit, Centos 6 64-bit, and Centos 6 32-bit
sudo yum install –y epel-release
- Confirm that python 3.x installed by running 'python --version'.
- yum install python-pip
- pip install --upgrade pip
- Confirm pip installation by running 'pip --version'
- pip install awscli --upgrade --use
- Confirm by running 'aws --version' , if you get any errors check below steps:
- Run '~/.local/bin/aws --version' if you getting the version back then it's installed but not in the environment.
Configure AWS Cli
Perquisite: you need to have your Access Key and Secret Access Key, if you don't have one follow the below steps otherwise skip that part.
Create Access Key
- Login to AWS Console
- Under your IAM name choose 'My Security Credentials'
- Click on Access Keys, create new one and save the Secret Access Key as you no longer going to have access to it anymore.
Create Access Key
- Go to your EC2 again and run 'awsconfigure'
- Put both Access and Secret Key
- Choose your region or leave it empty for default
- You can run simple commands like 'aws ec2 describe-instances' for testing.
If you are getting errors like:
An error occurred (AuthFailure) when calling the DescribeInstances operation: AWS was not able to validate the provided access credentials
An error occurred (UnrecognizedClientException) when calling the DetectLabels operation: The security token included in the request is invalid.
You can confirm the keys by checking the configuration in below path
It should look similar to
region = us-west-2
aws_access_key_id = AKI************
aws_secret_access_key = Isx8***************
You can also try debug mode
aws ec2 describe-instances --debug
In some cases the server time should be synced, so be sure that you have ntp and it's on
yum install ntp
systemctl start ntpd
Lastly try again running 'aws configure' and see the output which shows the last 3 characters if matching your keys.
Please like our page and share it.