<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic terraform jobs depends_on in Get Started Discussions</title>
    <link>https://community.databricks.com/t5/get-started-discussions/terraform-jobs-depends-on/m-p/38293#M5496</link>
    <description>&lt;P&gt;I am attempting to automate Jobs creation using Databrick Terraform provider.&amp;nbsp; &amp;nbsp; I have a number of task that will "depends_on" each other and am trying to use dynamic content to do this.&amp;nbsp; Each task name is stored in a string array so looping over the task is what i'm trying to do.&amp;nbsp; The first item in the array would not have a depends_on section.&amp;nbsp; &amp;nbsp;I have made numerous attempts, but the depends_on section errors with a null or empty string.&amp;nbsp; Any suggestions?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Sample Code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;locals {
  sorted_tasks = sort(var.tasks)
}

resource "databricks_job" "new_job" {
  run_as {
    user_name = "email@email.com"
  }

  max_concurrent_runs = 1
  format              = "MULTI_TASK"
  name                = "JOBNAME"

  email_notifications {
    on_failure                = ["email@email.com"]
    no_alert_for_skipped_runs = false
  }

  schedule {
    quartz_cron_expression = "16 0 0 * * ?"
    timezone_id            = "America/Boise"
    pause_status           = "UNPAUSED"
  }

  dynamic task {

    for_each = { for idx, task_key in local.sorted_tasks : idx =&amp;gt; task_key }

    content {

      task_key = local.sorted_tasks[task.key]

      depends_on {
        task_key = task.key &amp;gt; 0 ? local.sorted_tasks[task.key-1] : []
      }
 
      notebook_task {
        notebook_path = "/PATH/${local.sorted_tasks[task.key]}"
        source        = "WORKSPACE"
      }

      job_cluster_key = "CLUSTERNAME"

      library {
        pypi {
          package = "snowflake-connector-python"
        }
      }

      library {
        pypi {
          package = "arrow"
        }
      }

      timeout_seconds = 0
 
    }
    
  }

  job_cluster {
    job_cluster_key = "CLUSTERNAME"

    new_cluster {
      cluster_name  = ""
      spark_version = "12.2.x-scala2.12"

      spark_conf = {
        "spark.databricks.delta.preview.enabled"           = "true"
       }

      azure_attributes {
        first_on_demand    = 1
        availability       = "SPOT_WITH_FALLBACK_AZURE"
        spot_bid_max_price = 100
      }

      node_type_id        = "Standard_DS3_v2"
      enable_elastic_disk = true
      policy_id           = "POLICYID"
      data_security_mode  = "LEGACY_SINGLE_USER_STANDARD"
      runtime_engine      = "PHOTON"

      autoscale {
        min_workers = 2
        max_workers = 4
      }
    }


  }



}







&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 24 Jul 2023 15:00:10 GMT</pubDate>
    <dc:creator>GrahamBricks</dc:creator>
    <dc:date>2023-07-24T15:00:10Z</dc:date>
    <item>
      <title>terraform jobs depends_on</title>
      <link>https://community.databricks.com/t5/get-started-discussions/terraform-jobs-depends-on/m-p/38293#M5496</link>
      <description>&lt;P&gt;I am attempting to automate Jobs creation using Databrick Terraform provider.&amp;nbsp; &amp;nbsp; I have a number of task that will "depends_on" each other and am trying to use dynamic content to do this.&amp;nbsp; Each task name is stored in a string array so looping over the task is what i'm trying to do.&amp;nbsp; The first item in the array would not have a depends_on section.&amp;nbsp; &amp;nbsp;I have made numerous attempts, but the depends_on section errors with a null or empty string.&amp;nbsp; Any suggestions?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Sample Code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;locals {
  sorted_tasks = sort(var.tasks)
}

resource "databricks_job" "new_job" {
  run_as {
    user_name = "email@email.com"
  }

  max_concurrent_runs = 1
  format              = "MULTI_TASK"
  name                = "JOBNAME"

  email_notifications {
    on_failure                = ["email@email.com"]
    no_alert_for_skipped_runs = false
  }

  schedule {
    quartz_cron_expression = "16 0 0 * * ?"
    timezone_id            = "America/Boise"
    pause_status           = "UNPAUSED"
  }

  dynamic task {

    for_each = { for idx, task_key in local.sorted_tasks : idx =&amp;gt; task_key }

    content {

      task_key = local.sorted_tasks[task.key]

      depends_on {
        task_key = task.key &amp;gt; 0 ? local.sorted_tasks[task.key-1] : []
      }
 
      notebook_task {
        notebook_path = "/PATH/${local.sorted_tasks[task.key]}"
        source        = "WORKSPACE"
      }

      job_cluster_key = "CLUSTERNAME"

      library {
        pypi {
          package = "snowflake-connector-python"
        }
      }

      library {
        pypi {
          package = "arrow"
        }
      }

      timeout_seconds = 0
 
    }
    
  }

  job_cluster {
    job_cluster_key = "CLUSTERNAME"

    new_cluster {
      cluster_name  = ""
      spark_version = "12.2.x-scala2.12"

      spark_conf = {
        "spark.databricks.delta.preview.enabled"           = "true"
       }

      azure_attributes {
        first_on_demand    = 1
        availability       = "SPOT_WITH_FALLBACK_AZURE"
        spot_bid_max_price = 100
      }

      node_type_id        = "Standard_DS3_v2"
      enable_elastic_disk = true
      policy_id           = "POLICYID"
      data_security_mode  = "LEGACY_SINGLE_USER_STANDARD"
      runtime_engine      = "PHOTON"

      autoscale {
        min_workers = 2
        max_workers = 4
      }
    }


  }



}







&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jul 2023 15:00:10 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/terraform-jobs-depends-on/m-p/38293#M5496</guid>
      <dc:creator>GrahamBricks</dc:creator>
      <dc:date>2023-07-24T15:00:10Z</dc:date>
    </item>
  </channel>
</rss>

