From cdfc6be5d0d24ea5464e2f4d95474852571cafba Mon Sep 17 00:00:00 2001 From: mikatong Date: Thu, 21 Jul 2022 15:53:50 +0800 Subject: [PATCH] fix: add db_major_version --- tencentcloud/resource_tc_postgresql_instance.go | 14 +++++++++++++- .../resource_tc_postgresql_instance_test.go | 2 ++ website/docs/r/postgresql_instance.html.markdown | 3 ++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/tencentcloud/resource_tc_postgresql_instance.go b/tencentcloud/resource_tc_postgresql_instance.go index 919805d696..2c9c9e61cf 100644 --- a/tencentcloud/resource_tc_postgresql_instance.go +++ b/tencentcloud/resource_tc_postgresql_instance.go @@ -193,6 +193,14 @@ func resourceTencentCloudPostgresqlInstance() *schema.Resource { Description: "Version of the postgresql database engine. Valid values: `10.4`, `11.8`, `12.4`.", }, "db_major_vesion": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Deprecated: "`db_major_vesion` will be deprecated, use `db_major_version` instead.", + Description: "PostgreSQL major version number. Valid values: 10, 11, 12, 13. " + + "If it is specified, an instance running the latest kernel of PostgreSQL DBMajorVersion will be created.", + }, + "db_major_version": { Type: schema.TypeString, Optional: true, Computed: true, @@ -459,6 +467,9 @@ func resourceTencentCloudPostgresqlInstanceCreate(d *schema.ResourceData, meta i if v, ok := d.GetOk("db_major_vesion"); ok { dbMajorVersion = v.(string) } + if v, ok := d.GetOk("db_major_version"); ok { + dbMajorVersion = v.(string) + } if v, ok := d.GetOk("db_kernel_version"); ok { dbKernelVersion = v.(string) } @@ -941,7 +952,7 @@ func resourceTencentCloudPostgresqlInstanceUpdate(d *schema.ResourceData, meta i paramEntrys["max_standby_streaming_delay"] = strconv.Itoa(v.(int)) } } - if d.HasChange("db_major_vesion") || d.HasChange("db_kernel_version") { + if d.HasChange("db_major_vesion") || d.HasChange("db_major_version") || d.HasChange("db_kernel_version") { return fmt.Errorf("Not support change db major version or kernel version.") } @@ -1025,6 +1036,7 @@ func resourceTencentCloudPostgresqlInstanceRead(d *schema.ResourceData, meta int _ = d.Set("subnet_id", instance.SubnetId) _ = d.Set("engine_version", instance.DBVersion) _ = d.Set("db_major_vesion", instance.DBMajorVersion) + _ = d.Set("db_major_version", instance.DBMajorVersion) _ = d.Set("db_kernel_version", instance.DBKernelVersion) _ = d.Set("name", instance.DBInstanceName) _ = d.Set("charset", instance.DBCharset) diff --git a/tencentcloud/resource_tc_postgresql_instance_test.go b/tencentcloud/resource_tc_postgresql_instance_test.go index 6b73bb9ed3..dfd3d986f8 100644 --- a/tencentcloud/resource_tc_postgresql_instance_test.go +++ b/tencentcloud/resource_tc_postgresql_instance_test.go @@ -112,6 +112,8 @@ func TestAccTencentCloudPostgresqlInstanceResource(t *testing.T) { resource.TestCheckResourceAttrSet(testPostgresqlInstanceResourceKey, "availability_zone"), resource.TestCheckResourceAttrSet(testPostgresqlInstanceResourceKey, "private_access_ip"), resource.TestCheckResourceAttrSet(testPostgresqlInstanceResourceKey, "private_access_port"), + resource.TestCheckResourceAttrSet(testPostgresqlInstanceResourceKey, "db_major_vesion"), + resource.TestCheckResourceAttrSet(testPostgresqlInstanceResourceKey, "db_major_version"), resource.TestCheckResourceAttr(testPostgresqlInstanceResourceKey, "backup_plan.#", "1"), resource.TestCheckResourceAttr(testPostgresqlInstanceResourceKey, "backup_plan.0.min_backup_start_time", "00:10:11"), resource.TestCheckResourceAttr(testPostgresqlInstanceResourceKey, "backup_plan.0.max_backup_start_time", "01:10:11"), diff --git a/website/docs/r/postgresql_instance.html.markdown b/website/docs/r/postgresql_instance.html.markdown index 68714e992b..80ea44dfaf 100644 --- a/website/docs/r/postgresql_instance.html.markdown +++ b/website/docs/r/postgresql_instance.html.markdown @@ -156,7 +156,8 @@ The following arguments are supported: * `charge_type` - (Optional, String, ForceNew) Pay type of the postgresql instance. For now, only `POSTPAID_BY_HOUR` is valid. * `charset` - (Optional, String, ForceNew) Charset of the root account. Valid values are `UTF8`,`LATIN1`. * `db_kernel_version` - (Optional, String) PostgreSQL kernel version number. If it is specified, an instance running kernel DBKernelVersion will be created. -* `db_major_vesion` - (Optional, String) PostgreSQL major version number. Valid values: 10, 11, 12, 13. If it is specified, an instance running the latest kernel of PostgreSQL DBMajorVersion will be created. +* `db_major_version` - (Optional, String) PostgreSQL major version number. Valid values: 10, 11, 12, 13. If it is specified, an instance running the latest kernel of PostgreSQL DBMajorVersion will be created. +* `db_major_vesion` - (Optional, String, **Deprecated**) `db_major_vesion` will be deprecated, use `db_major_version` instead. PostgreSQL major version number. Valid values: 10, 11, 12, 13. If it is specified, an instance running the latest kernel of PostgreSQL DBMajorVersion will be created. * `db_node_set` - (Optional, Set) Specify instance node info for disaster migration. * `engine_version` - (Optional, String, ForceNew) Version of the postgresql database engine. Valid values: `10.4`, `11.8`, `12.4`. * `kms_key_id` - (Optional, String) KeyId of the custom key.