Why Terraform workspaces are the wrong way to separate FDE clients
HashiCorp says workspaces don't suit deployments needing separate credentials, which is nearly every client; modules are what keep the fifth rollout identical to the first.
In brief
- Terraform describes the desired state; providers let one workflow cover almost any platform with an API that a customer runs
- Package the standard stack as a module; for_each repeats it well within one credential boundary, while customers who need their own credentials get one root config and one backend each, all calling the same module
- State must be stored remotely with locking and access control; HashiCorp does not recommend workspaces for deployments that need separate credentials
The first trap in building infrastructure for your second customer sits right in Terraform’s official documentation. Workspaces let one configuration be tied to several states, which sounds a lot like “one copy per customer”. Yet HashiCorp itself states plainly that workspaces are not suitable for deployments that need separate credentials and access controls.
And separate credentials are close to the definition of FDE work. You take the same product into customer A’s environment, then customer B’s, then customer C’s, each with its own cloud account, its own permissions and its own security requirements. The question is not whether to use Terraform, but how to arrange it so that the fifth deployment still looks like the first.
One workflow for every platform a customer runs
According to HashiCorp’s documentation, Terraform is an infrastructure-as-code tool for building, changing and versioning cloud and on-prem resources, described in shareable configuration files. The key point is that the configuration is declarative: you describe the desired state, and Terraform works out the steps.
For an FDE, the benefit is that the infrastructure blueprint lives in git, where it can be reviewed and diffed, rather than in the memory of whoever installed it for the first customer.
Providers are what let Terraform keep up with the variety of customer environments. HashiCorp describes providers as allowing Terraform to work with virtually any platform or service with an accessible API. One customer runs on cloud, another on-prem, a third wants to connect a few SaaS tools as well: one workflow, many providers, the same way to plan and apply.
The module is the unit of repetition, not copy-paste
HashiCorp says it directly in its module documentation: for infrastructure you provision repeatedly, write reusable modules to codify it. It also argues that modularising and sharing configuration standardises provisioning, so teams get resources quickly and predictably. That is precisely the FDE problem: one standard stack, built many times.
Imagine you have a customer_stack module that takes a customer name, a region and a size. The most familiar way to call it is a map and a single for_each line:
module "customer" {
for_each = var.customers # map: customer name -> config
source = "./modules/customer_stack"
name = each.key
region = each.value.region
}
According to the documentation, the for_each meta-argument accepts a map or a set of strings and creates one instance for each element. Adding a customer means adding an entry to the map; changing the standard stack means changing one place in the module.
But look closely: for_each lives within one configuration, and according to the state documentation, one configuration is tied to one state unless you use workspaces. It follows that a single apply touches the infrastructure of every customer in the map, and unless you deliberately split credentials per customer inside that configuration, everything goes through the same set of credentials.
This approach works when everything sits within one trust boundary, such as several environments for the same customer, or several customers you host together in your own account.
For customers who demand their own credentials, exactly the case HashiCorp has in mind when it warns about workspaces, the more sensible approach is one root directory and one backend per customer, all calling the same module. The difference between customers then shrinks to a few lines of variables in their directory; the standard stack stays in one place.
Workspaces are not a way to separate customers
Only now do we reach state. State is what maps configuration to real resources; HashiCorp recommends storing it in HCP Terraform or a remote backend for secure storage and collaboration, and warns against backends without locking or access control. For a customer’s infrastructure data, this is not optional.
This is where many people reach for workspaces. The documentation confirms that some backends support multiple named workspaces, allowing several states to be associated with one configuration. But the same page states clearly that workspaces are not suitable for decomposing a system or for deployments that need separate credentials and access controls.
Enterprise customers rarely accept credentials shared with another customer.
Put those two warnings together and the safe approach is fairly clear: repeat configuration through modules, but separate state and credentials at the backend level, with each customer getting a remote state that has locking and its own permissions. Workspaces still have a place when every copy runs on the same set of credentials; the boundary between two companies, by HashiCorp’s own account, is not that place.
Licensing is a question customers will ask
There is one non-technical detail an FDE should know by heart. On 10 August 2023, HashiCorp moved Terraform and its other core products from MPL 2.0 to the Business Source License, while keeping APIs, SDKs and most libraries under MPL 2.0.
On 25 August 2023, the community announced OpenTofu, a fork of Terraform, stating that it had completed its application to join the Linux Foundation and aimed to move towards the Cloud Native Computing Foundation.
If a customer has a policy of using only open-source software, OpenTofu is the main option to put forward. Have both dates ready, along with a clear view on which tool to choose, before the customer raises it in an architecture review.
What to learn first, and what to put on your CV
The sensible order is declarative thinking first, then providers, then modules, then state. Plenty of capable developers still think in terms of sequential scripts, and Terraform will frustrate them until they accept that they only describe the desired state.
After that, make yourself write a module for the stack of the product you are working on, and call it from two root directories for two hypothetical customers. It is a small exercise, but it hits exactly what an FDE does every day.
On your CV, do not write “knows Terraform”. Write that you packaged a stack into a reusable module and deployed it for N customers using separate root configs, with separate, locked remote state. That sentence tells a recruiter you have walked past exactly the trap the documentation warns about.
The second customer is always the real test. If building for them is just a new directory calling the existing module plus a new backend, you have what HashiCorp calls standardised, predictable provisioning.
Was this article useful?
Thanks for the feedback!
7 sources
- What is Terraform | Terraform | HashiCorp Developer
- Modules overview | Terraform | HashiCorp Developer
- for_each meta-argument reference | Terraform | HashiCorp Developer
- State: Workspaces | Terraform | HashiCorp Developer
- State | Terraform | HashiCorp Developer
- HashiCorp adopts Business Source License · 2023-08-10
- OpenTofu Announces Fork of Terraform · 2023-08-25