@@ -2055,13 +2055,20 @@ var resourcesMap map[string]importable = map[string]importable{
2055
2055
}
2056
2056
return shouldOmitForUnityCatalog (ic , pathString , as , d )
2057
2057
},
2058
- Ignore : generateIgnoreObjectWithEmptyAttributeValue ("databricks_catalog" , "name" ),
2058
+ Ignore : func (ic * importContext , r * resource ) bool {
2059
+ res := (r .Data != nil && (r .Data .Get ("name" ).(string ) == "" || r .Data .Get ("name" ).(string ) == "system" ))
2060
+ if res {
2061
+ ic .addIgnoredResource (fmt .Sprintf ("databricks_catalog. id=%s" , r .ID ))
2062
+ }
2063
+ return res
2064
+ },
2059
2065
Depends : []reference {
2060
2066
{Path : "connection_name" , Resource : "databricks_connection" , Match : "name" },
2061
2067
{Path : "storage_root" , Resource : "databricks_external_location" , Match : "url" , MatchType : MatchLongestPrefix },
2068
+ {Path : "owner" , Resource : "databricks_service_principal" , Match : "application_id" },
2069
+ {Path : "owner" , Resource : "databricks_group" , Match : "display_name" },
2070
+ {Path : "owner" , Resource : "databricks_user" , Match : "user_name" , MatchType : MatchCaseInsensitive },
2062
2071
},
2063
- // TODO: convert `main` catalog into the data source as it's automatically created?
2064
- // This will require addition of the databricks_catalog data source
2065
2072
},
2066
2073
"databricks_schema" : {
2067
2074
WorkspaceLevel : true ,
@@ -2072,6 +2079,9 @@ var resourcesMap map[string]importable = map[string]importable{
2072
2079
Depends : []reference {
2073
2080
{Path : "catalog_name" , Resource : "databricks_catalog" },
2074
2081
{Path : "storage_root" , Resource : "databricks_external_location" , Match : "url" , MatchType : MatchLongestPrefix },
2082
+ {Path : "owner" , Resource : "databricks_service_principal" , Match : "application_id" },
2083
+ {Path : "owner" , Resource : "databricks_group" , Match : "display_name" },
2084
+ {Path : "owner" , Resource : "databricks_user" , Match : "user_name" , MatchType : MatchCaseInsensitive },
2075
2085
},
2076
2086
},
2077
2087
"databricks_volume" : {
@@ -2092,6 +2102,9 @@ var resourcesMap map[string]importable = map[string]importable{
2092
2102
SkipDirectLookup : true },
2093
2103
{Path : "storage_location" , Resource : "databricks_external_location" ,
2094
2104
Match : "url" , MatchType : MatchLongestPrefix },
2105
+ {Path : "owner" , Resource : "databricks_service_principal" , Match : "application_id" },
2106
+ {Path : "owner" , Resource : "databricks_group" , Match : "display_name" },
2107
+ {Path : "owner" , Resource : "databricks_user" , Match : "user_name" , MatchType : MatchCaseInsensitive },
2095
2108
},
2096
2109
},
2097
2110
"databricks_sql_table" : {
@@ -2116,6 +2129,9 @@ var resourcesMap map[string]importable = map[string]importable{
2116
2129
SkipDirectLookup : true },
2117
2130
{Path : "storage_location" , Resource : "databricks_external_location" ,
2118
2131
Match : "url" , MatchType : MatchLongestPrefix },
2132
+ {Path : "owner" , Resource : "databricks_service_principal" , Match : "application_id" },
2133
+ {Path : "owner" , Resource : "databricks_group" , Match : "display_name" },
2134
+ {Path : "owner" , Resource : "databricks_user" , Match : "user_name" , MatchType : MatchCaseInsensitive },
2119
2135
},
2120
2136
},
2121
2137
"databricks_grants" : {
@@ -2152,6 +2168,9 @@ var resourcesMap map[string]importable = map[string]importable{
2152
2168
ShouldOmitField : shouldOmitWithIsolationMode ,
2153
2169
Depends : []reference {
2154
2170
{Path : "azure_service_principal.client_secret" , Variable : true },
2171
+ {Path : "owner" , Resource : "databricks_service_principal" , Match : "application_id" },
2172
+ {Path : "owner" , Resource : "databricks_group" , Match : "display_name" },
2173
+ {Path : "owner" , Resource : "databricks_user" , Match : "user_name" , MatchType : MatchCaseInsensitive },
2155
2174
},
2156
2175
},
2157
2176
"databricks_credential" : {
@@ -2162,6 +2181,9 @@ var resourcesMap map[string]importable = map[string]importable{
2162
2181
ShouldOmitField : shouldOmitWithIsolationMode ,
2163
2182
Depends : []reference {
2164
2183
{Path : "azure_service_principal.client_secret" , Variable : true },
2184
+ {Path : "owner" , Resource : "databricks_service_principal" , Match : "application_id" },
2185
+ {Path : "owner" , Resource : "databricks_group" , Match : "display_name" },
2186
+ {Path : "owner" , Resource : "databricks_user" , Match : "user_name" , MatchType : MatchCaseInsensitive },
2165
2187
},
2166
2188
},
2167
2189
"databricks_external_location" : {
@@ -2184,6 +2206,9 @@ var resourcesMap map[string]importable = map[string]importable{
2184
2206
},
2185
2207
Depends : []reference {
2186
2208
{Path : "credential_name" , Resource : "databricks_storage_credential" , Match : "name" },
2209
+ {Path : "owner" , Resource : "databricks_service_principal" , Match : "application_id" },
2210
+ {Path : "owner" , Resource : "databricks_group" , Match : "display_name" },
2211
+ {Path : "owner" , Resource : "databricks_user" , Match : "user_name" , MatchType : MatchCaseInsensitive },
2187
2212
},
2188
2213
},
2189
2214
"databricks_connection" : {
@@ -2200,12 +2225,25 @@ var resourcesMap map[string]importable = map[string]importable{
2200
2225
List : listUcConnections ,
2201
2226
// TODO: think what to do with the sensitive fields in the `options`?
2202
2227
Import : func (ic * importContext , r * resource ) error {
2203
- // TODO: do we need to emit the owner See comment for the owner...
2204
2228
connectionName := r .Data .Get ("name" ).(string )
2205
2229
ic .emitUCGrantsWithOwner ("foreign_connection/" + connectionName , r )
2206
2230
return nil
2207
2231
},
2232
+ Ignore : func (ic * importContext , r * resource ) bool {
2233
+ res := (r .Data .Get ("connection_type" ).(string ) == "ONLINE_CATALOG" &&
2234
+ strings .HasPrefix (r .Data .Get ("name" ).(string ), "internal-" ) &&
2235
+ r .Data .Get ("owner" ).(string ) == "System user" )
2236
+ if res {
2237
+ ic .addIgnoredResource (fmt .Sprintf ("databricks_connection. id=%s" , r .ID ))
2238
+ }
2239
+ return res
2240
+ },
2208
2241
ShouldOmitField : shouldOmitForUnityCatalog ,
2242
+ Depends : []reference {
2243
+ {Path : "owner" , Resource : "databricks_service_principal" , Match : "application_id" },
2244
+ {Path : "owner" , Resource : "databricks_group" , Match : "display_name" },
2245
+ {Path : "owner" , Resource : "databricks_user" , Match : "user_name" , MatchType : MatchCaseInsensitive },
2246
+ },
2209
2247
},
2210
2248
"databricks_share" : {
2211
2249
WorkspaceLevel : true ,
@@ -2225,7 +2263,6 @@ var resourcesMap map[string]importable = map[string]importable{
2225
2263
return nil
2226
2264
},
2227
2265
Import : func (ic * importContext , r * resource ) error {
2228
- // TODO: do we need to emit the owner See comment for the owner...
2229
2266
var share tf_sharing.ShareInfo
2230
2267
s := ic .Resources ["databricks_share" ].Schema
2231
2268
common .DataToStructPointer (r .Data , s , & share )
@@ -2262,6 +2299,9 @@ var resourcesMap map[string]importable = map[string]importable{
2262
2299
{Path : "object.name" , Resource : "databricks_registered_model" , IsValidApproximation : isMatchignShareObject ("MODEL" )},
2263
2300
{Path : "object.name" , Resource : "databricks_schema" , IsValidApproximation : isMatchignShareObject ("SCHEMA" )},
2264
2301
{Path : "object.name" , Resource : "databricks_sql_table" , IsValidApproximation : isMatchignShareObject ("TABLE" )},
2302
+ {Path : "owner" , Resource : "databricks_service_principal" , Match : "application_id" },
2303
+ {Path : "owner" , Resource : "databricks_group" , Match : "display_name" },
2304
+ {Path : "owner" , Resource : "databricks_user" , Match : "user_name" , MatchType : MatchCaseInsensitive },
2265
2305
},
2266
2306
},
2267
2307
"databricks_recipient" : {
@@ -2281,7 +2321,18 @@ var resourcesMap map[string]importable = map[string]importable{
2281
2321
}
2282
2322
return nil
2283
2323
},
2284
- // TODO: do we need to emit the owner See comment for the owner...
2324
+ Import : func (ic * importContext , r * resource ) error {
2325
+ owner := r .Data .Get ("owner" ).(string )
2326
+ if owner != "" {
2327
+ emitUserSpOrGroup (ic , owner )
2328
+ }
2329
+ return nil
2330
+ },
2331
+ Depends : []reference {
2332
+ {Path : "owner" , Resource : "databricks_service_principal" , Match : "application_id" },
2333
+ {Path : "owner" , Resource : "databricks_group" , Match : "display_name" },
2334
+ {Path : "owner" , Resource : "databricks_user" , Match : "user_name" , MatchType : MatchCaseInsensitive },
2335
+ },
2285
2336
// TODO: emit variable for sharing_code ...
2286
2337
// TODO: add depends for sharing_code?
2287
2338
},
@@ -2311,8 +2362,6 @@ var resourcesMap map[string]importable = map[string]importable{
2311
2362
Resource : "databricks_schema" ,
2312
2363
ID : schemaFullName ,
2313
2364
})
2314
- // r.AddDependsOn(&resource{Resource: "databricks_grants", ID: "schema/" + schemaFullName})
2315
- // TODO: emit owner? See comment in catalog resource
2316
2365
return nil
2317
2366
},
2318
2367
ShouldOmitField : func (ic * importContext , pathString string , as * schema.Schema , d * schema.ResourceData ) bool {
@@ -2332,6 +2381,9 @@ var resourcesMap map[string]importable = map[string]importable{
2332
2381
IsValidApproximation : createIsMatchingCatalogAndSchema ("catalog_name" , "schema_name" ),
2333
2382
SkipDirectLookup : true },
2334
2383
{Path : "storage_root" , Resource : "databricks_external_location" , Match : "url" , MatchType : MatchLongestPrefix },
2384
+ {Path : "owner" , Resource : "databricks_service_principal" , Match : "application_id" },
2385
+ {Path : "owner" , Resource : "databricks_group" , Match : "display_name" },
2386
+ {Path : "owner" , Resource : "databricks_user" , Match : "user_name" , MatchType : MatchCaseInsensitive },
2335
2387
},
2336
2388
},
2337
2389
"databricks_metastore" : {
@@ -2347,6 +2399,11 @@ var resourcesMap map[string]importable = map[string]importable{
2347
2399
}
2348
2400
return shouldOmitForUnityCatalog (ic , pathString , as , d )
2349
2401
},
2402
+ Depends : []reference {
2403
+ {Path : "owner" , Resource : "databricks_service_principal" , Match : "application_id" },
2404
+ {Path : "owner" , Resource : "databricks_group" , Match : "display_name" },
2405
+ {Path : "owner" , Resource : "databricks_user" , Match : "user_name" , MatchType : MatchCaseInsensitive },
2406
+ },
2350
2407
},
2351
2408
"databricks_metastore_assignment" : {
2352
2409
AccountLevel : true ,
@@ -2602,7 +2659,6 @@ var resourcesMap map[string]importable = map[string]importable{
2602
2659
Resource : "databricks_sql_table" ,
2603
2660
ID : r .Data .Get ("spec.0.source_table_full_name" ).(string ),
2604
2661
})
2605
- // TODO: emit owner? See comment in catalog resource
2606
2662
return nil
2607
2663
},
2608
2664
Ignore : generateIgnoreObjectWithEmptyAttributeValue ("databricks_online_table" , "name" ),
@@ -2613,6 +2669,9 @@ var resourcesMap map[string]importable = map[string]importable{
2613
2669
IsValidApproximation : createIsMatchingCatalogAndSchema ("catalog_name" , "schema_name" ),
2614
2670
SkipDirectLookup : true },
2615
2671
{Path : "spec.source_table_full_name" , Resource : "databricks_sql_table" },
2672
+ {Path : "owner" , Resource : "databricks_service_principal" , Match : "application_id" },
2673
+ {Path : "owner" , Resource : "databricks_group" , Match : "display_name" },
2674
+ {Path : "owner" , Resource : "databricks_user" , Match : "user_name" , MatchType : MatchCaseInsensitive },
2616
2675
},
2617
2676
},
2618
2677
"databricks_vector_search_endpoint" : {
0 commit comments