nepalcargoservices.com

Create and Configure AWS CLI in an EC2 Instance

Written on

Introduction to AWS EC2

In this guide, we'll walk through the process of creating and launching an EC2 instance, connecting to it via SSH, and configuring the AWS CLI. Don't worry; it's straightforward!

Creating an EC2 Instance on AWS

Steps to Follow:

  1. Create and launch an EC2 instance.
  2. SSH into the EC2 instance.
  3. Configure the AWS CLI.

To begin, log into your AWS account. Upon logging in, you should see "EC2" among your recently visited services. If it's not visible, simply type "EC2" in the search bar at the top and select it.

Navigating to EC2 Instances

Next, click on "Instances" to view your current instances.

Viewing EC2 Instances

Now, let's proceed to launch a new instance. You'll notice multiple options available for launching; choose the one that suits you best.

Launching an EC2 Instance

For this instance, I have named it "Developer Exercise 1."

Naming Your EC2 Instance

Next, we need to create a key pair.

Creating a Key Pair for EC2

I recommend naming your instance and key pair the same for easy identification, especially if you're working on multiple projects. After naming your key pair, click "Create." Remember where your key pair is saved for later access.

Downloading Key Pair

Once the instance is launched, select "View all instances" to proceed.

Viewing All EC2 Instances

Next, check the box next to your instance and click "Connect."

Connecting to EC2 Instance

Choose "SSH client" and copy the provided command. This command is essential for connecting to your instance.

Copying SSH Command

Open your terminal, navigate to the directory containing your key pair, and paste the command. My key pair is located in my Downloads folder, as shown below.

Using Terminal to SSH into EC2

Success! You are now logged in as ec2-user and operating within your EC2 instance. To configure the AWS CLI, simply enter the command:

aws configure

You will be prompted to input your AWS Access Key ID and AWS Secret Access Key. If you don’t know these, no worries! Just follow these steps to create new keys.

Back in your AWS dashboard, click on the dropdown next to your Username and Account ID, then select "Security credentials."

Navigating to Security Credentials

Then, select "Create access key" to download your new keys.

Downloading Access Keys

Open the file containing your downloaded keys. If you're having trouble copying them directly into your terminal, try using a split-screen view for easier manual entry.

Accessing Downloaded Keys

Re-enter the earlier command, and you will be prompted again for your keys. Enter them along with your default region name. After completing this, run the command once more to confirm the configuration. Note that I skipped the output format setting.

Confirming AWS CLI Configuration

And just like that, you're all set! This process was designed to be simple, and it truly was.

Pro Tip: Always keep track of your Access Keys to streamline the process in the future.

Thank you for following along! I hope you found this guide helpful.

Jason Wood

@jwood9799

Chapter 2: YouTube Tutorials

This video tutorial titled "AWS CLI on Amazon EC2" provides a comprehensive overview of setting up the AWS CLI in an EC2 environment.

In this second video, "Launch Amazon EC2 Instance Using AWS CLI," you'll learn the step-by-step process to launch an EC2 instance through the AWS CLI.

Share the page:

Twitter Facebook Reddit LinkIn

-----------------------

Recent Post:

Innovations in Maintenance of Way: Enhancing Rail Infrastructure

Explore how new methods and machines are transforming the maintenance of rail infrastructure, ensuring efficiency and safety.

What Is the Fifth Dimension and Its Origins?

Explore the concept of the fifth dimension, its origins in physics, and its implications for understanding the universe.

# The Power of Silence: Why I Keep My iPhone on Do Not Disturb Mode

Discover the benefits of using Do Not Disturb mode on your iPhone to enhance productivity and maintain focus in a world full of distractions.