Vsphere terraform - best practices and how to manage - help

Hey everyone,

I’m currently tasked with moving about 2,000 VMs over to Terraform. Most of these are for our devs, and they’re organized in vSphere folders by username (e.g., Devs/jsmith/vm-01).

I’m trying to avoid a “copy-paste”, so I’m thinking about this setup:

  • Global Module: One master VM module that handles all the vSphere heavy lifting.

  • T-Shirt Sizing: A global map (Small, Medium, Large) so I can standardize resources across the whole fleet in one place.

  • The Workflow: I want to manage everything through terraform.tfvars. If a dev needs a VM, I just add an object to a map in the vars file. If they’re done, I delete that line.

With 2k VMs, a single state file sounds like a performance nightmare. Should I break these into multiple “Dev” folders with separate state files to keep terraform plan fast or maybe one state file per developer folder?

As backend I am planning to use MinIO, any tips on handling state locking or specific S3 endpoint configs I should watch out for?

What’s the best way to handle the Devs/<username> path dynamically so Terraform doesn’t trip over itself if a folder doesn’t exist yet?

I’ll be grateful for all advices.

Thank you so much :slight_smile: