Using Workspaces
Learn when to use Terraform workspaces and their types.
We'll cover the following
When to use Terraform workspaces
Terraform workspaces are commonly used in large organizations to delegate responsibilities and roles to different team members. Each team would be granted permission to perform updates on workspaces related to their role. Additionally, production and staging type environments may have different permissions applied to their workspaces to further restrict who can deploy updates to these sensitive environments.
The current workspace
name is stored locally in the .terraform
directory. This allows multiple team members to work in different workspaces concurrently.
Types of workspaces
Let’s assume we’re working in a large organization. In this organization, there’s a networking team, a governance team, and an application team. There are also multiple environment types, like production, staging, and development.
Each team is responsible for its own Terraform configurations that create and manage their respective components. In order to separate roles and permissions across all environments and configurations, we could create the following workspaces:
networking-dev
networking-stage
networking-prod
governance-dev
governance-stage
governance-prod
application-dev
application-stage
application-prod
This will keep each team’s work separate (even if it’s contained in the same repository) and allow for independent progression through the development and staging of changes.
Get hands-on with 1400+ tech skills courses.