GCP Workspace Provisioning: Subnet IAM Permission Errors with Terraform
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi everyone,
I'm provisioning a Databricks workspace on GCP using Terraform with the databricks_mws_workspaces resource and an existing customer-managed VPC.
During workspace provisioning, I'm encountering the following permission errors:
compute.subnetworks.getIamPolicy
compute.subnetworks.setIamPolicy
iam.roles.get
Current understanding of the issue
Databricks uses compute.subnetworks.setIamPolicy to grant its workspace service account permission to use the workspace subnet during workspace provisioning.
My understanding is that the following permissions are required:
compute.subnetworks.getIamPolicy and compute.subnetworks.setIamPolicy on the Databricks workspace subnets only.
roles/iam.roleViewer on the host project to provide the iam.roles.get permission.
The proposed approach is to grant these permissions to deployment service account only on the Databricks subnets:
europe-west1-data-platform-databricks-ws1
europe-west1-data-platform-databricks-ws2
europe-west1-data-platform-databricks-ws3
europe-west1-data-platform-databricks-ws4
europe-west1-data-platform-databricks-ws5
This would follow a least-privilege approach, restricting subnet IAM policy management to the specific Databricks subnets rather than granting broad permissions at the host project level.
However, I'm currently unable to obtain compute.subnetworks.setIamPolicy permission from the Cloud/Network team due to their IAM restrictions.
Alternative approach under consideration: Least-Privilege Workspace
I'm considering moving from the current databricks_mws_workspaces Terraform-based provisioning approach to Databricks' GCP Least-Privilege Workspace creation workflow.
My understanding is that this approach separates workspace creation permissions from the permissions required by the workspace service account and allows network permissions to be provisioned separately.
Questions
Is granting compute.subnetworks.getIamPolicy and compute.subnetworks.setIamPolicy at the individual subnet level, along with roles/iam.roleViewer at the host-project level, the correct and recommended approach for the existing databricks_mws_workspaces Terraform workflow?
Can these permissions be restricted to individual subnets using a custom IAM role, without requiring broader Compute Network Admin or Project IAM Admin permissions?
Would migrating to the GCP Least-Privilege Workspace workflow eliminate the need for the workspace deployment service account to have compute.subnetworks.setIamPolicy permission?
In the Least-Privilege Workspace approach, can the Cloud/Network team pre-provision the required subnet IAM bindings for the Databricks workspace service account, while the Databricks team retains responsibility for workspace provisioning?
Are there any limitations or differences in using an existing customer-managed VPC with the Least-Privilege Workspace workflow compared with the traditional databricks_mws_workspaces approach?
I'd appreciate guidance from anyone who has implemented GCP Databricks workspace provisioning with strict IAM separation and least-privilege access.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
In the standard databricks_mws_workspaces flow, granting setIamPolicy on the subnets won't be enough on its own. The least-privilege workspace (LPW) flow does remove the need for that permission.
Why the standard flow keeps failing
In the standard flow, Databricks uses the creator's credentials to create a custom Network role in the VPC (host) project and bind it to the subnet. The workspace creation permissions doc lists what the creator needs on the VPC project: - compute.subnetworks.get/getIamPolicy/setIamPolicy - iam.roles.create/get/update - compute.firewalls.get/create/update and compute.networks.updatePolicy
roles/iam.roleViewer only gives you iam.roles.get, so you'd hit the next error right away. You can put the subnet IAM permissions in a custom role and bind it at the subnet level. The iam.roles.* and firewall permissions are project-level, though, so you still need host-project grants. Databricks recommends roles/owner on both projects for this flow.
Least-privilege workspace
In the LPW flow, the creator's host-project role is read-only. It includes compute.subnetworks.getIamPolicy and iam.roles.get, but not setIamPolicy. Instead, your network team:
- Creates lpw.databricks.network.role.v2 in the host project (the permissions are listed in the docs).
- Pre-creates the firewall rule: INGRESS, priority 65534, source set to the subnet range, all protocols allowed.
- After the workspace is created and returns workspace_service_account, binds the role on each subnet:
gcloud compute networks subnets add-iam-policy-binding europe-west1-data-platform-databricks-ws1 \ --project=<host-project-id> --region=europe-west1 \ --member="serviceAccount:<workspace_service_account>" \ --role="projects/<host-project-id>/roles/lpw.databricks.network.role.v2"
The docs describe LPW through the Account API, so check whether your Terraform provider version supports it before you switch.