You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Feature] Add support for filters in databricks_clusters data source (#4014)
## Changes
Version 1.50 of the Terraform Provider featured an upgrade to the Go SDK
affecting cluster listing. The new List Clusters API returns all
terminated clusters in the last 30 days without a limit. This results in
the list operation taking considerably longer for some workspaces,
especially workspaces with many jobs where clusters are frequently
created. This impacts the `databricks_clusters` data source, which can
be slow.
This PR partially addresses this by adding support for `filter_by` to
the `databricks_clusters` API. Filters expressed here are pushed to the
server and result in fewer clusters being returned by the API. Users of
this data source can specify a particular cluster state, cluster source,
pinned status, or cluster policy ID to limit the number of clusters
returned by the API, drastically speeding up performance.
## Tests
Integration tests for `databricks_cluster` data source test setting the
`filter_by` parameter's attributes.
- [ ] `make test` run locally
- [ ] relevant change in `docs/` folder
- [ ] covered with integration tests in `internal/acceptance`
- [ ] relevant acceptance tests are passing
- [ ] using Go SDK
Copy file name to clipboardExpand all lines: docs/data-sources/clusters.md
+10Lines changed: 10 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,6 +27,16 @@ data "databricks_clusters" "all_shared" {
27
27
## Argument Reference
28
28
29
29
*`cluster_name_contains` - (Optional) Only return [databricks_cluster](../resources/cluster.md#cluster_id) ids that match the given name string.
30
+
*`filter_by` - (Optional) Filters to apply to the listed clusters. See [filter_by Configuration Block](#filter_by-configuration-block) below for details.
31
+
32
+
### filter_by Configuration Block
33
+
34
+
The `filter_by` block controls the filtering of the listed clusters. It supports the following arguments:
35
+
36
+
*`cluster_sources` - (Optional) List of cluster sources to filter by. Possible values are `API`, `JOB`, `MODELS`, `PIPELINE`, `PIPELINE_MAINTENANCE`, `SQL`, and `UI`.
37
+
*`cluster_states` - (Optional) List of cluster states to filter by. Possible values are `RUNNING`, `PENDING`, `RESIZING`, `RESTARTING`, `TERMINATING`, `TERMINATED`, `ERROR`, and `UNKNOWN`.
38
+
*`is_pinned` - (Optional) Whether to filter by pinned clusters.
39
+
*`policy_id` - (Optional) Filter by [databricks_cluster_policy](../resources/cluster_policy.md) id.
0 commit comments