Safeguard
Security Guides•

Are Terraform workspaces a security boundary between environments?

Terraform CLI workspaces share one backend and one set of credentials, so they are not an isolation boundary. How to separate prod from dev properly.

Safeguard Security Team
3 min read

No. Terraform CLI workspaces are named sets of state inside one backend, using the same credentials. HashiCorp's documentation says workspaces are not appropriate for deployments requiring separate credentials and access controls. If prod needs isolation from dev, separate the backends and the identities, not just the workspace name.

What a workspace is

Every Terraform configuration has one backend. Workspaces are named state files within it. You start in the default workspace, and terraform workspace new adds more. A plan in a new workspace does not touch resources in other workspaces, but those resources continue to exist.

This is handy for short-lived copies of the same configuration, such as a feature environment, where you can vary counts or tags using the workspace name.

Why it is not isolation

Everything below stays shared across workspaces:

  • The backend. Anyone who can read or write the bucket can reach every workspace state, usually by changing a path.
  • The credentials. The documentation says you can deploy multiple instances without changing authentication credentials. That is convenient, and it means a mistake or a compromise in one workspace carries the same permissions into the others.
  • The code. The same configuration produces every environment, so a bad merge affects them together.

A typo in terraform workspace select can also point a destroy at production. Humans make that class of mistake regularly.

Patterns that do isolate

NeedApproach
Different people or pipelines for prodSeparate backend, separate role, separate pipeline
Blast radiusSeparate cloud accounts or subscriptions per environment
Config divergenceA directory or module call per environment, same modules
Short-lived copiesWorkspaces are fine, within one trust level

The key rule: the identity running prod applies should not be able to read or modify dev state, and the reverse. Different cloud accounts with their own deploy roles do this well.

A middle path

Many teams use one module and one root directory per environment. Each root has its own backend configuration and its own deploy role. Changes to the shared module are promoted by bumping a pinned version, which gives a natural promotion gate.

What to check in review

  1. Does the pipeline for production use a role that dev pipelines cannot assume?
  2. Is the production backend readable only by that role and a small set of humans?
  3. Are workspace names used for anything security relevant, like selecting an account? If so, treat that as a smell.
  4. Can a destroy run against production from a developer laptop?

Safeguard's policies and gates can hold pull requests to rules about protected environments, while asset discovery helps you see what actually exists in each account.

Quick check

Can I use workspaces for dev, staging and prod if each has its own tags?

You can, but it gives no access control separation. Tags do not change who can read state or deploy. Use separate backends and roles for anything that needs isolation.

Are HCP Terraform workspaces the same thing?

No. HashiCorp notes that CLI workspaces are different from HCP Terraform workspaces, which have their own access controls.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.