@@ -1796,13 +1796,20 @@ var resourcesMap map[string]importable = map[string]importable{
1796
1796
}
1797
1797
return shouldOmitForUnityCatalog (ic , pathString , as , d )
1798
1798
},
1799
- Ignore : generateIgnoreObjectWithEmptyAttributeValue ("databricks_catalog" , "name" ),
1799
+ Ignore : func (ic * importContext , r * resource ) bool {
1800
+ res := (r .Data != nil && (r .Data .Get ("name" ).(string ) == "" || r .Data .Get ("name" ).(string ) == "system" ))
1801
+ if res {
1802
+ ic .addIgnoredResource (fmt .Sprintf ("databricks_catalog. id=%s" , r .ID ))
1803
+ }
1804
+ return res
1805
+ },
1800
1806
Depends : []reference {
1801
1807
{Path : "connection_name" , Resource : "databricks_connection" , Match : "name" },
1802
1808
{Path : "storage_root" , Resource : "databricks_external_location" , Match : "url" , MatchType : MatchLongestPrefix },
1809
+ {Path : "owner" , Resource : "databricks_service_principal" , Match : "application_id" },
1810
+ {Path : "owner" , Resource : "databricks_group" , Match : "display_name" },
1811
+ {Path : "owner" , Resource : "databricks_user" , Match : "user_name" , MatchType : MatchCaseInsensitive },
1803
1812
},
1804
- // TODO: convert `main` catalog into the data source as it's automatically created?
1805
- // This will require addition of the databricks_catalog data source
1806
1813
},
1807
1814
"databricks_schema" : {
1808
1815
WorkspaceLevel : true ,
@@ -1813,6 +1820,9 @@ var resourcesMap map[string]importable = map[string]importable{
1813
1820
Depends : []reference {
1814
1821
{Path : "catalog_name" , Resource : "databricks_catalog" },
1815
1822
{Path : "storage_root" , Resource : "databricks_external_location" , Match : "url" , MatchType : MatchLongestPrefix },
1823
+ {Path : "owner" , Resource : "databricks_service_principal" , Match : "application_id" },
1824
+ {Path : "owner" , Resource : "databricks_group" , Match : "display_name" },
1825
+ {Path : "owner" , Resource : "databricks_user" , Match : "user_name" , MatchType : MatchCaseInsensitive },
1816
1826
},
1817
1827
},
1818
1828
"databricks_volume" : {
@@ -1833,6 +1843,9 @@ var resourcesMap map[string]importable = map[string]importable{
1833
1843
SkipDirectLookup : true },
1834
1844
{Path : "storage_location" , Resource : "databricks_external_location" ,
1835
1845
Match : "url" , MatchType : MatchLongestPrefix },
1846
+ {Path : "owner" , Resource : "databricks_service_principal" , Match : "application_id" },
1847
+ {Path : "owner" , Resource : "databricks_group" , Match : "display_name" },
1848
+ {Path : "owner" , Resource : "databricks_user" , Match : "user_name" , MatchType : MatchCaseInsensitive },
1836
1849
},
1837
1850
},
1838
1851
"databricks_sql_table" : {
@@ -1857,6 +1870,9 @@ var resourcesMap map[string]importable = map[string]importable{
1857
1870
SkipDirectLookup : true },
1858
1871
{Path : "storage_location" , Resource : "databricks_external_location" ,
1859
1872
Match : "url" , MatchType : MatchLongestPrefix },
1873
+ {Path : "owner" , Resource : "databricks_service_principal" , Match : "application_id" },
1874
+ {Path : "owner" , Resource : "databricks_group" , Match : "display_name" },
1875
+ {Path : "owner" , Resource : "databricks_user" , Match : "user_name" , MatchType : MatchCaseInsensitive },
1860
1876
},
1861
1877
},
1862
1878
"databricks_grants" : {
@@ -1893,6 +1909,9 @@ var resourcesMap map[string]importable = map[string]importable{
1893
1909
ShouldOmitField : shouldOmitWithIsolationMode ,
1894
1910
Depends : []reference {
1895
1911
{Path : "azure_service_principal.client_secret" , Variable : true },
1912
+ {Path : "owner" , Resource : "databricks_service_principal" , Match : "application_id" },
1913
+ {Path : "owner" , Resource : "databricks_group" , Match : "display_name" },
1914
+ {Path : "owner" , Resource : "databricks_user" , Match : "user_name" , MatchType : MatchCaseInsensitive },
1896
1915
},
1897
1916
},
1898
1917
"databricks_credential" : {
@@ -1903,6 +1922,9 @@ var resourcesMap map[string]importable = map[string]importable{
1903
1922
ShouldOmitField : shouldOmitWithIsolationMode ,
1904
1923
Depends : []reference {
1905
1924
{Path : "azure_service_principal.client_secret" , Variable : true },
1925
+ {Path : "owner" , Resource : "databricks_service_principal" , Match : "application_id" },
1926
+ {Path : "owner" , Resource : "databricks_group" , Match : "display_name" },
1927
+ {Path : "owner" , Resource : "databricks_user" , Match : "user_name" , MatchType : MatchCaseInsensitive },
1906
1928
},
1907
1929
},
1908
1930
"databricks_external_location" : {
@@ -1925,6 +1947,9 @@ var resourcesMap map[string]importable = map[string]importable{
1925
1947
},
1926
1948
Depends : []reference {
1927
1949
{Path : "credential_name" , Resource : "databricks_storage_credential" , Match : "name" },
1950
+ {Path : "owner" , Resource : "databricks_service_principal" , Match : "application_id" },
1951
+ {Path : "owner" , Resource : "databricks_group" , Match : "display_name" },
1952
+ {Path : "owner" , Resource : "databricks_user" , Match : "user_name" , MatchType : MatchCaseInsensitive },
1928
1953
},
1929
1954
},
1930
1955
"databricks_connection" : {
@@ -1941,12 +1966,25 @@ var resourcesMap map[string]importable = map[string]importable{
1941
1966
List : listUcConnections ,
1942
1967
// TODO: think what to do with the sensitive fields in the `options`?
1943
1968
Import : func (ic * importContext , r * resource ) error {
1944
- // TODO: do we need to emit the owner See comment for the owner...
1945
1969
connectionName := r .Data .Get ("name" ).(string )
1946
1970
ic .emitUCGrantsWithOwner ("foreign_connection/" + connectionName , r )
1947
1971
return nil
1948
1972
},
1973
+ Ignore : func (ic * importContext , r * resource ) bool {
1974
+ res := (r .Data .Get ("connection_type" ).(string ) == "ONLINE_CATALOG" &&
1975
+ strings .HasPrefix (r .Data .Get ("name" ).(string ), "internal-" ) &&
1976
+ r .Data .Get ("owner" ).(string ) == "System user" )
1977
+ if res {
1978
+ ic .addIgnoredResource (fmt .Sprintf ("databricks_connection. id=%s" , r .ID ))
1979
+ }
1980
+ return res
1981
+ },
1949
1982
ShouldOmitField : shouldOmitForUnityCatalog ,
1983
+ Depends : []reference {
1984
+ {Path : "owner" , Resource : "databricks_service_principal" , Match : "application_id" },
1985
+ {Path : "owner" , Resource : "databricks_group" , Match : "display_name" },
1986
+ {Path : "owner" , Resource : "databricks_user" , Match : "user_name" , MatchType : MatchCaseInsensitive },
1987
+ },
1950
1988
},
1951
1989
"databricks_share" : {
1952
1990
WorkspaceLevel : true ,
@@ -1966,7 +2004,6 @@ var resourcesMap map[string]importable = map[string]importable{
1966
2004
return nil
1967
2005
},
1968
2006
Import : func (ic * importContext , r * resource ) error {
1969
- // TODO: do we need to emit the owner See comment for the owner...
1970
2007
var share tf_sharing.ShareInfo
1971
2008
s := ic .Resources ["databricks_share" ].Schema
1972
2009
common .DataToStructPointer (r .Data , s , & share )
@@ -2003,6 +2040,9 @@ var resourcesMap map[string]importable = map[string]importable{
2003
2040
{Path : "object.name" , Resource : "databricks_registered_model" , IsValidApproximation : isMatchignShareObject ("MODEL" )},
2004
2041
{Path : "object.name" , Resource : "databricks_schema" , IsValidApproximation : isMatchignShareObject ("SCHEMA" )},
2005
2042
{Path : "object.name" , Resource : "databricks_sql_table" , IsValidApproximation : isMatchignShareObject ("TABLE" )},
2043
+ {Path : "owner" , Resource : "databricks_service_principal" , Match : "application_id" },
2044
+ {Path : "owner" , Resource : "databricks_group" , Match : "display_name" },
2045
+ {Path : "owner" , Resource : "databricks_user" , Match : "user_name" , MatchType : MatchCaseInsensitive },
2006
2046
},
2007
2047
},
2008
2048
"databricks_recipient" : {
@@ -2022,7 +2062,18 @@ var resourcesMap map[string]importable = map[string]importable{
2022
2062
}
2023
2063
return nil
2024
2064
},
2025
- // TODO: do we need to emit the owner See comment for the owner...
2065
+ Import : func (ic * importContext , r * resource ) error {
2066
+ owner := r .Data .Get ("owner" ).(string )
2067
+ if owner != "" {
2068
+ emitUserSpOrGroup (ic , owner )
2069
+ }
2070
+ return nil
2071
+ },
2072
+ Depends : []reference {
2073
+ {Path : "owner" , Resource : "databricks_service_principal" , Match : "application_id" },
2074
+ {Path : "owner" , Resource : "databricks_group" , Match : "display_name" },
2075
+ {Path : "owner" , Resource : "databricks_user" , Match : "user_name" , MatchType : MatchCaseInsensitive },
2076
+ },
2026
2077
// TODO: emit variable for sharing_code ...
2027
2078
// TODO: add depends for sharing_code?
2028
2079
},
@@ -2052,8 +2103,6 @@ var resourcesMap map[string]importable = map[string]importable{
2052
2103
Resource : "databricks_schema" ,
2053
2104
ID : schemaFullName ,
2054
2105
})
2055
- // r.AddDependsOn(&resource{Resource: "databricks_grants", ID: "schema/" + schemaFullName})
2056
- // TODO: emit owner? See comment in catalog resource
2057
2106
return nil
2058
2107
},
2059
2108
ShouldOmitField : func (ic * importContext , pathString string , as * schema.Schema , d * schema.ResourceData ) bool {
@@ -2073,6 +2122,9 @@ var resourcesMap map[string]importable = map[string]importable{
2073
2122
IsValidApproximation : createIsMatchingCatalogAndSchema ("catalog_name" , "schema_name" ),
2074
2123
SkipDirectLookup : true },
2075
2124
{Path : "storage_root" , Resource : "databricks_external_location" , Match : "url" , MatchType : MatchLongestPrefix },
2125
+ {Path : "owner" , Resource : "databricks_service_principal" , Match : "application_id" },
2126
+ {Path : "owner" , Resource : "databricks_group" , Match : "display_name" },
2127
+ {Path : "owner" , Resource : "databricks_user" , Match : "user_name" , MatchType : MatchCaseInsensitive },
2076
2128
},
2077
2129
},
2078
2130
"databricks_metastore" : {
@@ -2088,6 +2140,11 @@ var resourcesMap map[string]importable = map[string]importable{
2088
2140
}
2089
2141
return shouldOmitForUnityCatalog (ic , pathString , as , d )
2090
2142
},
2143
+ Depends : []reference {
2144
+ {Path : "owner" , Resource : "databricks_service_principal" , Match : "application_id" },
2145
+ {Path : "owner" , Resource : "databricks_group" , Match : "display_name" },
2146
+ {Path : "owner" , Resource : "databricks_user" , Match : "user_name" , MatchType : MatchCaseInsensitive },
2147
+ },
2091
2148
},
2092
2149
"databricks_metastore_assignment" : {
2093
2150
AccountLevel : true ,
@@ -2343,7 +2400,6 @@ var resourcesMap map[string]importable = map[string]importable{
2343
2400
Resource : "databricks_sql_table" ,
2344
2401
ID : r .Data .Get ("spec.0.source_table_full_name" ).(string ),
2345
2402
})
2346
- // TODO: emit owner? See comment in catalog resource
2347
2403
return nil
2348
2404
},
2349
2405
Ignore : generateIgnoreObjectWithEmptyAttributeValue ("databricks_online_table" , "name" ),
@@ -2354,6 +2410,9 @@ var resourcesMap map[string]importable = map[string]importable{
2354
2410
IsValidApproximation : createIsMatchingCatalogAndSchema ("catalog_name" , "schema_name" ),
2355
2411
SkipDirectLookup : true },
2356
2412
{Path : "spec.source_table_full_name" , Resource : "databricks_sql_table" },
2413
+ {Path : "owner" , Resource : "databricks_service_principal" , Match : "application_id" },
2414
+ {Path : "owner" , Resource : "databricks_group" , Match : "display_name" },
2415
+ {Path : "owner" , Resource : "databricks_user" , Match : "user_name" , MatchType : MatchCaseInsensitive },
2357
2416
},
2358
2417
},
2359
2418
"databricks_vector_search_endpoint" : {
0 commit comments