The AWS CLI is a tool you use in the command line (terminal) to work with Amazon Web Services (AWS). It helps you manage and automate AWS services without needing a web browser or extra apps.
In this guide, we will learn how to install AWS CLI v2 on a Linux system. You can find the official AWS CLI documentation here. For general usage information, you can read this guide.
Step 1: Installing AWS CLI on Linux
The AWS CLI version 2 can be installed from the default repositories on Linux. You can use a package manager to install it.
Here are some commands to install AWS CLI version 2:
- Ubuntu and Debian-based Systems
sudo apt install awscli
- Fedora and CentOS 9/8
sudo dnf install awscli
- CentOS 7 and Scientific Linux
sudo yum install awscli
If the package is not found in the package manager, you can install AWS CLI directly using the source code to get the latest version for any Linux platform.
curl https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip -o awscliv2.zip
unzip awscliv2.zip
sudo ./aws/install
Step 2: Generate Access Credentials
To use AWS CLI with your AWS account, you need to set your AWS credentials on your system. These credentials are used to authenticate your requests to AWS.
Follow these steps to generate new credentials:
- Go to AWS Security Credentials.
- Expand the option Access keys (access key ID and secret access key).
- Click the button Create New Access Key.
- Copy the access key ID and secret access key and save them in a safe place.
Step 3: Configure AWS CLI
To set your AWS credentials for the AWS CLI, use the following command:
aws configure
You will be prompted to enter your AWS Access Key ID and Secret Access Key:
AWS Access Key ID [None]: ABCDEFXXXXXXXXDKKDFJ
AWS Secret Access Key [None]: 3SDFsXXXXXXXXXXXXXXXXXXXXXSJFKD
Default region name [None]: us-east-1
Default output format [None]:
Now your system is set up with AWS CLI tools.
Step 4: Working with AWS CLI Commands (Optional)
The AWS CLI allows you to manage many AWS services from the command line. To get help, type:
aws help
Here are a few example commands to use with AWS CLI:
- List all the EC2 instances:
aws ec2 describe-instances
- List instances from a specific region:
aws ec2 describe-instances --region=us-west-1
- List S3 buckets:
aws s3 list
Conclusion
This guide explained how to install AWS CLI on Linux and use it. The AWS CLI is a command line interface built on top of the AWS APIs. It makes it easy to manage and automate the use of Amazon Web Services directly from your terminal without using a browser or extra apps.
2 Comments
I have multiple AWS account with me. Is there any way to use any of them from the same system. If yes then how do I configure all of them in a single system?
Hi,
Looks like amazon is depreciating SOAP Requests after December 2014.
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-soap-api.html
You should use Query API for Amazon EC2, or the SDKs for AWS regarding their website.