Table of Contents

The Error

Error: Workspace production does not exist

What Causes This

The workspace hasn’t been created yet, or you’re referencing a workspace in a different backend.

How to Fix It

Solution 1: Create the Workspace

terraform workspace new production
terraform workspace select production

Solution 2: Auto-Create in CI/CD

terraform workspace select $ENV 2>/dev/null || terraform workspace new $ENV

Solution 3: Use workspace in Config

resource "aws_instance" "web" {
  instance_type = lookup({dev="t3.micro", prod="t3.medium"}, terraform.workspace, "t3.micro")
}

Prevention Tips

  1. Pin provider versions — avoid surprise breaking changes
  2. Use CI/CD — catch errors before they hit production
  3. Test with terraform plan — always review before applying
  4. Keep Terraform updated — newer versions have better error messages
  5. Use terraform validate — catches syntax errors early

Hands-On Courses

Conclusion

This error is common and fixable. Follow the solutions above, and check our Terraform course for hands-on training that covers real-world troubleshooting scenarios.