What is a workspace in Terraform?

A workspace in Terraform Cloud and Terraform open-source mean two slightly different things. For the certification, we’re focusing on the Terraform open-source option. Workspaces in Terraform open-source are independently managed state files that share a common configuration.

Note: In older versions of Terraform, a similar construct called an environment was managed using the terraform env command. That command still exists, but it’s essentially an alias for terraform workspace and may be deprecated in a future release.

Workspace for multiple environments

Many organizations have multiple environments, including development, testing, staging, and production. Each Terraform workspace is meant to represent the deployment of a configuration to one of these separate working environments. This enables us to use a single configuration to manage the same deployment in all environments, ensuring a high level of consistency as applications roll through the lower environments to production.

Get hands-on with 1200+ tech skills courses.