Skip to content

Commit

Permalink
Switch to using patch for description.
Browse files Browse the repository at this point in the history
  • Loading branch information
nat-henderson committed Nov 12, 2019
1 parent 27d7e20 commit 393a56b
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ func resourceGoogleServiceAccount() *schema.Resource {
"description": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
"project": {
Type: schema.TypeString,
Expand Down Expand Up @@ -144,6 +143,21 @@ func resourceGoogleServiceAccountUpdate(d *schema.ResourceData, meta interface{}
// See comment in Create.
time.Sleep(time.Second)
}
if d.HasChange("description") {
sa, err := config.clientIAM.Projects.ServiceAccounts.Get(d.Id()).Do()
if err != nil {
return fmt.Errorf("Error retrieving service account %q: %s", d.Id(), err)
}
_, err = config.clientIAM.Projects.ServiceAccounts.Patch(d.Id(),
&iam.PatchServiceAccountRequest{
UpdateMask: "description",
ServiceAccount: &iam.ServiceAccount{
DisplayName: d.Get("display_name").(string),
Description: d.Get("description").(string),
Etag: sa.Etag,
},
}).Do()
}

return nil
}
Expand Down

0 comments on commit 393a56b

Please sign in to comment.