Getting Started with AWS CLI: Install, Configure, Test, and Use
The AWS Command Line Interface (CLI) is a powerful tool allowing you to interact directly with various AWS services from your command line. This guide will walk you through setting up the AWS CLI on your laptop, whether you're using Windows, macOS, or Linux.
Prerequisites
Before we begin, ensure you have:
An AWS account
Your AWS access key ID and secret access key
Python 3.6 or later installed on your system
Step 1: Install the AWS CLI
For Windows:
Download the AWS CLI MSI installer for Windows (64-bit) from the official AWS website.
Run the downloaded MSI installer and follow the on-screen instructions.
Once installed, open the Command Prompt to verify the installation by typing:
aws --version
For macOS:
The easiest way to install AWS CLI on macOS is using Homebrew. If you don't have Homebrew installed, install it first.
Open Terminal and run:
brew install awscli
Verify the installation:
aws --version
For Linux:
Open a terminal window.
Use pip to install the AWS CLI:
pip3 install awscli --upgrade --user
Add the AWS CLI executable to your PATH:
export PATH=$PATH:$HOME/.local/bin
Verify the installation:
aws --version
Step 2: Configure the AWS CLI
After installation, you need to configure the AWS CLI with your credentials:
Open a terminal or command prompt.
Run the following command:
aws configure
You'll be prompted to enter four pieces of information:
AWS Access Key ID
AWS Secret Access Key
Default region name (e.g., us-west-2, eu-west-1)
Default output format (json, yaml, text, or table)
Example:
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
Step 3: Test Your Configuration
To ensure everything is set up correctly:
Run a simple AWS CLI command, such as listing your S3 buckets:
aws s3 ls
If configured correctly, you should see a list of your S3 buckets or an empty response if you have no buckets.
Step 4: Using AWS CLI
Now that you've set up AWS CLI, you can start using it to interact with AWS services. Here are a few example commands:
List EC2 instances:
aws ec2 describe-instances
Create an S3 bucket:
aws s3api create-bucket --bucket test-bucket-789282 --region us-east-1
Upload a file to S3:
aws s3 cp "C:\Users\sprasad\Desktop\test_s3_folder" s3://test-bucket-789282/ --recursive
Conclusion
You've successfully set up the AWS CLI on your laptop! This powerful tool allows you to manage your AWS resources efficiently from the command line. As you become more familiar with the AWS CLI, you'll find it invaluable for automating tasks and managing your AWS infrastructure.
Remember to keep your AWS access keys secure and never share them publicly. If you suspect your keys have been compromised, immediately rotate them in your AWS IAM console.
Happy cloud computing!
Thank you for joining me on this journey through the world of cloud computing! Your interest and support mean a lot to me, and I'm excited to continue exploring this fascinating field together. Let's stay connected and keep learning and growing as we navigate the ever-evolving landscape of technology.
LinkedIn Profile: https://www.linkedin.com/in/prasad-g-743239154/
Feel free to reach out to me directly at spujari.devops@gmail.com. I'm always open to hearing your thoughts and suggestions, as they help me improve and better cater to your needs. Let's keep moving forward and upward!
If you found this blog post helpful, please consider showing your support by giving it a round of applauseπππ. Your engagement not only boosts the visibility of the content, but it also lets other DevOps and Cloud Engineers know that it might be useful to them too. Thank you for being so supportive! π
Thank you for reading and happy deploying! π
Best Regards,
Sprasad
Subscribe to my newsletter
Read articles from Sprasad Pujari directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Sprasad Pujari
Sprasad Pujari
Greetings! I'm Sprasad P, a DevOps Engineer with a passion for optimizing development pipelines, automating processes, and enabling teams to deliver software faster and more reliably.