All Tools View Categories About Contact Privacy

Terraform Workspace / Multi-Environment Generator

Scaffold a workspace-based dev/staging/prod layout keyed by terraform.workspace.

Runs entirely in your browser - nothing is uploaded and no cloud connection is made.
Your generated scaffold will appear here.

About Terraform Workspace / Multi-Environment Generator

Managing multiple environments such as development, staging and production with Terraform is one of the most common sources of friction for infrastructure teams. Copying entire configuration directories for each environment leads to configuration drift, duplicated code and painful merge conflicts that are hard to reconcile later. Terraform workspaces solve this by keeping a single configuration while maintaining completely separate state files for each environment. This generator scaffolds a complete, production-ready workspace layout: a terraform.tf whose backend key or prefix is automatically keyed by terraform.workspace, a providers.tf, a variables.tf that exposes the current workspace as an environment variable, and a main.tf that names resources after the active workspace. It also emits the exact terraform workspace new and terraform workspace select commands you need for every environment you choose. Everything is generated in your browser, so nothing is uploaded and no cloud connection is ever made. Reach for this tool whenever you want isolated state per environment without maintaining several near-identical repositories or copy-paste directories. It is especially useful when onboarding a new service, standardising a team workflow, or teaching the workspace pattern to engineers who are new to Terraform. Note that workspaces share the same code, so they suit environments that differ mainly by variables; when environments need entirely different resources, consider separate configurations instead. Because the generated files follow Terraform conventions exactly, you can drop them straight into an existing repository, commit them, and run a pipeline without further edits.

Features

  • Single configuration - one set of dot-tf files drives every environment.
  • Workspace-aware backend - the state key or prefix uses terraform.workspace automatically.
  • Multiple backends - S3, GCS, Azure Blob and local backends are supported.
  • Provider choices - aws, azurerm, google and a generic null_resource fallback.
  • Per-environment commands - generates workspace new and select for each chosen environment.
  • Environment variable - a variable named environment defaults to terraform.workspace.
  • Workspace-named resources - sample resources are tagged and named by the active workspace.
  • Export options - copy, download or print the full scaffold.
  • No dependencies - pure browser-side HCL generation.
  • Private by design - nothing leaves the page.
  • Consistent tagging - the generated assets carry an Environment tag for cost tracking.
  • Repeatable output - the same inputs always produce the same scaffold.
  • Backend portability - switch backends without rewriting resource code.
  • Clear separation - selection commands prevent accidental cross-environment applies.

How to Use

  1. Name the project - enter a short slug used in bucket keys and resource names.
  2. Pick a provider - choose aws, azurerm, google or generic.
  3. Pick a backend - choose s3, gcs, azurerm or local.
  4. Select environments - tick dev, staging and/or prod.
  5. Review the inputs - confirm provider, backend and environment selection.
  6. Generate - click Generate to build the scaffold and commands.
  7. Inspect the output - check the directory layout and terraform blocks.
  8. Copy the commands - run the printed workspace new and select lines in order.
  9. Apply safely - select a workspace, then run terraform plan or apply against it.
  10. Export - copy, download or print the result for your repository.

Examples

Worked example - a project named shop using the aws provider and the s3 backend with dev, staging and prod selected produces a backend key of shop/${terraform.workspace}/terraform.tfstate. The generated main.tf creates an aws_s3_bucket named assets whose bucket is ${terraform.workspace}-shop-assets and whose tags include Environment = ${terraform.workspace}. Finally the tool prints terraform workspace new dev, terraform workspace new staging and terraform workspace new prod followed by the matching select commands, giving you a complete bootstrap sequence you can paste into a terminal. After selecting a workspace, a normal terraform apply targets only that environment state, so mistakes in dev never touch prod. The variables.tf block means var.environment is always the current workspace name, which you can reuse across modules.

Benefits

  • State isolation - each environment keeps its own state file.
  • Less duplication - a single configuration replaces many copies.
  • Consistency - every environment is built from the same source.
  • Portability - the output works with any supported backend.
  • Privacy - generation runs entirely in the browser.
  • Onboarding speed - new engineers get a correct layout in seconds.
  • Lower risk - explicit workspace selection reduces wrong-environment deploys.
  • Auditability - the generated commands make environment setup easy to review and repeat.

Frequently Asked Questions

What does this generate?
A single Terraform configuration (terraform.tf, providers.tf, variables.tf, main.tf) whose backend key and resource names are keyed by terraform.workspace, plus the workspace new/select commands for each chosen environment.
Why workspaces?
Workspaces keep one configuration but maintain separate state per environment, so dev/staging/prod stay isolated without duplicating files.
Which backends are supported?
S3, GCS, Azure Blob (azurerm) and local. The backend key/prefix uses ${terraform.workspace} automatically.
Which providers?
aws, azurerm, google and a generic null_resource fallback for the sample resource.
Does this connect to a cloud?
No. It only builds the HCL text and commands in your browser.
Can I download it?
Yes. Copy, download or print the generated scaffold.