Skip to content

[Exporter] Add export of databricks_mws_network_connectivity_config and databricks_mws_ncc_private_endpoint_rule #4613

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEXT_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@

### Exporter

* Add export of `databricks_mws_network_connectivity_config` and `databricks_mws_ncc_private_endpoint_rule` ([#4613](https://github.com/databricks/terraform-provider-databricks/pull/4613))

### Internal Changes
4 changes: 4 additions & 0 deletions docs/guides/experimental-exporter.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ Services could be specified in combination with predefined aliases (`all` - for
* `mlflow-webhooks` - **listing** [databricks_mlflow_webhook](../resources/mlflow_webhook.md).
* `model-serving` - **listing** [databricks_model_serving](../resources/model_serving.md).
* `mounts` - **listing** works only in combination with `-mounts` command-line option.
* `nccs` - **listing** [databricks_mws_network_connectivity_config](../resources/mws_network_connectivity_config.md) and [databricks_mws_ncc_private_endpoint_rule](../resources/mws_ncc_private_endpoint_rule.md). **Note** we can't export [databricks_mws_ncc_binding](../resources/mws_ncc_binding.md) because of the missing API.
* `notebooks` - **listing** [databricks_notebook](../resources/notebook.md).
* `policies` - **listing** [databricks_cluster_policy](../resources/cluster_policy).
* `pools` - **listing** [instance pools](../resources/instance_pool.md).
Expand Down Expand Up @@ -209,6 +210,9 @@ Exporter aims to generate HCL code for most of the resources within the Databric
| [databricks_mlflow_model](../resources/mlflow_model.md) | No | No | No | No |
| [databricks_mlflow_webhook](../resources/mlflow_webhook.md) | Yes | Yes | Yes | No |
| [databricks_model_serving](../resources/model_serving) | Yes | Yes | Yes | No |
| [databricks_mws_network_connectivity_config](../resources/mws_network_connectivity_config.md) | Yes | Yes | No | Yes |
| [databricks_mws_ncc_binding](../resources/mws_ncc_binding.md) | No | No | No | No |
| [databricks_mws_ncc_private_endpoint_rule](../resources/mws_ncc_private_endpoint_rule.md) | Yes | No | No | Yes |
| [databricks_mws_permission_assignment](../resources/mws_permission_assignment.md) | Yes | No | No | Yes |
| [databricks_notebook](../resources/notebook.md) | Yes | Yes | Yes | No |
| [databricks_notification_destination](../resources/notification_destination.md) | Yes | No | Yes\*\* | No |
Expand Down
48 changes: 48 additions & 0 deletions exporter/importables.go
Original file line number Diff line number Diff line change
Expand Up @@ -2687,4 +2687,52 @@ var resourcesMap map[string]importable = map[string]importable{
{Path: "direct_access_index_spec.embedding_source_columns.embedding_model_endpoint_name", Resource: "databricks_model_serving"},
},
},
"databricks_mws_network_connectivity_config": {
AccountLevel: true,
Service: "nccs",
List: func(ic *importContext) error {
updatedSinceMs := ic.getUpdatedSinceMs()
it := ic.accountClient.NetworkConnectivity.ListNetworkConnectivityConfigurations(ic.Context,
settings.ListNetworkConnectivityConfigurationsRequest{})
for it.HasNext(ic.Context) {
nc, err := it.Next(ic.Context)
if err != nil {
return err
}
if ic.incremental && nc.UpdatedTime < updatedSinceMs {
log.Printf("[DEBUG] skipping %s that was modified at %d (last active=%d)",
fmt.Sprintf("network connectivity config '%s'", nc.Name), nc.UpdatedTime, updatedSinceMs)
continue
}
// TODO: technically we can create data directly from the API response
ic.Emit(&resource{
Resource: "databricks_mws_network_connectivity_config",
ID: nc.AccountId + "/" + nc.NetworkConnectivityConfigId,
Name: nc.Name,
})
if nc.EgressConfig.TargetRules != nil {
for _, rule := range nc.EgressConfig.TargetRules.AzurePrivateEndpointRules {
// TODO: technically we can create data directly from the API response
resourceId := strings.ReplaceAll(rule.ResourceId, "/subscriptions/", "")
resourceId = strings.ReplaceAll(resourceId, "/resourceGroups/", "_")
resourceId = strings.ReplaceAll(resourceId, "/providers/Microsoft", "_")
ic.Emit(&resource{
Resource: "databricks_mws_ncc_private_endpoint_rule",
ID: nc.NetworkConnectivityConfigId + "/" + rule.RuleId,
Name: nc.Name + "_" + resourceId + "_" + rule.GroupId.String(),
})
}
}
}
return nil
},
},
"databricks_mws_ncc_private_endpoint_rule": {
AccountLevel: true,
Service: "nccs",
Depends: []reference{
{Path: "network_connectivity_config_id", Resource: "databricks_mws_network_connectivity_config",
Match: "network_connectivity_config_id"},
},
},
}
Loading