diff --git a/.changelog/2652.txt b/.changelog/2652.txt new file mode 100644 index 0000000000..c7f0528c03 --- /dev/null +++ b/.changelog/2652.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +tencentcloud_postgresql_instance: support change pg password regardless user +``` diff --git a/tencentcloud/services/postgresql/resource_tc_postgresql_instance.go b/tencentcloud/services/postgresql/resource_tc_postgresql_instance.go index 5989b42b4d..fa3ba7fd39 100644 --- a/tencentcloud/services/postgresql/resource_tc_postgresql_instance.go +++ b/tencentcloud/services/postgresql/resource_tc_postgresql_instance.go @@ -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) } diff --git a/tencentcloud/services/postgresql/resource_tc_postgresql_instance_test.go b/tencentcloud/services/postgresql/resource_tc_postgresql_instance_test.go index f31c008998..50791f5332 100644 --- a/tencentcloud/services/postgresql/resource_tc_postgresql_instance_test.go +++ b/tencentcloud/services/postgresql/resource_tc_postgresql_instance_test.go @@ -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 @@ -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 diff --git a/tencentcloud/services/postgresql/service_tencentcloud_postgresql.go b/tencentcloud/services/postgresql/service_tencentcloud_postgresql.go index bda6927b55..7fde1882ef 100644 --- a/tencentcloud/services/postgresql/service_tencentcloud_postgresql.go +++ b/tencentcloud/services/postgresql/service_tencentcloud_postgresql.go @@ -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() { @@ -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())