0PricingLogin
Terraform Infrastructure as Code · Lesson

Using Workspaces for Environments

Explore Terraform workspaces to manage separate states for different environments (e.g., dev, staging, prod) within the same configuration.

What are Terraform Workspaces?

Terraform workspaces help you manage multiple, distinct states for the same Terraform configuration. Think of them as separate environments like 'dev', 'staging', or 'prod'.

This means you can use one set of .tf files to deploy infrastructure to different places without changing your code, promoting reusability and consistency.

The 'default' Workspace

When you first initialize Terraform in a directory (using terraform init), you're automatically using the default workspace.

All your initial terraform apply operations will store their state in this default workspace, unless you create and select another one. It's always present!

All lessons in this course

  1. Introduction to Terraform Modules
  2. Creating Reusable Modules
  3. Using Workspaces for Environments
  4. Publishing Modules to a Registry
← Back to Terraform Infrastructure as Code