How to use AWS cli
What is AWSCLI?
AWS Command Line Interface
It is an Open-Source tool which enables us to interact with AWS services using Command-Line. It allows us to perform functionality through commands that are equivalent to the Browser-AWS GUI management console.
How to install awscli in Linux (ubuntu)?
apt install awscli
How to configure the AWS CLI ?
aws configure AWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY Default region name [None]: us-west-2 Default output format [None]: json
Multiple profiles can be added to the awscli
Now we need to check if we have configured the credentials perfectly or not
aws ec2 describe-regions --output table
List the aws configured file and secure keys
ls ~/.aws aws ec2 describe-instances --profile user2 export AWS_PROFILE=user2
The following example shows how you would configure environment variables for the default user from earlier in this guide.
Linux, macOS, or Unix $ export AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE $ export AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY $ export AWS_DEFAULT_REGION=us-west-2
How to reconfigure the AWS CLI
aws configure --profile profilename aws ec2 describe-instances --output table --region us-east-1 aws ec2 describe-instances --output table --region us-west-1