AWS Command Line Interface
Today we will be setting up our AWS CLI.
AWS CLI is a tool that lets us manage AWS services from the command line. With AWS CLI, we can control various AWS services and automate tasks through scripts.
To use AWS CLI, we need to configure it with access keys that grant the necessary permissions to perform actions on AWS resources. These access keys are part of AWS Identity and Access Management (IAM).
IAM Access Keys
IAM (Identity and Access Management) access keys are a pair of security credentials that AWS uses to authenticate and authorize API calls. These keys are associated with an IAM user and consist of two parts:
Access Key ID: A unique identifier for the access key.
Secret Access Key: A secret key used to sign requests.
Purpose
IAM access keys allow programmatic access to AWS services via the AWS CLI (Command Line Interface), AWS SDKs (Software Development Kits), and other tools that make API requests to AWS services.
When creating access keys, it is essential to use the IAMAdmin
role or another appropriate IAM role. Creating access keys for the root account is not recommended due to security concerns.
Let's create our Access keys.
Click on your profile and select Security credentials
.
Scroll a bit and you will find the Access keys section.
Click on Create access key
.
Choose CLI for Use case, tick the confirmation box and click on Next
.
Provide a description tag for your Access key.
Click on Create access key
.
Our access key has been created.
We can see that this is the only time we can view or download our secret key. However, if we lose it, we can create a new one.
Click on Download .csv file
and store it securely in your local machine.
Click on Done
.
We have created our access keys. We can create up to two access keys in total. Access keys can be created, deleted, activated, and deactivated.
Downloading AWS CLI
Now that we have created & downloaded our access keys, it's time to download the AWS CLI on our local machine.
Click the link above to download AWS CLI.
Choose according to your operating system.
Configure all the setup, and after your setup is successful, type the following command.
aws --version
The command displays the installed version of the AWS CLI on your machine.
Configuration
Type the following command to configure your AWS CLI.
aws configure
The command is used to configure your credentials for the AWS CLI. It will ask for your access key ID, secret access key, default region name (use the closest region code, e.g., us-east-1) & skip the default output format field associated with your IAM user.
After you have configured your credentials, input the following command.
aws configure list
The command displays information about the profiles you have configured for interacting with AWS services.
You must see your configured profile.
Simple Commands
Let's use simple AWS CLI commands.
aws s3 ls #to list the S3 buckets.
The command is used to list the S3 buckets.
As I do not have any buckets created, it is showing empty.
aws iam list-users #to list all IAM users
We used simple AWS CLI commands. Now that our AWS CLI is set up, we can do many AWS operations from the command line but more on that later.
Thank you.