@@ -266,7 +266,7 @@ func resourceEnterpriseGroupCreate(ctx context.Context, data *schema.ResourceDat
266266 return diag .FromErr (fmt .Errorf ("converting created group data: %w" , err ))
267267 }
268268
269- if err = setEnterpriseGroupsData (data , group ); err != nil {
269+ if err = setEnterpriseGroupsData (ctx , data , group ); err != nil {
270270 return diag .FromErr (fmt .Errorf ("failed to set created group data: %w" , err ))
271271 }
272272
@@ -471,7 +471,7 @@ func resourceEnterpriseGroupRead(ctx context.Context, data *schema.ResourceData,
471471 return diag .FromErr (fmt .Errorf ("fetching role bindings for groups: %w" , err ))
472472 }
473473
474- if err = setEnterpriseGroupsData (data , groupWithRoleBindings ); err != nil {
474+ if err = setEnterpriseGroupsData (ctx , data , groupWithRoleBindings ); err != nil {
475475 return diag .FromErr (fmt .Errorf ("failed to set read groups data: %w" , err ))
476476 }
477477 }
@@ -576,6 +576,7 @@ func convertListGroupsResponseGroup(
576576}
577577
578578func setEnterpriseGroupsData (
579+ ctx context.Context ,
579580 data * schema.ResourceData ,
580581 group EnterpriseGroupWithRoleBindings ,
581582) error {
@@ -595,7 +596,7 @@ func setEnterpriseGroupsData(
595596 return fmt .Errorf ("failed to set members: %w" , err )
596597 }
597598
598- roleBindings , err := convertRoleBindings (data , group .RoleBindings )
599+ roleBindings , err := convertRoleBindings (ctx , data , group .RoleBindings )
599600 if err != nil {
600601 return fmt .Errorf ("failed to convert role bindings: %w" , err )
601602 }
@@ -631,6 +632,7 @@ func convertMembers(members []Member) []map[string]any {
631632}
632633
633634func convertRoleBindings (
635+ ctx context.Context ,
634636 data * schema.ResourceData ,
635637 newRoleBinding []RoleBinding ,
636638) ([]map [string ]any , error ) {
@@ -684,13 +686,18 @@ func convertRoleBindings(
684686 if rb .ID == "" {
685687 newRb , ok = newRoleBindingNameToRoleBinding [rb .Name ]
686688 if ! ok {
687- // Something is wrong, role binding without ID should be found by Name
689+ tflog .Warn (ctx , "Role binding not found by Name, skipping" , map [string ]any {
690+ "role_binding_name" : rb .Name ,
691+ })
688692 continue
689693 }
690694 } else {
691695 newRb , ok = newRoleBindingIDToRoleBinding [rb .ID ]
692696 if ! ok {
693- // Role binding was removed outside of Terraform, skip it
697+ tflog .Warn (ctx , "Role binding not found by ID, trying to find by Name" , map [string ]any {
698+ "role_binding_id" : rb .ID ,
699+ "role_binding_name" : rb .Name ,
700+ })
694701 continue
695702 }
696703 }
@@ -840,7 +847,7 @@ func resourceEnterpriseGroupUpdate(ctx context.Context, data *schema.ResourceDat
840847 return diag .FromErr (fmt .Errorf ("converting updated group data: %w" , err ))
841848 }
842849
843- if err = setEnterpriseGroupsData (data , group ); err != nil {
850+ if err = setEnterpriseGroupsData (ctx , data , group ); err != nil {
844851 return diag .FromErr (fmt .Errorf ("failed to set updated group data: %w" , err ))
845852 }
846853
0 commit comments