Installing aws-cli on CentOS 7

There are a number of ways to install the AWS command line tools. Below is the method I favour on CentOS:

[andy@centos7 ~]$ curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"
[andy@centos7 ~]$ unzip awscli-bundle.zip
[andy@centos7 ~]$ cd awscli-bundle/
[andy@centos7 awscli-bundle]$ sudo ./install -i /usr/local/aws -b /usr/local/bin/aws

Check that was successful with:

[andy@centos7 ~]$ aws --version
aws-cli/1.16.123 Python/2.7.5 Linux/3.10.0-957.5.1.el7.x86_64 botocore/1.12.113

You can now remove the files extracted:

[andy@centos7 ~]$ rm -vR ~/awscli-bundle/
[andy@centos7 ~]$ rm -v ~/awscli-bundle.zip

Configure aws-cli to use your AWS credentials:

[andy@centos7 ~]$ aws configure
AWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE
AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
Default region name [None]: eu-west-1
Default output format [None]: json

You can test your AWS credentials with the below command.

[andy@centos7 ~]$ aws sts get-caller-identity
{
    "Account": "903503371367", 
    "UserId": "AKIAIOSFODNN7EXAMPLE", 
    "Arn": "arn:aws:iam::903503371367:user/andy"
}

It should display your users details if you are authenticated.

Be the first to comment

Leave a Reply