@@ -1796,13 +1796,20 @@ var resourcesMap map[string]importable = map[string]importable{
17961796 }
17971797 return shouldOmitForUnityCatalog (ic , pathString , as , d )
17981798 },
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+ },
18001806 Depends : []reference {
18011807 {Path : "connection_name" , Resource : "databricks_connection" , Match : "name" },
18021808 {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 },
18031812 },
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
18061813 },
18071814 "databricks_schema" : {
18081815 WorkspaceLevel : true ,
@@ -1813,6 +1820,9 @@ var resourcesMap map[string]importable = map[string]importable{
18131820 Depends : []reference {
18141821 {Path : "catalog_name" , Resource : "databricks_catalog" },
18151822 {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 },
18161826 },
18171827 },
18181828 "databricks_volume" : {
@@ -1833,6 +1843,9 @@ var resourcesMap map[string]importable = map[string]importable{
18331843 SkipDirectLookup : true },
18341844 {Path : "storage_location" , Resource : "databricks_external_location" ,
18351845 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 },
18361849 },
18371850 },
18381851 "databricks_sql_table" : {
@@ -1857,6 +1870,9 @@ var resourcesMap map[string]importable = map[string]importable{
18571870 SkipDirectLookup : true },
18581871 {Path : "storage_location" , Resource : "databricks_external_location" ,
18591872 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 },
18601876 },
18611877 },
18621878 "databricks_grants" : {
@@ -1893,6 +1909,9 @@ var resourcesMap map[string]importable = map[string]importable{
18931909 ShouldOmitField : shouldOmitWithIsolationMode ,
18941910 Depends : []reference {
18951911 {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 },
18961915 },
18971916 },
18981917 "databricks_credential" : {
@@ -1903,6 +1922,9 @@ var resourcesMap map[string]importable = map[string]importable{
19031922 ShouldOmitField : shouldOmitWithIsolationMode ,
19041923 Depends : []reference {
19051924 {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 },
19061928 },
19071929 },
19081930 "databricks_external_location" : {
@@ -1925,6 +1947,9 @@ var resourcesMap map[string]importable = map[string]importable{
19251947 },
19261948 Depends : []reference {
19271949 {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 },
19281953 },
19291954 },
19301955 "databricks_connection" : {
@@ -1941,12 +1966,25 @@ var resourcesMap map[string]importable = map[string]importable{
19411966 List : listUcConnections ,
19421967 // TODO: think what to do with the sensitive fields in the `options`?
19431968 Import : func (ic * importContext , r * resource ) error {
1944- // TODO: do we need to emit the owner See comment for the owner...
19451969 connectionName := r .Data .Get ("name" ).(string )
19461970 ic .emitUCGrantsWithOwner ("foreign_connection/" + connectionName , r )
19471971 return nil
19481972 },
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+ },
19491982 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+ },
19501988 },
19511989 "databricks_share" : {
19521990 WorkspaceLevel : true ,
@@ -1966,7 +2004,6 @@ var resourcesMap map[string]importable = map[string]importable{
19662004 return nil
19672005 },
19682006 Import : func (ic * importContext , r * resource ) error {
1969- // TODO: do we need to emit the owner See comment for the owner...
19702007 var share tf_sharing.ShareInfo
19712008 s := ic .Resources ["databricks_share" ].Schema
19722009 common .DataToStructPointer (r .Data , s , & share )
@@ -2003,6 +2040,9 @@ var resourcesMap map[string]importable = map[string]importable{
20032040 {Path : "object.name" , Resource : "databricks_registered_model" , IsValidApproximation : isMatchignShareObject ("MODEL" )},
20042041 {Path : "object.name" , Resource : "databricks_schema" , IsValidApproximation : isMatchignShareObject ("SCHEMA" )},
20052042 {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 },
20062046 },
20072047 },
20082048 "databricks_recipient" : {
@@ -2022,7 +2062,18 @@ var resourcesMap map[string]importable = map[string]importable{
20222062 }
20232063 return nil
20242064 },
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+ },
20262077 // TODO: emit variable for sharing_code ...
20272078 // TODO: add depends for sharing_code?
20282079 },
@@ -2052,8 +2103,6 @@ var resourcesMap map[string]importable = map[string]importable{
20522103 Resource : "databricks_schema" ,
20532104 ID : schemaFullName ,
20542105 })
2055- // r.AddDependsOn(&resource{Resource: "databricks_grants", ID: "schema/" + schemaFullName})
2056- // TODO: emit owner? See comment in catalog resource
20572106 return nil
20582107 },
20592108 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{
20732122 IsValidApproximation : createIsMatchingCatalogAndSchema ("catalog_name" , "schema_name" ),
20742123 SkipDirectLookup : true },
20752124 {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 },
20762128 },
20772129 },
20782130 "databricks_metastore" : {
@@ -2088,6 +2140,11 @@ var resourcesMap map[string]importable = map[string]importable{
20882140 }
20892141 return shouldOmitForUnityCatalog (ic , pathString , as , d )
20902142 },
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+ },
20912148 },
20922149 "databricks_metastore_assignment" : {
20932150 AccountLevel : true ,
@@ -2343,7 +2400,6 @@ var resourcesMap map[string]importable = map[string]importable{
23432400 Resource : "databricks_sql_table" ,
23442401 ID : r .Data .Get ("spec.0.source_table_full_name" ).(string ),
23452402 })
2346- // TODO: emit owner? See comment in catalog resource
23472403 return nil
23482404 },
23492405 Ignore : generateIgnoreObjectWithEmptyAttributeValue ("databricks_online_table" , "name" ),
@@ -2354,6 +2410,9 @@ var resourcesMap map[string]importable = map[string]importable{
23542410 IsValidApproximation : createIsMatchingCatalogAndSchema ("catalog_name" , "schema_name" ),
23552411 SkipDirectLookup : true },
23562412 {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 },
23572416 },
23582417 },
23592418 "databricks_vector_search_endpoint" : {
0 commit comments