5.2. AWS EC2 – Virtual Servers in the Cloud πŸš€

Table of Contents

Hey Web Codders! πŸ‘‹ I’m Vikas Sankhla, your tech buddy from Web Codder, and today we’re diving into something SUPER COOL: Amazon EC2. πŸ˜„

You might be wondering:

πŸ‘‰ What is EC2?
πŸ‘‰ How can I use it to host my app?
πŸ‘‰ Is it hard to set up?

Don’t worry! I’m going to explain everything step-by-step, super simple.


🌟 What Is Amazon EC2?

Let’s imagine this: You want to run your app on a powerful computer that’s always online.

Instead of buying your own computer, Amazon rents you one on the internet! πŸ’»β˜οΈ

That’s what EC2 (Elastic Compute Cloud) isβ€”a virtual server you can use anytime, anywhere. πŸš€

πŸ’‘ In simple words:
EC2 = A computer in the cloud that runs your app. βœ…


πŸ–₯️ Why Do We Need EC2?

  • Your app needs a home 🏠 (a server).
  • You want your app to be available 24/7. πŸ•’
  • You don’t want to worry about hardware & electricity. πŸ”Œ

EC2 solves all that by giving you:

βœ… A computer that’s always on.
βœ… The ability to choose your power.
βœ… Global access (users from anywhere can visit).


πŸ› οΈ How to Set Up an EC2 Instance (Step-by-Step)

Let’s host your app on EC2. Follow these easy steps:

1️⃣ Sign In to AWS Console

πŸ‘‰ Go to aws.amazon.com
πŸ‘‰ Log in or create an account.

Note: AWS gives you free tier access for 12 months! πŸŽ‰


2️⃣ Launch a New EC2 Instance πŸš€

  • Click β€œEC2” in the services menu.
  • Click β€œLaunch Instance.”

βœ… Choose an Amazon Machine Image (AMI):
Pick Ubuntu Server 20.04 LTS (free tier eligible).

βœ… Choose Instance Type:
Pick t2.micro (also free tier!).


3️⃣ Configure Instance Details πŸ› οΈ

  • Number of instances: 1
  • Network: Default VPC
  • Subnet: Pick one (closest to your region)

πŸ’‘ You can leave most settings as default.


4️⃣ Add Storage πŸ’Ύ

Default: 8GB is fine for small apps.


5️⃣ Add Tags 🏷️

Example:
Key: Name
Value: MyFirstEC2

(Helps you identify your instance later!)


6️⃣ Configure Security Group πŸ”

πŸ‘‰ Allow SSH (port 22) so you can connect.
πŸ‘‰ Allow HTTP (port 80) if you’re hosting a website.
πŸ‘‰ Optional: Allow HTTPS (port 443) for secure sites.

(⚠️ Always be careful with securityβ€”don’t allow too much open access!)


7️⃣ Launch πŸš€

  • Click β€œLaunch.”
  • Choose β€œCreate new key pair.”
  • Download the .pem file (IMPORTANT: Keep this safe!).

🌍 Understanding EC2: Instance Types, Regions & Zones

πŸ”‘ ConceptπŸ“ What It Means
Instance TypeThe β€œpower level” of your server (CPU, RAM). Example: t2.micro.
RegionThe country/area where your server is. Example: Asia Pacific (Mumbai).
Availability ZoneA data center in your region (for high availability).

πŸ‘‰ Tip: Always choose a region near your users for best speed! ⚑


πŸ”— How to Connect to Your EC2 Instance (SSH)

You’ve launched your EC2β€”yay! πŸŽ‰ Now let’s log in to your cloud server.

1️⃣ Open Terminal (Mac/Linux) or PowerShell (Windows)

2️⃣ Use SSH Command

Example:

bashCopyEditssh -i /path/to/your-key.pem ubuntu@your-ec2-public-ip

πŸ‘‰ Replace:

  • /path/to/your-key.pem = Your downloaded key file path.
  • your-ec2-public-ip = Find it in EC2 dashboard (Public IPv4).

πŸ’‘ First time? It might ask:
Are you sure you want to connect?
Type: yes βœ…


πŸ” Set Up Security Credentials

Remember: Never share your .pem file or your server IP publicly! 🚨

You can also:

  • Create IAM roles/users for better access control.
  • Set up firewall rules (in Security Groups).

Ec2 Setup Flow
5.2. Aws Ec2 – Virtual Servers In The Cloud πŸš€ 2

1️⃣ Create EC2
2️⃣ Configure security πŸ”
3️⃣ Launch πŸš€
4️⃣ Connect via SSH πŸ”—
5️⃣ Host your app 🌍


🏁 Conclusion: Your First EC2 Server Is Live! πŸš€

Awesome job, coder fam! πŸŽ‰ You just set up a real cloud server using EC2. 😎

Now you can:

  • Host websites
  • Run backend apps
  • Experiment with servers like a pro developer. πŸ’»

πŸ‘‰ In the next guide, we’ll deploy a React app to your EC2 & make it live for the world. 🌎


βœ… Don’t miss out! Subscribe & follow:

Share the Post:
Picture of Web Codder

Web Codder

Vikas Sankhla is a seasoned Full Stack Developer with over 7 years of experience in web development. He is the founder of Web Codder, a platform dedicated to providing comprehensive web development tutorials and resources. Vikas specializes in the MERN stack (MongoDB, Express.js, React.js, Node.js) and has been instrumental in mentoring aspiring developers through his online courses and content. His commitment to simplifying complex web technologies has made him a respected figure in the developer community.

Related Posts