From 393a56b6eaa7e18ed7f3a0ff90a72f2b90cab70b Mon Sep 17 00:00:00 2001 From: Nathan McKinley Date: Tue, 12 Nov 2019 11:05:31 -0800 Subject: [PATCH] Switch to using patch for description. --- .../resources/resource_google_service_account.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/third_party/terraform/resources/resource_google_service_account.go b/third_party/terraform/resources/resource_google_service_account.go index 28f1dee0ec4f..22beead449f3 100644 --- a/third_party/terraform/resources/resource_google_service_account.go +++ b/third_party/terraform/resources/resource_google_service_account.go @@ -44,7 +44,6 @@ func resourceGoogleServiceAccount() *schema.Resource { "description": { Type: schema.TypeString, Optional: true, - ForceNew: true, }, "project": { Type: schema.TypeString, @@ -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 }