Gradient Terraform Integration
Integrating Gradient into your Terraform process typically involves the following steps:
Include Workspace and Job Configuration in your Terraform Plan
Configure Terraform to ignore recommendation fields when detecting drift
Let Gradient “auto-apply” recommendations directly to your Databricks Job via Databricks API
Databricks Workspace and Job Configurations Used by Gradient
Gradient utilizes Databricks webhook notification destinations to be notified upon the start of managed Databricks Jobs. Each notification destination should be incorporated into your infrastructure management process to maintain Gradient configuration within your Databricks workspace definition. See example.
Databricks Workspace Webhook Notification Destination
Additionally, each workflow cluster being managed by Gradient should reference this webhook.
Databricks Job Notifications
Managing Terraform Drift
If you are using terraform plan
to tell you when there is a configuration drift of resources created by Terraform, we recommend you use one of the following methods to omit Databricks Job cluster configurations generated by Gradient. This will avoid the most recent cluster configuration from being overwritten by Terraform.
Ignore the Entire Cluster Configuration
Specifying ‘ignore_chages = all’ under ‘lifecycle’ definition of the entire cluster configuration will result in the entire cluster configuration being ignored by the drift detection process.
Ignore only the Cluster Configurations Managed by Gradient
Explicitly specifying which configurations to ignore allows configurations not managed by Gradient to be evaluated by the drift detection process. However, it is important to notes that these configurations may change as new features are added to Gradient.
Apply All Recommendations to Terraform
If you choose not "ignore changes" and want to reintegrate the recommendations back into their terraform resource, you can retrieve the latest recommendation using the following function in the Sync Python Library:
This function returns a Python dictionary containing the recommended cluster configuration for the project. Parse and persist this data in the format required by your infrastructure management process.
Auto-Apply Recommendations
To avoid manually applying recommendations, you can also enable Auto-Apply in the "Edit settings" button in the Gradient project page. If this option is enabled, recommendations will be automatically applied after each run of your job.
This setting is applicable only to Databricks Workflows. Auto-Apply is not applicable if you're using the DatabricksSubmitRunOperator or Databricks /api/2.1/jobs/runs/submit API.
The Auto-Apply setting is applicable only to Databricks Workflows.
Auto-Apply is not applicable if you're using the DatabricksSubmitRunOperator or Databricks /api/2.1/jobs/runs/submit API.
Last updated