DEV Community

Cover image for Deploying NoteZipper on AWS: A Complete Infrastructure Guide ๐Ÿš€
Haripriya Veluchamy
Haripriya Veluchamy

Posted on

Deploying NoteZipper on AWS: A Complete Infrastructure Guide ๐Ÿš€

Hey there, fellow developers! ๐Ÿ‘‹ Today, I'm super excited to share my journey of setting up a robust AWS infrastructure for the awesome NoteZipper application using Terraform. If you're looking to level up your DevOps game while working with MERN stack applications, you're in for a treat! here is the repo of this project github and dont forget to check the video tutorial here

What's NoteZipper? ๐Ÿ“

Before we dive in, let me give you a quick intro - NoteZipper is this cool MERN stack notes application originally created by Piyush Agarwal. Think of it as your digital notebook, but with all the modern bells and whistles!

Why Terraform? ๐Ÿค”

You might be wondering, "Why bother with Terraform?" Well, let me tell you - managing cloud infrastructure manually is like trying to organize a library without a catalog system. It's messy, error-prone, and honestly, quite frustrating! That's where Infrastructure as Code (IaC) with Terraform comes in to save the day.

What We're Building ๐Ÿ—๏ธ

Our infrastructure setup includes:

  • An EC2 instance to host our application (our app's cozy home ๐Ÿ )
  • Security Groups for network access (our bouncer at the club ๐Ÿšช)
  • IAM roles and policies (our permission slip system ๐Ÿ“‹)
  • Environment configurations (our app's wardrobe for different occasions ๐Ÿ‘”)

Getting Started ๐ŸŒŸ

First things first, you'll need a few tools in your toolkit:

  1. Terraform (v1.0.0 or newer) - our infrastructure magic wand โœจ
  2. An AWS Account with CLI configured - your cloud playground
  3. MongoDB Atlas account - where our data lives
  4. Git - because, well, version control is life!

The Fun Part - Deployment! ๐ŸŽฎ

Here's how you can get everything up and running:

  1. Clone the repo and cd into it (your usual git dance ๐Ÿ’ƒ)
  2. Create a terraform.tfvars file with your secret sauce:
aws_region   = "us-east-1"
environment  = "dev"
mongodb_uri  = "your-mongodb-uri"
jwt_secret   = "your-jwt-secret"
Enter fullscreen mode Exit fullscreen mode
  1. Run these magical commands:
terraform init    # Get the party started ๐ŸŽ‰
terraform plan    # Preview the guest list ๐Ÿ“‹
terraform apply   # Let the show begin! ๐ŸŽญ
Enter fullscreen mode Exit fullscreen mode

Security First! ๐Ÿ”’

We're not leaving our application exposed! Our security groups are set up like a well-trained security team:

  • Port 5000: Backend API (VIP entrance)
  • Port 3000: Frontend Development (Main entrance)
  • Port 22: SSH access (Staff entrance)

Troubleshooting Tips ๐Ÿ”ง

Running into issues? Don't panic! Here are some common problems and their solutions:

  1. MongoDB Connection Issues ๐Ÿ”Œ

    • Double-check your MongoDB URI (typos are sneaky!)
    • Make sure your EC2 IP is whitelisted (don't leave your app locked out!)
  2. Application Not Starting ๐Ÿ˜ฑ

    • Check those logs (/var/log/user-data.log)
    • Verify Node.js is installed correctly

Image description
Image description

Time to Clean Up ๐Ÿงน

When you're done experimenting, don't forget to clean up:

terraform destroy    # Cleanup time! 
Enter fullscreen mode Exit fullscreen mode

Final Thoughts ๐Ÿ’ญ

Setting up infrastructure doesn't have to be scary or complicated. With tools like Terraform, we can make the process not just manageable but actually enjoyable! The best part? Once you've got this template set up, you can reuse it for other MERN stack applications with minimal modifications.

Remember, the cloud is your playground - don't be afraid to experiment and learn! ๐ŸŒˆ

Happy deploying! May your applications be scalable and your deployments be smooth! ๐Ÿš€โœจ

Top comments (0)