Should I use Terraform or Vagrant for localhost dev env?

Hi, which one is a better solution for localhost setup, please? Ideally something that can be added to repo, and everyone on the team can get up and running with one command basically.

I think we used Vagrant in the past, but isn’t it overkill, and best practices moved elsewhere already? It requires whole VirtualBox, doesn’t it?

Terraform seems more like deployment config tool. I don’t know much about Terraform, guessing from looking at the docs. Am I right?

Thank you for help and recommendations!

1 Like

It really depends what you are trying to setup, and it might be that neither of those options fit.

As you mention Vagrant is useful to manage VMs (although it can also manage Docker containers too). Terraform is often for creating long lived infrastructure (so again it could create VMs or Docker containers, as well as Kubernetes objects, cloud infrastructure, etc.)

What are you hoping that your “one command” actually achieves?

Are you looking to run your application locally? Create developer specific infrastructure in a cloud? Install development tools locally? Checkout application code ready for usage?

Thank you. What I’m trying to achieve locally: a guy in the team is developing frontend. I want to clone his repo and get up and running with single command, ideally without polluting my machine, fiddling with versions of node, react, vue, postgres, all those crazy frontend tools like webpack and whatnot - basically I don’t care what stack he uses, I just want to be able to quickly jump in and fix small bugs.

That sounds like something that Docker could be useful for. You’d pull down images containing the correct versions of the database, node, etc. and mount in your checked out code. We do something similar, however we use docker-compose to manage this rather than Vagrant or Terraform.

that sounds good. docker has become de-facto standard. I always had some trouble configuring file system access and being able to just open editor and tweak the code, but I guess that has some simple solution. If I understand correctly, the ideal solution that is achievable is to have a repo that I can clone and just run docker-compose up , right?

That’s what we have yes. The code repo for the application also contains a docker-compose.yaml file detailing what is needed to run it locally. Then the developer can just run docker-compose up to start all the different bits, including mounting the code that they are working on. Depending on the language being used subsequent changes might be instantly applied, might need a container restart or might need a compilation step (which might be done via your IDE) and a container restart.