Skip to content

Commit cc19139

Browse files
gitmknanonymous
andauthored
fix: suport import vpc (#1605)
* fix: suport import vpc * fix: update field properties * feat: add changelog --------- Co-authored-by: anonymous <anonymous@mail.org>
1 parent a490cd3 commit cc19139

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

.changelog/1605.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
resource/tencentcloud_mysql_instance: import support vpc_id and subnet_id
3+
```

tencentcloud/resource_tc_mysql_instance.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,14 @@ func TencentMsyqlBasicInfo() map[string]*schema.Schema {
157157
"vpc_id": {
158158
Type: schema.TypeString,
159159
Optional: true,
160+
Computed: true,
160161
ValidateFunc: validateStringLengthInRange(1, 100),
161162
Description: "ID of VPC, which can be modified once every 24 hours and can't be removed.",
162163
},
163164
"subnet_id": {
164165
Type: schema.TypeString,
165166
Optional: true,
167+
Computed: true,
166168
ValidateFunc: validateStringLengthInRange(1, 100),
167169
Description: "Private network ID. If `vpc_id` is set, this value is required.",
168170
},
@@ -798,12 +800,8 @@ func tencentMsyqlBasicInfoRead(ctx context.Context, d *schema.ResourceData, meta
798800
_ = d.Set("mem_size", mysqlInfo.Memory)
799801
_ = d.Set("cpu", mysqlInfo.Cpu)
800802
_ = d.Set("volume_size", mysqlInfo.Volume)
801-
if d.Get("vpc_id").(string) != "" {
802-
errRet = d.Set("vpc_id", mysqlInfo.UniqVpcId)
803-
}
804-
if d.Get("subnet_id").(string) != "" {
805-
errRet = d.Set("subnet_id", mysqlInfo.UniqSubnetId)
806-
}
803+
_ = d.Set("vpc_id", mysqlInfo.UniqVpcId)
804+
_ = d.Set("subnet_id", mysqlInfo.UniqSubnetId)
807805

808806
isUniversal := mysqlInfo.DeviceType != nil && *mysqlInfo.DeviceType == "UNIVERSAL"
809807
if _, ok := d.GetOk("device_type"); ok || !isUniversal {

tencentcloud/resource_tc_mysql_instance_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ func testSweepMySQLInstance(region string) error {
9595
return nil
9696
}
9797

98+
// go test -i; go test -test.run TestAccTencentCloudMysqlInstanceResource_prepaid -v
9899
func TestAccTencentCloudMysqlInstanceResource_prepaid(t *testing.T) {
99100
resource.Test(t, resource.TestCase{
100101
PreCheck: func() { testAccPreCheckCommon(t, ACCOUNT_TYPE_PREPAY) },
@@ -107,6 +108,8 @@ func TestAccTencentCloudMysqlInstanceResource_prepaid(t *testing.T) {
107108
testAccCheckMysqlMasterInstanceExists("tencentcloud_mysql_instance.prepaid"),
108109
resource.TestCheckResourceAttrSet("tencentcloud_mysql_instance.prepaid", "id"),
109110
resource.TestCheckResourceAttr("tencentcloud_mysql_instance.prepaid", "charge_type", "PREPAID"),
111+
resource.TestCheckResourceAttrSet("tencentcloud_mysql_instance.prepaid", "vpc_id"),
112+
resource.TestCheckResourceAttrSet("tencentcloud_mysql_instance.prepaid", "subnet_id"),
110113
),
111114
},
112115
{

0 commit comments

Comments
 (0)