Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Service account description is not updateable. #4870

Merged
merged 1 commit into from
Nov 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 21 additions & 13 deletions google/resource_google_service_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,23 +126,31 @@ func resourceGoogleServiceAccountDelete(d *schema.ResourceData, meta interface{}

func resourceGoogleServiceAccountUpdate(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
if d.HasChange("display_name") || 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.Update(d.Id(),
&iam.ServiceAccount{
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)
}
updateMask := make([]string, 0)
if d.HasChange("description") {
updateMask = append(updateMask, "description")
}
if d.HasChange("display_name") {
updateMask = append(updateMask, "display_name")
}
_, err = config.clientIAM.Projects.ServiceAccounts.Patch(d.Id(),
&iam.PatchServiceAccountRequest{
UpdateMask: strings.Join(updateMask, ","),
ServiceAccount: &iam.ServiceAccount{
DisplayName: d.Get("display_name").(string),
Description: d.Get("description").(string),
Etag: sa.Etag,
}).Do()
if err != nil {
return fmt.Errorf("Error updating service account %q: %s", d.Id(), err)
}
// See comment in Create.
time.Sleep(time.Second)
},
}).Do()
if err != nil {
return err
}
// See comment in Create.
time.Sleep(time.Second)

return nil
}
Expand Down
12 changes: 7 additions & 5 deletions google/resource_google_service_account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ func TestAccServiceAccount_basic(t *testing.T) {
uniqueId := ""
displayName := "Terraform Test"
displayName2 := "Terraform Test Update"
desc := "test description"
desc2 := "test description update"
project := getTestProjectFromEnv()
expectedEmail := fmt.Sprintf("%s@%s.iam.gserviceaccount.com", accountId, project)
resource.Test(t, resource.TestCase{
Expand All @@ -25,7 +27,7 @@ func TestAccServiceAccount_basic(t *testing.T) {
Steps: []resource.TestStep{
// The first step creates a basic service account
{
Config: testAccServiceAccountBasic(accountId, displayName),
Config: testAccServiceAccountBasic(accountId, displayName, desc),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
"google_service_account.acceptance", "project", project),
Expand All @@ -51,7 +53,7 @@ func TestAccServiceAccount_basic(t *testing.T) {
},
// The second step updates the service account
{
Config: testAccServiceAccountBasic(accountId, displayName2),
Config: testAccServiceAccountBasic(accountId, displayName2, desc2),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
"google_service_account.acceptance", "project", project),
Expand Down Expand Up @@ -90,14 +92,14 @@ func testAccStoreServiceAccountUniqueId(uniqueId *string) resource.TestCheckFunc
}
}

func testAccServiceAccountBasic(account, name string) string {
func testAccServiceAccountBasic(account, name, desc string) string {
return fmt.Sprintf(`
resource "google_service_account" "acceptance" {
account_id = "%v"
display_name = "%v"
description = "foo"
description = "%v"
}
`, account, name)
`, account, name, desc)
}

func testAccServiceAccountWithProject(project, account, name string) string {
Expand Down
5 changes: 3 additions & 2 deletions google/resource_monitoring_uptime_check_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,9 @@ func resourceMonitoringUptimeCheckConfig() *schema.Resource {
Description: `If true, use HTTPS instead of HTTP to run the check.`,
},
"validate_ssl": {
Type: schema.TypeBool,
Optional: true,
Type: schema.TypeBool,
Optional: true,
Description: `Boolean specifying whether to include SSL certificate validation as a part of the Uptime check. Only applies to checks where monitoredResource is set to uptime_url. If useSsl is false, setting validateSsl to true has no effect.`,
},
},
},
Expand Down