Skip to content

Commit 6ca275b

Browse files
authored
[Exporter] Add export of databricks_mws_network_connectivity_config and databricks_mws_ncc_private_endpoint_rule (#4613)
## Changes <!-- Summary of your changes that are easy to understand --> ## Tests <!-- How is this tested? Please see the checklist below and also describe any other relevant tests --> - [x] `make test` run locally - [x] relevant change in `docs/` folder - [ ] covered with integration tests in `internal/acceptance` - [x] using Go SDK - [ ] using TF Plugin Framework
1 parent 98ddb5f commit 6ca275b

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed

NEXT_CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,6 @@
1313

1414
### Exporter
1515

16+
* 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))
17+
1618
### Internal Changes

docs/guides/experimental-exporter.md

+4
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ Services could be specified in combination with predefined aliases (`all` - for
131131
* `mlflow-webhooks` - **listing** [databricks_mlflow_webhook](../resources/mlflow_webhook.md).
132132
* `model-serving` - **listing** [databricks_model_serving](../resources/model_serving.md).
133133
* `mounts` - **listing** works only in combination with `-mounts` command-line option.
134+
* `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.
134135
* `notebooks` - **listing** [databricks_notebook](../resources/notebook.md).
135136
* `policies` - **listing** [databricks_cluster_policy](../resources/cluster_policy).
136137
* `pools` - **listing** [instance pools](../resources/instance_pool.md).
@@ -209,6 +210,9 @@ Exporter aims to generate HCL code for most of the resources within the Databric
209210
| [databricks_mlflow_model](../resources/mlflow_model.md) | No | No | No | No |
210211
| [databricks_mlflow_webhook](../resources/mlflow_webhook.md) | Yes | Yes | Yes | No |
211212
| [databricks_model_serving](../resources/model_serving) | Yes | Yes | Yes | No |
213+
| [databricks_mws_network_connectivity_config](../resources/mws_network_connectivity_config.md) | Yes | Yes | No | Yes |
214+
| [databricks_mws_ncc_binding](../resources/mws_ncc_binding.md) | No | No | No | No |
215+
| [databricks_mws_ncc_private_endpoint_rule](../resources/mws_ncc_private_endpoint_rule.md) | Yes | No | No | Yes |
212216
| [databricks_mws_permission_assignment](../resources/mws_permission_assignment.md) | Yes | No | No | Yes |
213217
| [databricks_notebook](../resources/notebook.md) | Yes | Yes | Yes | No |
214218
| [databricks_notification_destination](../resources/notification_destination.md) | Yes | No | Yes\*\* | No |

exporter/importables.go

+48
Original file line numberDiff line numberDiff line change
@@ -2687,4 +2687,52 @@ var resourcesMap map[string]importable = map[string]importable{
26872687
{Path: "direct_access_index_spec.embedding_source_columns.embedding_model_endpoint_name", Resource: "databricks_model_serving"},
26882688
},
26892689
},
2690+
"databricks_mws_network_connectivity_config": {
2691+
AccountLevel: true,
2692+
Service: "nccs",
2693+
List: func(ic *importContext) error {
2694+
updatedSinceMs := ic.getUpdatedSinceMs()
2695+
it := ic.accountClient.NetworkConnectivity.ListNetworkConnectivityConfigurations(ic.Context,
2696+
settings.ListNetworkConnectivityConfigurationsRequest{})
2697+
for it.HasNext(ic.Context) {
2698+
nc, err := it.Next(ic.Context)
2699+
if err != nil {
2700+
return err
2701+
}
2702+
if ic.incremental && nc.UpdatedTime < updatedSinceMs {
2703+
log.Printf("[DEBUG] skipping %s that was modified at %d (last active=%d)",
2704+
fmt.Sprintf("network connectivity config '%s'", nc.Name), nc.UpdatedTime, updatedSinceMs)
2705+
continue
2706+
}
2707+
// TODO: technically we can create data directly from the API response
2708+
ic.Emit(&resource{
2709+
Resource: "databricks_mws_network_connectivity_config",
2710+
ID: nc.AccountId + "/" + nc.NetworkConnectivityConfigId,
2711+
Name: nc.Name,
2712+
})
2713+
if nc.EgressConfig.TargetRules != nil {
2714+
for _, rule := range nc.EgressConfig.TargetRules.AzurePrivateEndpointRules {
2715+
// TODO: technically we can create data directly from the API response
2716+
resourceId := strings.ReplaceAll(rule.ResourceId, "/subscriptions/", "")
2717+
resourceId = strings.ReplaceAll(resourceId, "/resourceGroups/", "_")
2718+
resourceId = strings.ReplaceAll(resourceId, "/providers/Microsoft", "_")
2719+
ic.Emit(&resource{
2720+
Resource: "databricks_mws_ncc_private_endpoint_rule",
2721+
ID: nc.NetworkConnectivityConfigId + "/" + rule.RuleId,
2722+
Name: nc.Name + "_" + resourceId + "_" + rule.GroupId.String(),
2723+
})
2724+
}
2725+
}
2726+
}
2727+
return nil
2728+
},
2729+
},
2730+
"databricks_mws_ncc_private_endpoint_rule": {
2731+
AccountLevel: true,
2732+
Service: "nccs",
2733+
Depends: []reference{
2734+
{Path: "network_connectivity_config_id", Resource: "databricks_mws_network_connectivity_config",
2735+
Match: "network_connectivity_config_id"},
2736+
},
2737+
},
26902738
}

0 commit comments

Comments
 (0)