Ready, Set, LAUNCH!! How to Launch and Connect to an AWS EC2 Instance.
Tags: aws, compute, ec2, cloudcomputing
Published: 2024-06-14 01:49:07

[AWS EC2 (Amazon Elastic Compute Cloud)](https://aws.amazon.com/ec2/) is a popular service that provides scalable computing capacity in the cloud. Whether you're setting up a server for the first time or just need a refresher, this guide will walk you through launching an EC2 instance and connecting to it.

---

## **Prerequisites**

- An AWS account. If you don't have one, you can [create a free account](https://portal.aws.amazon.com/billing/signup?nc2=h_ct&src=header_signup&redirect_url=https%3A%2F%2Faws.amazon.com%2Fregistration-confirmation#/start/email).
- Basic understanding of cloud computing concepts.
- A terminal application for SSH (Linux and macOS).

---

## **Step 1: Launch an EC2 Instance**

1.. **Log in to AWS Management Console**

Go to the [AWS Management Console](https://aws.amazon.com/console/) and log in with your credentials.

2.. **Navigate to EC2 Dashboard**

From the AWS Management Console, type "EC2" in the search bar and select EC2 from the list of services.

3.. **Launch an Instance**

3.1. In the EC2 Dashboard, click **Launch Instance**.
3.2. **Name and Tags**: Enter a name for your instance (e.g., "MyFirstInstance"). Tags are optional.
3.3. **Choose an Amazon Machine Image (AMI)**: Select an AMI. For beginners, the Amazon Linux 2 AMI (HVM), SSD Volume Type is a good choice as it is free tier eligible.
3.4. **Choose an Instance Type**: Select the instance type. t2.micro is free tier eligible and sufficient for most small applications or testing purposes.
3.5. **Key Pair (login)**: Select Create a new key pair. Give it a name, and download the '.pem' file. Keep this file secure as it is necessary for SSH access.
3.6. **Network Settings**:
- Click on **Edit**.

- Under **VPC** and **Subnets**, the default settings are usually fine.

- Ensure Auto-assign public IP is enabled.

- **Firewall (security groups)**: Create a new security group.

- Add a rule to allow SSH access. Set the type to **SSH**, the protocol to **TCP**, the port range to **22**, and the source to **My IP** to restrict access to your IP address.'

3.7. **Configure Storage**: The default 8 GB is usually enough. **Click Next: Add Tags.**
3.8. **Advanced Details**: You can leave this section with default settings for now.
3.9. Review all the configurations and click **Launch Instance**.

4.. **View Your Instance**

Click **View Instances** to go to the EC2 Dashboard where you can see your instance initializing. Wait for the instance state to turn to **running** and the status checks to show **2/2 checks passed.**

---

## **Step 2: Connect to Your EC2 Instance**

1.. **Get the Public DNS**

In the EC2 Dashboard, click on your running instance and find the **Public DNS (IPv4)** field. Copy this address; you will need it to connect to your instance.

2.. **Connect Using SSH (Linux/Mac)**

2.1. Open a terminal.
2.2. Navigate to the directory where your '.pem' file is located.
2.3. Change the permissions of your .pem file to ensure it's not publicly viewable by using the following script:
- _chmod 400 your-key-pair.pem_

2.4. Connect to your instance by using the following script: 

_- ssh -i "your-key-pair.pem" ec2-user@your-public-dns_

Note: Replace 'your-key-pair.pem' with the name of your key pair file and 'your-public-dns' with the Public DNS you copied earlier

---

## **Outcome**

Once connected, you’ll be in the terminal of your new EC2 instance. You can now use this instance as a remote server to deploy applications, run scripts, or set up a web server. AWS EC2 provides a flexible platform for all your cloud computing needs.

Feel free to share your thoughts and questions in the comments below. Happy cloud computing!