Getting Started with AWS CLI: Installation, Configuration, and Basic Commands
One powerful tool that can simplify this process is the AWS Command Line Interface (AWS CLI). In this blog post, we will guide you through the installation of AWS CLI on your terminal, show you how to configure it to access your AWS account, and introduce you to some basic AWS CLI commands.
Installing AWS CLI:
Step 1: Check Prerequisites
Before installing AWS CLI, ensure that you have Python installed on your machine. AWS CLI requires Python 3.6.0 or later.
Step 2: Install AWS CLI
Open your terminal.
Run the following command to install AWS CLI :
curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg" sudo installer -pkg AWSCLIV2.pkg -target /
Configuring AWS CLI:
Step 3: AWS Configure
After installing AWS CLI, you need to configure it with your AWS credentials.
Run the following command:
aws configure
You will be prompted to enter your AWS Access Key ID, Secret Access Key, default region, and output format. These credentials can be obtained from the AWS Management Console.
Example:
AWS Access Key ID: YOUR_ACCESS_KEY_ID AWS Secret Access Key: YOUR_SECRET_ACCESS_KEY Default region name: YOUR_REGION Default output format: json
Basic AWS CLI Commands:
1. List S3 Buckets
To list all the S3 buckets in your account, use the following command:
aws s3 ls
2. Copy Files to S3
To copy a local file to an S3 bucket, use the following command:
aws s3 cp local-file.txt s3://your-bucket/
3. List EC2 Instances
To list all EC2 instances in your account, use the following command:
aws ec2 describe-instances
4. Create an S3 Bucket
To create a new S3 bucket, use the following command:
aws s3 mb s3://new-bucket-name
5. Delete an S3 Bucket
To delete an existing S3 bucket, use the following command:
aws s3 rb s3://bucket-to-delete --force
6. Launch an EC2 Instance
To launch a new EC2 instance, use the following command:
aws ec2 run-instances --image-id ami-12345678 --instance-type t2.micro --key-name your-key-pair
These are just a few examples of what AWS CLI can do. As you explore more, you'll discover its capabilities in managing various AWS services effortlessly from the command line.Use the official AWS docs for more details
https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-welcome.html
Conclusion: In this blog post, we covered the installation of AWS CLI, configuration using aws configure
, and some basic AWS CLI commands to get you started. Mastering AWS CLI can significantly enhance your productivity when working with AWS resources, allowing you to streamline operations and manage your infrastructure more efficiently.