Skip to content

Commit

Permalink
Merge pull request #1379 from hashicorp/bug/user-password-set-on-failure
Browse files Browse the repository at this point in the history
bugfix: run d.Partial() to avoid setting invalid password to state when a user update fails
  • Loading branch information
manicminer authored May 16, 2024
2 parents 6260f88 + 16c62b1 commit 67aac96
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/services/users/user_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,11 @@ func userResourceUpdate(ctx context.Context, d *pluginsdk.ResourceData, meta int
}

if _, err := client.Update(ctx, properties); err != nil {
// Flag the state as 'partial' to avoid setting `password` from the current config. Since the config is the
// only source for this property, if the update fails due to a bad password, the current password will be forgotten
// and Terraform will not offer a diff in the next plan.
d.Partial(true) //lintignore:R007

return tf.ErrorDiagF(err, "Could not update user with ID: %q", d.Id())
}

Expand Down

0 comments on commit 67aac96

Please sign in to comment.