@@ -196,12 +196,29 @@ var resourcesMap map[string]importable = map[string]importable{
196196 },
197197 },
198198 "databricks_group_role" : {
199- Service : "access" ,
199+ Service : "access" ,
200+ AccountLevel : true ,
200201 Depends : []reference {
201202 {Path : "group_id" , Resource : "databricks_group" },
202203 {Path : "role" , Resource : "databricks_instance_profile" , Match : "instance_profile_arn" },
203204 },
204205 },
206+ "databricks_user_role" : {
207+ Service : "access" ,
208+ AccountLevel : true ,
209+ Depends : []reference {
210+ {Path : "user_id" , Resource : "databricks_user" },
211+ {Path : "role" , Resource : "databricks_instance_profile" , Match : "instance_profile_arn" },
212+ },
213+ },
214+ "databricks_service_principal_role" : {
215+ Service : "access" ,
216+ AccountLevel : true ,
217+ Depends : []reference {
218+ {Path : "service_principal_id" , Resource : "databricks_group" },
219+ {Path : "role" , Resource : "databricks_instance_profile" , Match : "instance_profile_arn" },
220+ },
221+ },
205222 "databricks_library" : {
206223 Service : "compute" ,
207224 Depends : []reference {
@@ -531,7 +548,8 @@ var resourcesMap map[string]importable = map[string]importable{
531548 Body : resourceOrDataBlockBody ,
532549 },
533550 "databricks_group" : {
534- Service : "groups" ,
551+ Service : "groups" ,
552+ AccountLevel : true ,
535553 Name : func (ic * importContext , d * schema.ResourceData ) string {
536554 return d .Get ("display_name" ).(string ) + "_" + d .Id ()
537555 },
@@ -590,16 +608,7 @@ var resourcesMap map[string]importable = map[string]importable{
590608 if r .ID != g .ID {
591609 continue
592610 }
593- for _ , instanceProfile := range g .Roles {
594- ic .Emit (& resource {
595- Resource : "databricks_instance_profile" ,
596- ID : instanceProfile .Value ,
597- })
598- ic .Emit (& resource {
599- Resource : "databricks_group_role" ,
600- ID : fmt .Sprintf ("%s|%s" , g .ID , instanceProfile .Value ),
601- })
602- }
611+ ic .emitRoles ("group" , g .ID , g .Roles )
603612 if g .DisplayName == "users" && ! ic .importAllUsers {
604613 log .Printf ("[INFO] Skipping import of entire user directory ..." )
605614 continue
@@ -656,7 +665,8 @@ var resourcesMap map[string]importable = map[string]importable{
656665 Body : resourceOrDataBlockBody ,
657666 },
658667 "databricks_group_member" : {
659- Service : "groups" ,
668+ Service : "groups" ,
669+ AccountLevel : true ,
660670 Depends : []reference {
661671 {Path : "group_id" , Resource : "databricks_group" },
662672 {Path : "member_id" , Resource : "databricks_user" },
@@ -665,7 +675,8 @@ var resourcesMap map[string]importable = map[string]importable{
665675 },
666676 },
667677 "databricks_user" : {
668- Service : "users" ,
678+ Service : "users" ,
679+ AccountLevel : true ,
669680 Name : func (ic * importContext , d * schema.ResourceData ) string {
670681 s := d .Get ("user_name" ).(string )
671682 // if CLI argument includeUserDomains is set then it includes domain portion as well
@@ -694,11 +705,13 @@ var resourcesMap map[string]importable = map[string]importable{
694705 userName = u .UserName
695706 }
696707 ic .emitGroups (u , userName )
708+ ic .emitRoles ("user" , u .ID , u .Roles )
697709 return nil
698710 },
699711 },
700712 "databricks_service_principal" : {
701- Service : "users" ,
713+ Service : "users" ,
714+ AccountLevel : true ,
702715 Name : func (ic * importContext , d * schema.ResourceData ) string {
703716 name := d .Get ("display_name" ).(string )
704717 if name == "" {
@@ -738,6 +751,7 @@ var resourcesMap map[string]importable = map[string]importable{
738751 spnName = u .ApplicationID
739752 }
740753 ic .emitGroups (u , spnName )
754+ ic .emitRoles ("service_principal" , u .ID , u .Roles )
741755 return nil
742756 },
743757 },
0 commit comments