DEV Community

Elone.rajeev
Elone.rajeev

Posted on

๐Ÿš€ Learn AWS EC2: Ultimate Beginner's Guide ๐ŸŒ

Welcome to the AWS EC2 Tutorial! This guide will take you through everything you need to know about Amazon Elastic Compute Cloud (EC2)โ€”from launching instances to hosting your first webpage!


๐ŸŽฏ What is AWS EC2?

Amazon EC2 is a web service that provides resizable compute capacity in the cloud. It enables businesses to deploy applications quickly without hardware investments.


๐Ÿ“‹ Table of Contents

  1. ๐ŸŒŸ Why Learn EC2?
  2. ๐Ÿš€ Getting Started
  3. ๐Ÿ“ฆ EC2 Instance Types
  4. โš™๏ธ Launching an EC2 Instance
  5. ๐ŸŒ Hosting a Simple Webpage
  6. ๐Ÿ”’ Security Best Practices
  7. ๐Ÿ“ˆ Monitoring and Scaling
  8. ๐ŸŽ‰ Conclusion

๐ŸŒŸ Why Learn EC2?

  • ๐Ÿš€ Cloud Computing Mastery: EC2 is the backbone of AWS services.
  • ๐Ÿ’ผ Career Growth: EC2 knowledge is crucial for DevOps, cloud engineers, and developers.
  • ๐ŸŒ Real-World Applications: Use EC2 to host websites, deploy applications, or run data pipelines.

๐Ÿš€ Getting Started

Prerequisites

Before you begin, ensure you have:

  • โœ… An AWS account (free-tier eligible).
  • โœ… Basic knowledge of cloud computing.

๐Ÿ“ฆ EC2 Instance Types

AWS EC2 offers various instance types tailored for different workloads:

Type Use Case Examples
General Balanced performance t2.micro, t3.small
Compute High-performance computing c5.large, c6i.xlarge
Memory Memory-intensive apps r5.large, r6g.xlarge
Storage Data-heavy workloads i3.large, i4i.xlarge
GPU Machine learning, gaming g5.large, p3.2xlarge

โš™๏ธ Launching an EC2 Instance

Follow these steps to launch your first EC2 instance:

  1. Login to AWS Console ๐Ÿ–ฅ๏ธ

    • Navigate to EC2 under the "Compute" section.
  2. Click "Launch Instance" ๐Ÿš€

    • Provide a name for your instance.
    • Select an AMI (Amazon Machine Image) like Ubuntu, Amazon Linux, or Windows Server.
  3. Choose an Instance Type ๐Ÿ–ฑ๏ธ

    • For beginners, choose t2.micro (free-tier eligible).
  4. Configure Security Groups ๐Ÿ”’

    • Add rules to allow inbound traffic for HTTP (port 80) and SSH (port 22).
  5. Key Pair ๐Ÿ—๏ธ

    • Create or select an existing key pair for secure access.
  6. Launch Your Instance ๐ŸŽ‰

    • Click Launch Instance and wait for it to initialize.

๐ŸŒ Hosting a Simple Webpage

Hereโ€™s how you can host a basic index.html file on your EC2 instance.

Step 1: Install a Web Server

Log into your EC2 instance via SSH and run the following commands to install a web server:

# Update the package manager
sudo apt update  

# Install Apache2
sudo apt install apache2 -y  

# Start Apache2 service
sudo systemctl start apache2  

# Enable Apache2 to start on boot
sudo systemctl enable apache2  
Enter fullscreen mode Exit fullscreen mode

Step 2: Create Your Webpage

Navigate to the default web server directory and create an index.html file:

# Navigate to the default directory
cd /var/www/html  

# Create or edit the index.html file
sudo nano index.html  
Enter fullscreen mode Exit fullscreen mode

Add the following content to your index.html file:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Welcome to My Webpage</title>
</head>
<body>
    <h1>๐Ÿš€ Welcome to My First AWS EC2 Hosted Webpage!</h1>
    <p>This is a simple webpage hosted on an EC2 instance.</p>
</body>
</html>
Enter fullscreen mode Exit fullscreen mode

Save and exit (Ctrl+O, Enter, Ctrl+X).

Step 3: Open Your Webpage

  • In your browser, navigate to: http://<Public_IP_of_EC2_Instance>

You should see your index.html webpage live! ๐ŸŽ‰


๐Ÿ”’ Security Best Practices

  1. Use Security Groups: Restrict inbound traffic to only required ports.
  2. Key Management: Keep your .pem file secure.
  3. IAM Roles: Assign least privilege roles to your instances.

๐ŸŽ‰ Conclusion

With this guide, youโ€™ve:

  • Launched your first EC2 instance.
  • Installed a web server.
  • Hosted your first index.html webpage.

Continue exploring AWS to enhance your cloud computing skills!

Need Help? Reach out on AWS Forums or join the AWS Community.


Happy Hosting! ๐Ÿš€



By Rajeev Kumar
Enter fullscreen mode Exit fullscreen mode

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

๐Ÿ‘‹ Kindness is contagious

Please leave a โค๏ธ or a friendly comment on this post if you found it helpful!

Okay