DEV Community

Cover image for 🚀Migrating from Heroku to AWS with Terraform — A Real-World Guide
Hasnain – DevOps @ Hybytes
Hasnain – DevOps @ Hybytes

Posted on • Edited on

🚀Migrating from Heroku to AWS with Terraform — A Real-World Guide

As businesses grow, platforms like Heroku often become limiting. You start to feel the need for more control over networking, infrastructure, security, and scalability. That’s exactly where AWS comes in — but transitioning from a PaaS like Heroku to a powerful IaaS like AWS can feel overwhelming.

At Hybytes, we’ve helped several teams migrate from Heroku to AWS using Terraform, and in this post, I want to share a breakdown of how to approach this migration in a structured, repeatable way.

🔍 Why Migrate?

Heroku is great for getting started fast. But for growing teams, it brings challenges like:

  • High costs at scale
  • Limited infrastructure control
  • Vendor lock-in
  • Basic security/compliance tools

AWS provides the flexibility and scale you need — but requires good DevOps practices.

🛠️ Our Approach Using Terraform

We used Terraform to provision and manage infrastructure across:

  • VPC, Subnets, Security Groups
  • Amazon RDS (PostgreSQL)
  • Amazon ECS/Fargate for containers
  • SSM Parameter Store for config and secrets
  • ALB + Route 53 for traffic routing

We broke down the migration into clear stages: infrastructure setup, data migration, containerization, CI/CD pipeline, then DNS cutover.

đź§  Lessons Learned

  • Always start with a staging environment before going live
  • Use Terraform workspaces to manage multiple environments
  • Set up CloudWatch and cost alerts from day one
  • Replace Heroku Config Vars with SSM parameters securely

đź§© Tools We Used

  • Terraform
  • GitHub Actions for CI/CD
  • Docker + Amazon ECR
  • pg_dump / pg_restore for PostgreSQL migrations
  • Datadog for monitoring

📦 Final Thoughts

Moving from Heroku to AWS isn’t just a technical migration — it’s a shift in how your team builds and operates. With Terraform, it becomes much more manageable, auditable, and scalable.

We’ve documented our full guide here:
👉 Read the full post on Medium

If you're planning something similar, feel free to connect. I’d love to share ideas or collaborate on content!

Top comments (0)