<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Josipa Radnić on Medium]]></title>
        <description><![CDATA[Stories by Josipa Radnić on Medium]]></description>
        <link>https://medium.com/@josipa.radnic?source=rss-83ac91922704------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*vDmcMBMXQTWokp7uLZsBsQ.jpeg</url>
            <title>Stories by Josipa Radnić on Medium</title>
            <link>https://medium.com/@josipa.radnic?source=rss-83ac91922704------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 20:05:01 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@josipa.radnic/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Databricks Terraform Resource Exporter: Lessons learned from a workspace migration to Unity Catalog]]></title>
            <link>https://medium.com/valcon-consulting/databricks-terraform-resource-exporter-lessons-learned-from-a-workspace-migration-to-unity-catalog-9494070cdbd3?source=rss-83ac91922704------2</link>
            <guid isPermaLink="false">https://medium.com/p/9494070cdbd3</guid>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[databricks-unity-catalog]]></category>
            <category><![CDATA[cloud-migration]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[databricks]]></category>
            <dc:creator><![CDATA[Josipa Radnić]]></dc:creator>
            <pubDate>Thu, 28 May 2026 12:24:00 GMT</pubDate>
            <atom:updated>2026-05-28T12:24:00.761Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uWL6eVhK9OKBeYAE4bft-Q.png" /></figure><h3>The context</h3><p>I was recently part of a team responsible for implementing Unity Catalog across multiple Databricks workspaces for a client in Financial Services — where secure, governed, cross-domain data access at scale is one of the biggest challenges. Depending on the workspace, the approach varied — some workspaces were UC-enabled in-place, while others required provisioning a brand-new UC-enabled workspace and migrating workspace objects into it. My colleague has written a great overview of the broader <a href="https://medium.com/valcon-consulting/unity-catalog-migration-best-practices-lessons-learned-from-two-implementations-part-1-f692811643a6">UC implementation and best practices</a> — worth a read for the full picture. Here, I want to zoom into the <strong>migration side</strong> specifically: <strong>consolidating two legacy exploration workspaces into a single, brand-new Unity Catalog-enabled workspace</strong>, and the tool that made it possible at scale — the <a href="https://registry.terraform.io/providers/databricks/databricks/latest/docs/guides/experimental-exporter"><strong>Terraform Resource Exporter</strong></a>.</p><p>Both source workspaces were shared across many teams and had accumulated hundreds of notebooks, jobs, repos, and workspace files, none of which were aligned with UC governance standards. As exploration environments, these workspaces evolved with minimal structure. A significant portion of the work lived only in the Databricks UI and was not tracked in Git, which meant we couldn’t rebuild the environment through repository-based deployment. Rather than remediating two unstructured, heavily used environments in-place, the decision was made to provision a clean UC-enabled workspace from scratch and migrate what had been agreed upon.</p><p>What follows are the concrete problems I ran into, how I solved them, and what I would do differently.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*exeDOBvN8k8wMkp0XbniNw.png" /><figcaption>Before and after: workspace consolidation</figcaption></figure><h3>Why Terraform Resource Exporter?</h3><p>When you need to migrate workspace objects at scale, manual recreation stops being realistic very quickly.</p><p>A Databricks workspace can contain a wide variety of resources — notebooks, jobs, clusters, cluster policies, repos, workspace files, dashboards, SQL endpoints, access permissions, and more — and in an active exploration environment, hundreds of these can accumulate across teams.</p><p>In this migration, the target workspace had its own UC-compliant cluster policies and compute configuration — that immediately made manual migration impractical.</p><p>Jobs are a clear example of how manual remapping was never going to be feasible, because hundreds of them are referencing cluster configurations that no longer exist in the new workspace.</p><p>The Terraform Resource Exporter — part of the Databricks Terraform provider — turned out to be the right tool for the job, exporting workspace objects as structured Terraform resource definitions and preserving resource dependencies, ensuring Terraform understands the correct creation order when applying to the target workspace.</p><p>One important caveat: <strong>this tool is still experimental</strong>.</p><p>It has rough edges, incomplete support for certain resource types, and inconsistencies in the generated output. Despite that, it proved to be a feasible automated path for a migration of this scope — and arguably the only realistic one even if alternatives existed, given the volume of resources involved.</p><p>If you are considering it, go in with that expectation and budget extra time for cleanup.</p><h3>What I migrated (and what I did not)</h3><p>Before running the exporter, a scoping decision had to be made on what actually needed to be migrated.</p><p>The exporter can export almost every workspace resource, but that does not mean everything should be migrated — a workspace consolidation is also a good opportunity to clean up resources that are outdated, unused, or simply not worth carrying forward into a fresh environment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DkWxJpzw12oqSrJovTHUsA.png" /><figcaption>Migration scope: what was and wasn’t migrated</figcaption></figure><p>Clusters, cluster policies, users, and groups were already configured in the target workspace — clusters and cluster policies were pre-provisioned to meet Unity Catalog’s compute requirements, while users and groups were set up as part of the standard workspace onboarding.</p><p>As you will see, this exclusion created its own set of challenges downstream.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X9cQXNRmx8kFlz2tgYtxoQ.png" /><figcaption>Migration phases: Export, Transform, Deploy</figcaption></figure><h3>Phase 1: Running the exporter</h3><p>The export was run against each source workspace independently.</p><p>Setup involves authenticating via the Databricks CLI and initializing the Terraform provider in the export folder. The exporter itself is not a standalone CLI tool — it is built into the Databricks Terraform provider binary, so you invoke it by calling the provider executable directly with the exporter subcommand.</p><blockquote><strong>Tip: </strong>Always use the latest version of the Databricks Terraform provider when running the exporter. Since this is an experimental tool that is actively being developed, newer versions often resolve issues that older ones do not. On this project, upgrading the provider version alone fixed several problems we had been troubleshooting for a while — it is worth checking before going too deep into debugging.</blockquote><p>One prerequisite that is easy to overlook: <strong>all work on the source workspaces must stop before the export runs.</strong> The exporter does have an <strong>incremental </strong>option, but it is not supported for all resource types — and given that the exporter itself is already an experimental tool, relying on an <strong>experimental feature within an experimental tool </strong>was not something we were willing to bet a production migration on.</p><p>Any changes made after the export snapshot will not be captured in the migration.</p><p>The practical options are:</p><ul><li>define a hard freeze date after which no changes are made</li><li>explicitly communicate that any work done after the export will need to be manually re-applied in the new workspace</li></ul><h3>The most important command</h3><p>The exporter invocation itself contains the most nuance.</p><ul><li>-listing defines which resource types are actively scanned and discovered from the workspace</li><li>-services controls which transitive dependencies are processed alongside them</li></ul><p>It is recommended to limit scope using -listing rather than -services, and both should be tailored to your specific migration needs.</p><p>Since the exporter is invoked directly via the provider binary, the command is constructed by pointing to the provider executable and passing the arguments explicitly:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BwG-uqFq8ZndVpQ5cbdhSw.png" /><figcaption>Terraform Resource Exporter invocation command</figcaption></figure><h3>Interactive vs. non-interactive mode</h3><p>This distinction is more important than it appears.</p><p>The exporter supports an interactive mode where it prompts you to confirm each resource category one by one.</p><p>The problem is that in interactive mode, regardless of whether you confirm every category or skip some, the exporter only exports jobs and their related dependencies — other resource types are not reliably generated.</p><p>The non-interactive command with explicit -services and -listing flags are what produces the full export across all listed resource types.</p><p><strong>Always use the non-interactive form </strong>in any repeatable or pipeline context<strong>.</strong></p><h3>Phase 2: The hard part — transforming the export</h3><p>The raw export output is not ready to apply to the target workspace.</p><p>This is where most of the real work happened, and where the Terraform Resource Exporter’s experimental nature becomes most visible.</p><p>Below I will walk through the transformations that were required in this specific migration — some of these will apply to any (UC) migration regardless of the project, while others are specific to this setup.</p><p>Either way, expect to spend meaningful time here.</p><h3>Resources vs. data sources</h3><p>The exporter generates everything as Terraform resource blocks — including users, groups, and cluster policies that already exist in the target workspace.</p><p>If you apply the output as-is, Terraform will attempt to recreate them and fail.</p><p>Any pre-existing resource needs to be converted to a data block so Terraform fetches it rather than tries to create it.</p><p>This is a mandatory transformation step that the exporter does not handle for you.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZfJR5p1vR2XSHnah8HJFTA.png" /><figcaption>Converting a resource block to a data source</figcaption></figure><h3>Job and cluster remapping</h3><p>This was the most complex transformation.</p><p>Every job in jobs.tf references a cluster and/or a cluster policy from the source workspace — neither of which exists in the target.</p><p>Because the target is UC-enabled, it also requires different cluster attributes compared to legacy environments.</p><p>Replacing cluster references is not a simple find-and-replace.</p><p>Every job task in the exported jobs.tf had either:</p><ul><li>an existing_cluster_id</li><li>a policy_id</li><li>or a full embedded cluster specification inline</li></ul><p>Those embedded specifications included:</p><ul><li>node types</li><li>Spark versions</li><li>cluster attributes</li><li>additional compute configuration</li></ul><p>None of those specifications were valid in the UC-enabled target workspace.</p><p>The entire embedded cluster configuration had to be removed and replaced with a reference to the appropriate cluster or cluster policy from the new workspace, including all the UC-compatible attributes that come with it.</p><p>This was not a field substitution — it was a full replacement.</p><h3>Naming collisions</h3><p>Because two workspaces were being merged into one, naming collisions were inevitable.</p><p>The behavior differs by resource type</p><ul><li>notebooks silently overwrite each other if they share the same path</li><li>jobs with duplicate names simply coexist as separate entries.</li></ul><p>Knowing this distinction matters before deployment.</p><p>For notebooks, the approach that worked well was:</p><p>1. Comparing source paths across both export folders</p><p>2. Identifying overlaps</p><p>3. Appending a workspace-specific suffix to conflicting filenames.</p><p>This needs to happen before deployment, not after.</p><h3>Non-migratable file types</h3><p>Workspace files with .whl, .jar, or .exe extensions could not be committed to Git and have caused pipeline failures if left in the exported configuration.</p><p>These had to be identified and filtered out of wsfiles.tf — the Terraform file generated by the exporter that contains all workspace file resources — before deployment.</p><p>It is also worth auditing the source workspace before running the export and removing any resources that have no place in the target. Filtering them out afterward is more work than cleaning them up upfront.</p><h3>Git credentials for repos</h3><p>Repos require a Git credential to exist in the target workspace before they can be created.</p><p>Beyond generating the credential resource, every repo block needed a depends_on reference to it.</p><p>There are two ways to define the credentials.</p><p>The first uses a <strong>hardcoded personal access token</strong> directly in the Terraform resource.</p><p>This works locally, but:</p><ul><li>a personal token should never be committed to version control</li><li>trying automated deployments to a personal account is a risk.</li></ul><p>A <strong>better approach</strong> is to:</p><ul><li>use the <strong>pipeline’s build service account</strong> as the Git username</li><li>reference the token as a sensitive Terraform variable</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mBDoYK5KoO4lBUgEHeVHkg.png" /><figcaption>Git credential resource and token variable definition</figcaption></figure><p>The variable itself holds no value — it simply tells Terraform to expect one from the environment.</p><p>The actual secret token lives in an <strong>Azure DevOps variable group</strong> (in this case named azure_devops_git_pat), stored encrypted in the <strong>Azure DevOps Library</strong>.</p><p>The variable group is linked to the pipeline, and at runtime the token is injected as an environment variable:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Rj_20WnksAW1-BKhNsIi9A.png" /><figcaption>Injecting the Git token at pipeline runtime</figcaption></figure><p>Terraforms TF_VAR_ prefix convention automatically maps TF_VAR_azure_devops_pat to var.azure_devops_pat — no -var flag or .tfvars entry needed.</p><p>The secret never touches any file in the codebase. The full chain looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*261l9ZnLcT6fJB3pD1Bs6g.png" /><figcaption>Secret token flow: from Azure DevOps Library to Databricks workspace</figcaption></figure><blockquote><strong>Tip: </strong>The volume of transformations required across all these files is large enough that writing an automation script to apply them consistently is well worth the investment.</blockquote><blockquote>Rather than manually editing hundreds of resource blocks,<strong> it is worth developing a script</strong> that lets you define each transformation rule once and apply it reproducibly across both workspace exports.</blockquote><h3>Phase 3: Deployment</h3><p>With transformed Terraform files ready, an Azure DevOps pipeline applied them to the target workspace using a:</p><ul><li>Plan</li><li>Manual approval</li><li>Apply</li></ul><p>structure.</p><h3>Pipeline timeouts</h3><p>The agent timeout in this environment was set to 60 minutes — not nearly enough to deploy everything in a single run given the number of resources involved.</p><p>When the pipeline timed out mid-execution, Terraform had already written the successfully applied resources to the .tfstate file.</p><p>Re-triggering the pipeline picked up from where it left off rather than starting over.</p><p>The practical solution was to simply keep re-triggering the pipeline until everything passed — and it took more than just a couple of runs.</p><p>An alternative approach would be to explicitly scope each terraform apply to a specific set of resources, which:</p><ul><li>gives more control</li><li>is easier to monitor</li><li>but is harder to define upfront.</li></ul><h3>Deployment order matters</h3><p>Jobs are dependent on notebooks, repos, and workspace files being present — and all of those depend on directories and access being in place first.</p><p>A safe deployment order to follow is:</p><p>1. <strong>Directories and access</strong> — everything else depends on these</p><p>2. <strong>Notebooks, workspace files, repos</strong> — can be deployed in parallel or sequentially</p><p>3. <strong>Jobs</strong> — last, once all their dependencies exist in the workspace</p><p>If you repeatedly re-trigger the pipeline without scoping, Terraform will naturally respect this order through its dependency graph — but being aware of it helps when diagnosing failures.</p><h3>Repos and parallelism</h3><p>The default parallelism of 10 caused frequent timeouts for repos specifically — during authentication, connections were timing out and Terraform was silently skipping those repos rather than retrying.</p><p>Setting -parallelism=1in terraform apply forced repos to be processed one at a time, giving each one enough time to authenticate and clone successfully.</p><blockquote><strong>Warning: </strong>Even after getting parallelism right and re-triggering the pipeline consistently, expect some repo deployments to fail — and accept that some of those failures are completely out of your control.</blockquote><blockquote>Branches that no longer exist, repositories that have been deleted, or repos that are inaccessible for permission reasons will all surface as errors.</blockquote><blockquote>These are not migration failures — they are stale references from the source workspace.</blockquote><blockquote>Treat them as a cleanup task to handle case by case, and do not let them block the rest of the migration.</blockquote><h3>Key takeaways</h3><p>If you take nothing else from this article, take these.</p><p><strong>The exporter is a starting point, not a finished product.</strong> Always budget time for post-export transformation. The output requires meaningful cleanup before it is safe to apply.</p><p><strong>Never use interactive mode for production migrations.</strong> It silently produces incomplete dependency graphs. Use the explicit non-interactive command with -services and -listing specified.</p><p><strong>Plan for agent timeout limits from the start.</strong> At scale, both the export and the deployment can exceed configured time limits. Design for incremental, resource-type-scoped runs from day one rather than trying to do everything in a single pipeline execution.</p><p><strong>Resources vs. data sources are the most important concept to understand.</strong> The exporter does not know what already exists in your target workspace. Blindly applying its output will cause failures. Audit which resources need to become data sources before you run terraform apply.</p><p><strong>Cluster remapping jobs is the hardest part of a UC migration.</strong> Every exported job task carries an embedded cluster specification that is invalid in a UC-enabled workspace. The entire configuration needs to be stripped and replaced with UC-compatible references — it is not a field substitution; it is a full replacement.</p><p><strong>Use service accounts for Git credentials in pipelines.</strong> Never commit personal access tokens. Inject secrets as pipeline variables.</p><h3>Final thoughts</h3><p>The Terraform Resource Exporter is a genuinely useful tool for workspace migrations at scale, but it rewards practitioners who understand its limitations and plan around them.</p><p>The problems described here are solvable — none of them are blockers — but they are also not documented anywhere.</p><p>Despite its rough edges, this tool made it possible to complete a complex, large-scale workspace migration in just two weeks.</p><p>Hopefully this article helps you get there with as little trial and error as possible.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9494070cdbd3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/valcon-consulting/databricks-terraform-resource-exporter-lessons-learned-from-a-workspace-migration-to-unity-catalog-9494070cdbd3">Databricks Terraform Resource Exporter: Lessons learned from a workspace migration to Unity Catalog</a> was originally published in <a href="https://medium.com/valcon-consulting">Valcon</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>