This repository provides a Terraform module to create and manage Microsoft Fabric workspaces and workspace role assignments.
- Creates or updates Fabric workspaces with the
microsoft/fabricprovider. - Assigns workspace roles for four role types:
AdminMemberContributorViewer
- Supports principal resolution for role assignments:
User: byidorupn/emailGroup: byidor group email alias lookupServicePrincipal: byidServicePrincipalProfile: byid
- Applies deterministic workspace naming and lowercases names automatically.
- Appends a default description postscript:
"{workspace-name} created by Terraform."
- Supports capacity assignment modes:
best_effort(skip capacity attachment during workspace create)strict(attempt capacity attachment)
- Exposes diagnostics outputs for desired vs actual names and role assignment counts.
Workspace names are generated from:
{department}-{team}-{project-name}-{env}
Rules:
- Lowercase enforced.
- Non-alphanumeric separators in
project_nameare normalized. project_nameis rendered in kebab-case.
Example:
department = "Data"team = "Platform"project_name = "Analytics Workspace"env = "dev"
Result:
data-platform-analytics-workspace-dev
auth_mode supports:
user: use Azure CLI context (az login)service_principal: useservice_principal_info.app_idandservice_principal_info.secret
Both require tenant_id.
Workspace definitions are loaded from a JSON file path provided by workspaces_file.
Each workspace object includes:
project_namedescription(optional)env(dev,test,prod,sta)departmentteamcontacts(optional)capacity(optional)accesswith role buckets (admins,members,contributors,viewers)
Recommended principal object shape in access arrays:
{
"type": "User",
"upn": "[email protected]"
}{
"type": "Group",
"upn": "[email protected]"
}{
"type": "ServicePrincipal",
"id": "00000000-0000-0000-0000-000000000000"
}- Configure input values in
terraform.tfvars. - Provide a workspace definition JSON file and point
workspaces_fileto it. - Run Terraform from your execution environment:
terraform init -upgrade
terraform validate
terraform plan
terraform applytenant_idauth_modeservice_principal_infoworkspaces_filecapacity_assignment_mode
workspace_namesworkspace_idsworkspace_source_fileworkspace_name_diagnosticscapacity_assignment_notesworkspace_role_assignments_reported_by_fabric
These outputs are intended to make troubleshooting straightforward in CI or remote VM execution contexts.