Allow you to store your Terraform state in multiple, separate, named workspaces.
Terraform starts with a single workspace called default
.
terraform workspace
CLI commands are used to control workspaces.
Backend files structure
When using workspaces, Terraform will create a directory end:/
And inside this directory the name of the workspace will be prefixed before specified backend key
value:
This way, if the configuration of the Terraform s3
backend is specified as:
The path to the Terraform state file for the dev
workspace will be: env:/dev/services/users/terraform.tfstate
Create new workspaces
Switch between workspaces
Access workspace name in the configuration
Use terraform.workspace
variable.