My use case is a little different than what Terraform is designed for. I want to set up a service similar to Runcloud, Cloudways etc. So potentially thousands of customers each having one or more VPS servers. I want to use Terraform for setting up and tearing down the server for each customer on any one of maybe 4 major cloud providers. Just like how Runcloud and Cloudways do it. So I basically want to use Terraform as the abstraction layer between 4 or 5 different major cloud providers instead of having to connect to each providers API separately and then having to write my own abstraction layer.
How would I do something like this using Terraform? Terraform is designed for infrastructure described in a few state files. I am looking to do tiny micro infrastructures (mostly just one or 2 VPS servers per customer) described in potentially thousands of state files, presumably one for each customer. I don’t think terraform workspaces is the right separation method because the separation is not strong enough.
My current thinking is to create a separate remote state bucket folder for each customer. That customer folder will probably just contain the customers state file which will typically describe just one or more fairly generic VPS servers. Will this work even though Terraform is not really designed with this sort of use case?
The other part of it I haven’t bothered to mention is that I will also combine it with Ansible for setting up apps inside the server once Terraform sets up the server and installs SSH keys and then provides Ansible with the server IP address. That should not be a problem.
Right now, the plan is to run all the command line stuff using Jenkins. So the logical workflow will be:
My User CP website > My Backend > Jenkins > Terraform + Ansible > (Google Cloud or AWS or DigitalOcean or Linode) VPS server(s)