@@ -60,8 +60,13 @@ func ResourceRoleAssignment() *schema.Resource {
6060 Optional : true ,
6161 ForceNew : false ,
6262 Description : "IDs of service accounts that the role should be assigned to." ,
63+ // Ignore the org ID of the team when hashing. It works with or without it.
64+ Set : func (i interface {}) int {
65+ _ , saID := SplitOrgResourceID (i .(string ))
66+ return schema .HashString (saID )
67+ },
6368 Elem : & schema.Schema {
64- Type : schema .TypeInt ,
69+ Type : schema .TypeString ,
6570 },
6671 },
6772 },
@@ -100,9 +105,11 @@ func UpdateRoleAssignments(ctx context.Context, d *schema.ResourceData, meta int
100105 _ , teamIDStr := SplitOrgResourceID (t .(string ))
101106 teams [i ], _ = strconv .Atoi (teamIDStr )
102107 }
103- serviceAccounts , err := collectRoleAssignmentsToFn (d .Get ("service_accounts" ))
104- if err != nil {
105- return diag .Errorf ("invalid service account IDs specified %v" , err )
108+ serviceAccountsStrings := d .Get ("service_accounts" ).(* schema.Set ).List ()
109+ serviceAccounts := make ([]int , len (serviceAccountsStrings ))
110+ for i , t := range serviceAccountsStrings {
111+ _ , saIDStr := SplitOrgResourceID (t .(string ))
112+ serviceAccounts [i ], _ = strconv .Atoi (saIDStr )
106113 }
107114
108115 ra := & gapi.RoleAssignments {
@@ -151,7 +158,11 @@ func setRoleAssignments(assignments *gapi.RoleAssignments, d *schema.ResourceDat
151158 if err := d .Set ("teams" , teams ); err != nil {
152159 return err
153160 }
154- if err := d .Set ("service_accounts" , assignments .ServiceAccounts ); err != nil {
161+ serviceAccounts := make ([]string , len (assignments .ServiceAccounts ))
162+ for i , sa := range assignments .ServiceAccounts {
163+ serviceAccounts [i ] = strconv .Itoa (sa )
164+ }
165+ if err := d .Set ("service_accounts" , serviceAccounts ); err != nil {
155166 return err
156167 }
157168
0 commit comments