Introduction
AWS Command Line Interface(CLI) is a unified tool to manage your AWS Services. With the Help of this tool you can manage , configure and control multiple services.
AWS CLI Version
Currently two version of AWS CLI -
AWS CLI Version 1 - It's Older version , have less feature than version 2.
AWS CLI Version 2 - It's Latest version and supported all latest feature of AWS.
Step by Step Installing AWS CLI at Linux
Installing AWS CLI Version 1
Step 1 : First we update current system, to ensure all packages have latest version.$ sudo yum -y updateStep 2 : You can install AWS CLI and its dependency by using pip. Check pip and python installation status.
If python3 is installed then it is recommended that use pip3 also.
Check python installation status
$ python --versionor
$ python3 --versionCheck pip installation status
$ pip --versionor
$ pip3 --versionIf PIP already installed then ignore Step 3
Step 3 : Install pip - If you have don't have python or python3 on your Linux box then follow this step by step guide. Now download pip script provided by python packaging authority.
- Download pip script by using curl with -O option.
$ curl -O https://bootstrap.pypa.io/get-pip.py
- For python
$ python get-pip.py --user
- For python3
$ python3 get-pip.py --user
- Now test pip install correctly
$ pip --version pip 20.0.2 from /home/yogesh/.local/lib/python3.6/site-packages/pip (python 3.6)or
$ pip3 --version pip 20.0.2 from /home/yogesh/.local/lib/python3.6/site-packages/pip (python 3.6)
Step 4 : Install AWS CLI
Use pip or pip3 to install aws cli.
$ pip install --upgrade awscli --useror
pip3 install --upgrade awscli --userwhen you use --user switch, it install locally
Step 5 : Verify AWS CLI installation
aws --version
Installing AWS CLI Version 2
AWS CLI V2 is complete software package it not required any other package. you no need to install python.
Step 1 : Download file using curl, use -o(smallcase letter o) option to rename downloaded file from awscli-exe-linux-x86_64.zip to awscliv2.zip
Step 2 : Unzip awscliv2.zip using unzip command
optional switch
--install-dir - specific location other than default location which under current user.
--bin-dir - specific bin directory
--update - if you want update from version 1 to version 2
Step 1 : Find bin directory of AWS CLI Version 1 result give --bin-dir parameter valuePrerequisite
Required unzip package to extract the downloaded file.Step 1 : Download file using curl, use -o(smallcase letter o) option to rename downloaded file from awscli-exe-linux-x86_64.zip to awscliv2.zip
$curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
Step 2 : Unzip awscliv2.zip using unzip command
$ unzip awscliv2.zipStep 3: Install
$ sudo ./aws/install
optional switch
--install-dir - specific location other than default location which under current user.
--bin-dir - specific bin directory
--update - if you want update from version 1 to version 2
Update From AWS CLI version 1 to AWS CLI Version 2
$ which aws ~/.local/bin/awsStep 2 : Find installation directory of AWS CLI Version 1. result give --install-dir parameter value. Most cases bin directory and installation directory in version 1 same
$ ls ~/.local/bin/aws lrwxrwxrwx. 1 oracle oinstall 43 Apr 11 20:51 /home/oracle/.local/bin/awsStep 3 : use following command to upgrade from version 1 to version 2
sudo ./aws/install --bin-dir /usr/local/bin --install-dir /usr/local/aws-cli --update
Configure AWS CLI
1. Configure Credential - Use aws configure command to set aws access key id, aws secret access key, default region name and default output format.
[oracle@devBase aws]$ aws configure AWS Access Key ID [****************ksdk]: AWS Secret Access Key [****************klfk]: Default region name [ap-south-1]: Default output format [None]:
These information store under .aws directory of current user. This .aws directory have two file config and credentials. config file store region and output format while credentials store aws access key id and aws secret access key.
[oracle@devBase aws]$ ls ~/.aws/ config credentials [oracle@devBase aws]$ cat ~/.aws/config [default] region = ap-south-1 [oracle@devBase aws]$ cat ~/.aws/credentials [default] aws_access_key_id = jsdaflksdk aws_secret_access_key = kfsldafklfk
Here [default] indicate that this is default profile.
How to update region, output format, aws access key id, aws secret access key
Use set option to set these value
[oracle@devBase aws]$ aws configure set region ap-south-2 --profile default [oracle@devBase aws]$ aws configure get region --profile default ap-south-2Edit credential or config file
[oracle@devBase aws]$ vim ~/.aws/config
How to add multiple profile
1. Using aws cli - use --profile switch to add different profile.[oracle@devBase aws]$ aws configure --profile test AWS Access Key ID [None]: asdfkasdkjf AWS Secret Access Key [None]: akdfldsjakf Default region name [None]: us-west-1 Default output format [None]: tableyou can check the result
[oracle@devBase aws]$ cat ~/.aws/credentials [default] aws_access_key_id = jsdaflksdk aws_secret_access_key = kfsldafklfk [test] aws_access_key_id = asdfkasdkjf aws_secret_access_key = akdfldsjakf [oracle@devBase aws]$ cat ~/.aws/config [default] region = ap-south-2 [profile test] region = us-west-1 output = table2. Edit config and credential file to add different profile.
$ vim ~/.aws/config [default] region = ap-south-2 [profile test] region = us-west-1 output = table [profile test2] region = us-west-2 output = jsonTo use a named profile for multiple commands, you can avoid specifying the profile in every command by setting the AWS_PROFILE environment variable at the command line.
$ export AWS_PROFILE=test
Enable Command Completion
To enable command complettion, run the command for the shell that you're using. You can add the command to your shell's RC file to run it each time you open a new shell. In each command, replace the path /usr/local/aws/bin with the one found on your system in the previous section.[oracle@devBase aws]$ complete -C '~/.local/bin/aws_completer' aws
note : replace above red marked path to your system aws_completer location.Reference :
https://pip.pypa.io//en/latest/installing/#do-i-need-to-install-pip
https://www.digitalocean.com/community/tutorials/how-to-install-python-3-and-set-up-a-local-programming-environment-on-centos-7
error
https://github.com/pypa/pip/issues/4186
https://github.com/jasperproject/jasper-client/issues/17
https://github.com/ethereum/viper/issues/276
https://github.com/retspen/webvirtcloud/issues/137
https://github.com/aws/aws-cli/issues/2654
https://github.com/aws/aws-cli/issues/1522
https://stackoverflow.com/questions/31512422/pip-install-r-oserror-errno-13-permission-denied/31512489
No comments:
Post a Comment