Managing Amazon Web Services (AWS) from the command line can be highly efficient and convenient. The AWS Command Line Interface (CLI) allows you to interact with AWS services directly from your terminal or command prompt. This blog will guide you through the installation of AWS CLI, connecting it to your AWS account, and configuring it for seamless use.
Step 1: Install AWS CLI
For Windows Users:
- Download the Installer
- Visit the AWS CLI installation page and download the Windows installer.
- Run the Installer
- Double-click the downloaded .msi file and follow the installation wizard.
- Verify Installation
- Open Command Prompt and type:
aws –version - You should see output similar to:
aws-cli/2.x.x Python/3.x.x Windows/10
- Open Command Prompt and type:
For macOS Users:
- Use Homebrew
- Open your terminal and run:
brew install awscli
- Open your terminal and run:
- Verify Installation
- Run the following command in the terminal:
aws –version
- Run the following command in the terminal:
For Linux Users:
- Download and Install
Open your terminal and run:
curl “https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip” -o “awscliv2.zip”
unzip awscliv2.zip
-
- sudo ./aws/install
2. Verify Installation
-
- Run:
aws –version
- Run:
Step 2: Create or Locate Your Access and Secret Keys
To connect AWS CLI with your AWS account, you need an Access Key and a Secret Key. These keys can be created in the AWS Management Console.
- Login to AWS Console
- Navigate to AWS Management Console.
- Access IAM (Identity and Access Management)
- Search for “IAM” in the AWS Console search bar and select it.
- Create an IAM User
- Go to Users and click Add users.
- Provide a name for the user (e.g., cli-user).
- Select Programmatic access as the access type.
- Attach Policies
- Choose the appropriate policies for the user, such as AdministratorAccess (if applicable).
- Click Next: Tags and then Next: Review.
- Save the Keys
- After the user is created, download the .csv file containing the Access Key ID and Secret Access Key, or copy them securely.
Important: Keep your secret key confidential. Do not share it or expose it in code repositories.
Step 3: Configure AWS CLI
- Open Terminal or Command Prompt
- Run AWS Configure
- Enter the following command:
aws configure
- Enter the following command:
- Provide Credentials
- Enter the requested information:
- Access Key ID: (Enter your access key)
- Secret Access Key: (Enter your secret key)
- Default region: (e.g., us-east-1)
- Output format: (e.g., json)
- Enter the requested information:
Example:
AWS Access Key ID [None]: AKIAxxxxxxxxxxxxxxx
AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
Default region name [None]: us-east-1
4. Default output format [None]: json
5. Test the Configuration
-
- Run a simple command to test the connection:
aws s3 ls - If your CLI is connected correctly, you should see a list of S3 buckets (if any exist in your account).
- Run a simple command to test the connection:
With AWS CLI installed and configured, you can now manage your AWS resources efficiently from the command line. Whether you’re scripting repetitive tasks or exploring AWS services, the CLI is a powerful tool to have in your arsenal. Ensure your access keys are secure, and always follow best practices for managing credentials.
Next article – Step 6: How to Create a Windows 11 Virtual Instance Using Oracle VirtualBox