Skip to content

Commit ef455d1

Browse files
authored
feat(pg): [117602299] Support change pg password regardless user (#2652)
* support change pg password regardless user * add changelog
1 parent 8d10c30 commit ef455d1

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

.changelog/2652.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
tencentcloud_postgresql_instance: support change pg password regardless user
3+
```

tencentcloud/services/postgresql/resource_tc_postgresql_instance.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@ func resourceTencentCloudPostgresqlInstanceUpdate(d *schema.ResourceData, meta i
944944
if d.HasChange("root_password") {
945945
// 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
946946
outErr = resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
947-
inErr = postgresqlService.SetPostgresqlInstanceRootPassword(ctx, instanceId, d.Get("root_password").(string))
947+
inErr = postgresqlService.SetPostgresqlInstanceRootPassword(ctx, instanceId, d.Get("root_user").(string), d.Get("root_password").(string))
948948
if inErr != nil {
949949
return tccommon.RetryError(inErr)
950950
}

tencentcloud/services/postgresql/resource_tc_postgresql_instance_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,7 @@ resource "tencentcloud_postgresql_instance" "test" {
676676
vpc_id = tencentcloud_vpc.vpc.id
677677
subnet_id = tencentcloud_subnet.subnet.id
678678
engine_version = "13.3"
679+
root_username = "tf-user"
679680
root_password = "t1qaA2k1wgvfa3?ZZZ"
680681
charset = "LATIN1"
681682
memory = 4
@@ -711,7 +712,8 @@ resource "tencentcloud_postgresql_instance" "test" {
711712
vpc_id = tencentcloud_vpc.vpc.id
712713
subnet_id = tencentcloud_subnet.subnet.id
713714
engine_version = "13.3"
714-
root_password = "t1qaA2k1wgvfa3?ZZZ"
715+
root_username = "tf-user"
716+
root_password = "t1qaA2k1wgvfa3?ZZZ3daw"
715717
charset = "LATIN1"
716718
memory = 8
717719
cpu = 4

tencentcloud/services/postgresql/service_tencentcloud_postgresql.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ func (me *PostgresqlService) DeletePostgresqlInstance(ctx context.Context, insta
623623
return err
624624
}
625625

626-
func (me *PostgresqlService) SetPostgresqlInstanceRootPassword(ctx context.Context, instanceId string, password string) (errRet error) {
626+
func (me *PostgresqlService) SetPostgresqlInstanceRootPassword(ctx context.Context, instanceId string, user string, password string) (errRet error) {
627627
logId := tccommon.GetLogId(ctx)
628628
request := postgresql.NewResetAccountPasswordRequest()
629629
defer func() {
@@ -632,7 +632,7 @@ func (me *PostgresqlService) SetPostgresqlInstanceRootPassword(ctx context.Conte
632632
}
633633
}()
634634
request.DBInstanceId = &instanceId
635-
request.UserName = helper.String("root")
635+
request.UserName = &user
636636
request.Password = &password
637637

638638
ratelimit.Check(request.GetAction())

0 commit comments

Comments
 (0)