🚀Launching an EC2 Instance on AWS: Step-by-Step Instructions

If you're diving into cloud computing with AWS, Amazon EC2 (Elastic Compute Cloud) is likely one of the first services you'll interact with. It's the backbone for deploying scalable and secure virtual servers in the cloud. In this blog, I’ll walk you through how to create an EC2 instance step by step, explain each component involved, and share best practices along the way.


📘 What is Amazon EC2?

Amazon EC2 is a web service that provides resizable compute capacity in the cloud. It allows you to launch virtual machines (known as “instances”), configure security and networking, and manage storage. EC2 is ideal for hosting applications, websites, databases, or development environments.


🔧 Prerequisites

Before you start, make sure you have the following:

  • An AWS Account

  • Basic understanding of networking, SSH, and Linux/Windows (depending on your instance type)


🛠️ Step-by-Step Guide to Launch an EC2 Instance

Step 1: Log in to AWS Console

  1. Go to https://console.aws.amazon.com

  2. Log in with your AWS credentials.

  3. From the Services menu, select EC2 under “Compute.”


Step 2: Launch an Instance

Click “Launch Instance” to begin the configuration.


Step 3: Choose an Amazon Machine Image (AMI)

An AMI is a pre-configured template that includes the OS and software.

  • Common AMIs:

    • Amazon Linux 2

    • Ubuntu Server

    • Microsoft Windows Server

    • Red Hat Enterprise Linux

💡 Tip: Choose “Amazon Linux 2” or “Ubuntu” for a general-purpose Linux server.


Step 4: Choose an Instance Type

Select the instance type based on your requirements.

  • t2.micro – Free tier eligible (1 vCPU, 1 GB RAM)

  • t3.medium – Balanced performance (2 vCPUs, 4 GB RAM)

  • m5.large – Better compute performance (2 vCPUs, 8 GB RAM)

🔎 Instance types vary based on compute, memory, and storage optimization.


Step 5: Configure Instance Details

This is where you define:

  • Number of instances: Usually 1 unless you're launching a cluster.

  • Network: Choose the default VPC or create a custom one.

  • Subnet: Choose a specific Availability Zone.

  • Auto-assign Public IP: Enable it to connect via the internet.

  • IAM Role: Attach if your instance needs permissions (e.g., S3 access).

🔐 Consider enabling monitoring with CloudWatch for better visibility.


Step 6: Add Storage

  • Default volume is 8 GB (EBS - Elastic Block Store).

  • You can add additional volumes if needed.

  • Choose volume type: General Purpose SSD (gp3) or Provisioned IOPS.

📁 Remember: Root volume is where your OS is installed. Be cautious before deleting it.


Step 7: Add Tags

Tags help you organize and manage resources.

  • Key: Name

  • Value: MyFirstEC2Instance


Step 8: Configure Security Group

Security groups act as virtual firewalls.

Add rules like:

  • SSH (Port 22) for Linux

  • RDP (Port 3389) for Windows

  • HTTP (Port 80) or HTTPS (Port 443) for web servers

⚠️ Restrict SSH/RDP access to your IP only to enhance security.


Step 9: Launch and Create Key Pair

  • Create a new key pair (.pem file) for SSH access or use an existing one.

  • Download the key file and store it securely.

  • Click Launch Instance.


🔌 Connect to Your Instance

Once the instance is running:

  1. Go to Instances dashboard.

  2. Select your instance and click Connect.

  3. Use terminal or PuTTY (for Windows users):

     bashCopyEditchmod 400 your-key.pem
     ssh -i your-key.pem ec2-user@<your-public-ip>
    

📊 Monitoring Your Instance

Use CloudWatch for:

  • CPU utilization

  • Disk I/O

  • Network traffic

Enable detailed monitoring for more metrics (at additional cost).


🧼 Stopping or Terminating

  • Stop: Halts instance but retains EBS volume.

  • Terminate: Deletes the instance and its data (unless volume is marked "Delete on termination").


✅ Best Practices

  • Always backup your data (e.g., using AMI snapshots).

  • Use Elastic IPs if you want a static public IP.

  • Restrict access using security groups and NACLs.

  • Enable CloudTrail for auditing EC2 activity.

  • Use Auto Scaling and Load Balancers for production workloads.


🧠 Final Thoughts

Creating and managing an EC2 instance is one of the foundational skills in AWS. Whether you're setting up a dev environment, hosting a web server, or building complex distributed systems, EC2 gives you the flexibility to scale and control your infrastructure.


#AWS #EC2 #Happy Learning

0
Subscribe to my newsletter

Read articles from Pratik Prajapati directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Pratik Prajapati
Pratik Prajapati

👋 Welcome to my Hashnode blog! I'm a Web developer with 7 year's of experience and now I am going to change my domain as DevOps Engineer with lots of hands on experience.