Terraform workspace
A named, separate state within one backend, so the same configuration can manage several copies of its infrastructure.
In more detail
Every configuration starts in the workspace called default, and terraform.workspace returns the current name. Workspaces share the backend and its credentials, so HashiCorp recommends separate configurations, not workspaces, when environments need strong isolation such as production. Do not confuse them with the similarly named workspaces in HashiCorp's hosted service, which work differently.
Example
terraform workspace new staging
terraform workspace select stagingRelated terms
- Terraform backend — The setting that decides where Terraform stores state and how it locks it, from a local file to shared cloud storage.
- Terraform state — Terraform's record, usually a JSON file called terraform.tfstate, mapping each resource in the configuration to the real object it created.
- environment — One place where a copy of the application runs with its own config, such as development, staging or production.
Taught in
- Initialising The Working Directory — Infrastructure as Code with Terraform
- Workspaces For Multiple Environments — Infrastructure as Code with Terraform
- The Plan That Wanted To Destroy Production — HashiCorp Terraform Associate (004) Exam Prep
- The Local Backend, And Workspaces On One Machine — HashiCorp Terraform Associate (004) Exam Prep
- State Locking: One Writer At A Time — HashiCorp Terraform Associate (004) Exam Prep
- Remote State With The Backend Block — HashiCorp Terraform Associate (004) Exam Prep
- Drift: When Reality Stops Matching State — HashiCorp Terraform Associate (004) Exam Prep
- Moved And Removed Blocks: Refactoring Without Rebuilding — HashiCorp Terraform Associate (004) Exam Prep
- Verbose Logging: TF_LOG And Friends — HashiCorp Terraform Associate (004) Exam Prep
- Runs In HCP Terraform: The cloud Block And Remote Execution — HashiCorp Terraform Associate (004) Exam Prep