Skip to content

feat(pg): [117602299] Support change pg password regardless user #2652

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

Merged
merged 2 commits into from
May 23, 2024
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
3 changes: 3 additions & 0 deletions .changelog/2652.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
tencentcloud_postgresql_instance: support change pg password regardless user
```
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,7 @@ func resourceTencentCloudPostgresqlInstanceUpdate(d *schema.ResourceData, meta i
if d.HasChange("root_password") {
// to avoid other updating process conflicts with updating password, set the password updating with the last step, there is no way to figure out whether changing password is done
outErr = resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
inErr = postgresqlService.SetPostgresqlInstanceRootPassword(ctx, instanceId, d.Get("root_password").(string))
inErr = postgresqlService.SetPostgresqlInstanceRootPassword(ctx, instanceId, d.Get("root_user").(string), d.Get("root_password").(string))
if inErr != nil {
return tccommon.RetryError(inErr)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,7 @@ resource "tencentcloud_postgresql_instance" "test" {
vpc_id = tencentcloud_vpc.vpc.id
subnet_id = tencentcloud_subnet.subnet.id
engine_version = "13.3"
root_username = "tf-user"
root_password = "t1qaA2k1wgvfa3?ZZZ"
charset = "LATIN1"
memory = 4
Expand Down Expand Up @@ -711,7 +712,8 @@ resource "tencentcloud_postgresql_instance" "test" {
vpc_id = tencentcloud_vpc.vpc.id
subnet_id = tencentcloud_subnet.subnet.id
engine_version = "13.3"
root_password = "t1qaA2k1wgvfa3?ZZZ"
root_username = "tf-user"
root_password = "t1qaA2k1wgvfa3?ZZZ3daw"
charset = "LATIN1"
memory = 8
cpu = 4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ func (me *PostgresqlService) DeletePostgresqlInstance(ctx context.Context, insta
return err
}

func (me *PostgresqlService) SetPostgresqlInstanceRootPassword(ctx context.Context, instanceId string, password string) (errRet error) {
func (me *PostgresqlService) SetPostgresqlInstanceRootPassword(ctx context.Context, instanceId string, user string, password string) (errRet error) {
logId := tccommon.GetLogId(ctx)
request := postgresql.NewResetAccountPasswordRequest()
defer func() {
Expand All @@ -632,7 +632,7 @@ func (me *PostgresqlService) SetPostgresqlInstanceRootPassword(ctx context.Conte
}
}()
request.DBInstanceId = &instanceId
request.UserName = helper.String("root")
request.UserName = &user
request.Password = &password

ratelimit.Check(request.GetAction())
Expand Down
Loading