Skip to content

Commit 909b189

Browse files
alexotttanmay-db
andauthored
[Exporter] Improve support of databricks_model_serving (#4324)
## 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 - [ ] relevant change in `docs/` folder - [ ] covered with integration tests in `internal/acceptance` - [ ] using Go SDK - [ ] using TF Plugin Framework Co-authored-by: Tanmay Rustagi <[email protected]>
1 parent d2bb4e5 commit 909b189

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

exporter/importables.go

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,8 @@ var resourcesMap map[string]importable = map[string]importable{
250250
Ignore: generateIgnoreObjectWithEmptyAttributeValue("databricks_instance_pool", "instance_pool_name"),
251251
},
252252
"databricks_instance_profile": {
253-
Service: "access",
253+
Service: "access",
254+
WorkspaceLevel: true,
254255
Name: func(ic *importContext, d *schema.ResourceData) string {
255256
arn := d.Get("instance_profile_arn").(string)
256257
splits := strings.Split(arn, "/")
@@ -774,12 +775,8 @@ var resourcesMap map[string]importable = map[string]importable{
774775
return d.Get("name").(string)
775776
},
776777
List: func(ic *importContext) error {
777-
w, err := ic.Client.WorkspaceClient()
778-
if err != nil {
779-
return err
780-
}
781778
builtInClusterPolicies := ic.getBuiltinPolicyFamilies()
782-
it := w.ClusterPolicies.List(ic.Context, compute.ListClusterPoliciesRequest{})
779+
it := ic.workspaceClient.ClusterPolicies.List(ic.Context, compute.ListClusterPoliciesRequest{})
783780
i := 0
784781
for it.HasNext(ic.Context) {
785782
policy, err := it.Next(ic.Context)
@@ -2390,6 +2387,7 @@ var resourcesMap map[string]importable = map[string]importable{
23902387
}
23912388
if se.ExternalModel.OpenaiConfig != nil {
23922389
ic.emitSecretsFromSecretPathString(se.ExternalModel.OpenaiConfig.OpenaiApiKey)
2390+
ic.emitSecretsFromSecretPathString(se.ExternalModel.OpenaiConfig.MicrosoftEntraClientSecret)
23932391
}
23942392
if se.ExternalModel.PalmConfig != nil {
23952393
ic.emitSecretsFromSecretPathString(se.ExternalModel.PalmConfig.PalmApiKey)
@@ -2404,6 +2402,15 @@ var resourcesMap map[string]importable = map[string]importable{
24042402
ID: mse.Config.AutoCaptureConfig.CatalogName + "." + mse.Config.AutoCaptureConfig.SchemaName,
24052403
})
24062404
}
2405+
// TODO: add auto-capture for AI Gateway
2406+
if mse.AiGateway != nil && mse.AiGateway.InferenceTableConfig != nil &&
2407+
mse.AiGateway.InferenceTableConfig.CatalogName != "" &&
2408+
mse.AiGateway.InferenceTableConfig.SchemaName != "" {
2409+
ic.Emit(&resource{
2410+
Resource: "databricks_schema",
2411+
ID: mse.AiGateway.InferenceTableConfig.CatalogName + "." + mse.AiGateway.InferenceTableConfig.SchemaName,
2412+
})
2413+
}
24072414
return nil
24082415
},
24092416
Ignore: func(ic *importContext, r *resource) bool {
@@ -2441,14 +2448,22 @@ var resourcesMap map[string]importable = map[string]importable{
24412448
extModelBlockCoordinate := strings.Replace(pathString, ".scale_to_zero_enabled", ".external_model", 1)
24422449
return d.Get(extModelBlockCoordinate+".#").(int) == 0
24432450
}
2444-
return pathString == "config.0.auto_capture_config.0.enabled"
2451+
return pathString == "config.0.auto_capture_config.0.enabled" || pathString == "ai_gateway.0.inference_table_config.0.enabled"
24452452
},
24462453
Depends: []reference{
24472454
{Path: "config.served_entities.entity_name", Resource: "databricks_registered_model"},
2455+
{Path: "config.served_entities.instance_profile_arn", Resource: "databricks_instance_profile",
2456+
Match: "instance_profile_arn"},
24482457
{Path: "config.auto_capture_config.catalog_name", Resource: "databricks_catalog"},
24492458
{Path: "config.auto_capture_config.schema_name", Resource: "databricks_schema", Match: "name",
2450-
IsValidApproximation: createIsMatchingCatalogAndSchema("config.0.auto_capture_config.0.catalog_name", "config.0.auto_capture_config.0.schema_name"),
2451-
SkipDirectLookup: true},
2459+
IsValidApproximation: createIsMatchingCatalogAndSchema("config.0.auto_capture_config.0.catalog_name",
2460+
"config.0.auto_capture_config.0.schema_name"),
2461+
SkipDirectLookup: true},
2462+
{Path: "ai_gateway.inference_table_config.catalog_name", Resource: "databricks_catalog"},
2463+
{Path: "ai_gateway.inference_table_config.schema_name", Resource: "databricks_schema", Match: "name",
2464+
IsValidApproximation: createIsMatchingCatalogAndSchema("ai_gateway.0.inference_table_config.0.catalog_name",
2465+
"ai_gateway.0.inference_table_config.0.schema_name"),
2466+
SkipDirectLookup: true},
24522467
},
24532468
},
24542469
"databricks_mlflow_webhook": {

0 commit comments

Comments
 (0)