Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d411ee3

Browse files
authoredJun 4, 2024··
feat(cvm): [117301871]update cvm e2e test (#2664)
* add * add * add * add * add
1 parent fff50d0 commit d411ee3

18 files changed

+492
-112
lines changed
 

‎tencentcloud/services/cvm/resource_tc_cvm_sync_image.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ func ResourceTencentCloudCvmSyncImage() *schema.Resource {
1818
Create: resourceTencentCloudCvmSyncImageCreate,
1919
Read: resourceTencentCloudCvmSyncImageRead,
2020
Delete: resourceTencentCloudCvmSyncImageDelete,
21-
Importer: &schema.ResourceImporter{
22-
State: schema.ImportStatePassthrough,
23-
},
21+
2422
Schema: map[string]*schema.Schema{
2523
"image_id": {
2624
Required: true,

‎tencentcloud/services/cvm/resource_tc_cvm_sync_image.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@ Provides a resource to create a cvm sync_image
33
Example Usage
44

55
```hcl
6-
resource "tencentcloud_cvm_sync_image" "sync_image" {
7-
image_id = "img-xxxxxx"
8-
destination_regions =["ap-guangzhou", "ap-shanghai"]
6+
data "tencentcloud_images" "example" {
7+
image_type = ["PRIVATE_IMAGE"]
8+
image_name_regex = "MyImage"
9+
}
10+
11+
resource "tencentcloud_cvm_sync_image" "example" {
12+
image_id = data.tencentcloud_images.example.images.0.image_id
13+
destination_regions = ["ap-guangzhou", "ap-shanghai"]
914
}
1015
```

‎tencentcloud/services/cvm/resource_tc_cvm_sync_image_test.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,23 +57,32 @@ func init() {
5757
})
5858
}
5959

60-
func TestAccTencentCloudCvmSyncImageResource_basic(t *testing.T) {
60+
// go test -i; go test -test.run TestAccTencentCloudNeedFixCvmSyncImageResource_basic -v
61+
func TestAccTencentCloudNeedFixCvmSyncImageResource_basic(t *testing.T) {
6162
t.Parallel()
6263
resource.Test(t, resource.TestCase{
63-
PreCheck: func() { tcacctest.AccPreCheckCommon(t, tcacctest.ACCOUNT_TYPE_PREPAY) },
64+
PreCheck: func() { tcacctest.AccPreCheck(t) },
6465
Providers: tcacctest.AccProviders,
6566
Steps: []resource.TestStep{
6667
{
6768
Config: testAccCvmSyncImage,
68-
Check: resource.ComposeTestCheckFunc(resource.TestCheckResourceAttrSet("tencentcloud_cvm_sync_image.sync_image", "id")),
69+
Check: resource.ComposeTestCheckFunc(
70+
resource.TestCheckResourceAttrSet("tencentcloud_cvm_sync_image.example", "id"),
71+
resource.TestCheckResourceAttrSet("tencentcloud_cvm_sync_image.example", "image_id"),
72+
resource.TestCheckResourceAttrSet("tencentcloud_cvm_sync_image.example", "destination_regions.#"),
73+
),
6974
},
7075
},
7176
})
7277
}
7378

7479
const testAccCvmSyncImage = `
75-
resource "tencentcloud_cvm_sync_image" "sync_image" {
76-
image_id = "img-k4h0m5la"
77-
destination_regions = ["ap-shanghai"]
80+
data "tencentcloud_images" "example" {
81+
image_type = ["PRIVATE_IMAGE"]
82+
}
83+
84+
resource "tencentcloud_cvm_sync_image" "example" {
85+
image_id = data.tencentcloud_images.example.images.0.image_id
86+
destination_regions = ["ap-shanghai"]
7887
}
7988
`

‎tencentcloud/services/cvm/resource_tc_eip.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Provides an EIP resource.
33
Example Usage
44

55
Paid by the bandwidth package
6+
67
```hcl
78
resource "tencentcloud_eip" "foo" {
89
name = "awesome_gateway_ip"
@@ -13,7 +14,8 @@ resource "tencentcloud_eip" "foo" {
1314
```
1415

1516
AntiDDos Eip
16-
```
17+
18+
```hcl
1719
resource "tencentcloud_eip" "foo" {
1820
name = "awesome_gateway_ip"
1921
bandwidth_package_id = "bwp-4ocyia9s"
@@ -28,7 +30,8 @@ resource "tencentcloud_eip" "foo" {
2830
```
2931

3032
Eip With Network Egress
31-
```
33+
34+
```hcl
3235
resource "tencentcloud_eip" "foo" {
3336
name = "egress_eip"
3437
egress = "center_egress2"

‎tencentcloud/services/cvm/resource_tc_eip_address_transform.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ func ResourceTencentCloudEipAddressTransform() *schema.Resource {
1919
Create: resourceTencentCloudEipAddressTransformCreate,
2020
Read: resourceTencentCloudEipAddressTransformRead,
2121
Delete: resourceTencentCloudEipAddressTransformDelete,
22-
Importer: &schema.ResourceImporter{
23-
State: schema.ImportStatePassthrough,
24-
},
22+
2523
Schema: map[string]*schema.Schema{
2624
"instance_id": {
2725
Required: true,

‎tencentcloud/services/cvm/resource_tc_eip_address_transform.md

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,48 @@ Provides a resource to create a eip address_transform
33
Example Usage
44

55
```hcl
6-
resource "tencentcloud_eip_address_transform" "address_transform" {
7-
instance_id = ""
6+
# create vpc
7+
resource "tencentcloud_vpc" "vpc" {
8+
name = "vpc"
9+
cidr_block = "10.0.0.0/16"
10+
}
11+
12+
# create vpc subnet
13+
resource "tencentcloud_subnet" "subnet" {
14+
name = "subnet"
15+
vpc_id = tencentcloud_vpc.vpc.id
16+
availability_zone = "ap-guangzhou-6"
17+
cidr_block = "10.0.20.0/28"
18+
is_multicast = false
819
}
9-
```
1020
11-
Import
21+
# create cvm
22+
resource "tencentcloud_instance" "example" {
23+
instance_name = "tf_example"
24+
availability_zone = "ap-guangzhou-6"
25+
image_id = "img-9qrfy1xt"
26+
instance_type = "SA3.MEDIUM4"
27+
system_disk_type = "CLOUD_HSSD"
28+
system_disk_size = 100
29+
hostname = "example"
30+
project_id = 0
31+
vpc_id = tencentcloud_vpc.vpc.id
32+
subnet_id = tencentcloud_subnet.subnet.id
33+
allocate_public_ip = true
34+
internet_max_bandwidth_out = 10
1235
13-
eip address_transform can be imported using the id, e.g.
36+
data_disks {
37+
data_disk_type = "CLOUD_HSSD"
38+
data_disk_size = 50
39+
encrypt = false
40+
}
1441
42+
tags = {
43+
tagKey = "tagValue"
44+
}
45+
}
46+
47+
resource "tencentcloud_eip_address_transform" "example" {
48+
instance_id = tencentcloud_instance.example.id
49+
}
1550
```
16-
terraform import tencentcloud_eip_address_transform.address_transform address_transform_id
17-
```

‎tencentcloud/services/cvm/resource_tc_eip_address_transform_test.go

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
99
)
1010

11+
// go test -i; go test -test.run TestAccTencentCloudNeedFixEipAddressTransformResource_basic -v
1112
func TestAccTencentCloudNeedFixEipAddressTransformResource_basic(t *testing.T) {
1213
t.Parallel()
1314
resource.Test(t, resource.TestCase{
@@ -18,21 +19,58 @@ func TestAccTencentCloudNeedFixEipAddressTransformResource_basic(t *testing.T) {
1819
Steps: []resource.TestStep{
1920
{
2021
Config: testAccEipAddressTransform,
21-
Check: resource.ComposeTestCheckFunc(resource.TestCheckResourceAttrSet("tencentcloud_eip_address_transform.address_transform", "id")),
22-
},
23-
{
24-
ResourceName: "tencentcloud_eip_address_transform.address_transform",
25-
ImportState: true,
26-
ImportStateVerify: true,
22+
Check: resource.ComposeTestCheckFunc(
23+
resource.TestCheckResourceAttrSet("tencentcloud_eip_address_transform.example", "id"),
24+
resource.TestCheckResourceAttrSet("tencentcloud_eip_address_transform.example", "instance_id"),
25+
),
2726
},
2827
},
2928
})
3029
}
3130

3231
const testAccEipAddressTransform = `
32+
# create vpc
33+
resource "tencentcloud_vpc" "vpc" {
34+
name = "vpc"
35+
cidr_block = "10.0.0.0/16"
36+
}
37+
38+
# create vpc subnet
39+
resource "tencentcloud_subnet" "subnet" {
40+
name = "subnet"
41+
vpc_id = tencentcloud_vpc.vpc.id
42+
availability_zone = "ap-guangzhou-6"
43+
cidr_block = "10.0.20.0/28"
44+
is_multicast = false
45+
}
46+
47+
# create cvm
48+
resource "tencentcloud_instance" "example" {
49+
instance_name = "tf_example"
50+
availability_zone = "ap-guangzhou-6"
51+
image_id = "img-9qrfy1xt"
52+
instance_type = "SA3.MEDIUM4"
53+
system_disk_type = "CLOUD_HSSD"
54+
system_disk_size = 100
55+
hostname = "example"
56+
project_id = 0
57+
vpc_id = tencentcloud_vpc.vpc.id
58+
subnet_id = tencentcloud_subnet.subnet.id
59+
allocate_public_ip = true
60+
internet_max_bandwidth_out = 10
3361
34-
resource "tencentcloud_eip_address_transform" "address_transform" {
35-
instance_id = "ins-2kcdugsq"
62+
data_disks {
63+
data_disk_type = "CLOUD_HSSD"
64+
data_disk_size = 50
65+
encrypt = false
66+
}
67+
68+
tags = {
69+
tagKey = "tagValue"
70+
}
3671
}
3772
73+
resource "tencentcloud_eip_address_transform" "example" {
74+
instance_id = tencentcloud_instance.example.id
75+
}
3876
`

‎tencentcloud/services/cvm/resource_tc_eip_association_test.go

Lines changed: 109 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,24 @@ import (
1717
// go test -i; go test -test.run TestAccTencentCloudEipAssociationWithInstance -v
1818
func TestAccTencentCloudEipAssociationWithInstance(t *testing.T) {
1919
t.Parallel()
20-
id := "tencentcloud_eip_association.foo"
20+
id := "tencentcloud_eip_association.example"
2121
resource.Test(t, resource.TestCase{
2222
PreCheck: func() { tcacctest.AccPreCheck(t) },
2323
Providers: tcacctest.AccProviders,
2424
CheckDestroy: testAccCheckEipAssociationDestroy,
2525
Steps: []resource.TestStep{
2626
{
27-
PreConfig: func() { tcacctest.AccStepPreConfigSetTempAKSK(t, tcacctest.ACCOUNT_TYPE_COMMON) },
28-
Config: testAccTencentCloudEipAssociationWithInstance,
27+
//PreConfig: func() { tcacctest.AccStepPreConfigSetTempAKSK(t, tcacctest.ACCOUNT_TYPE_COMMON) },
28+
Config: testAccTencentCloudEipAssociationWithInstance,
2929
Check: resource.ComposeTestCheckFunc(
3030
testAccCheckEipAssociationExists(id),
3131
resource.TestCheckResourceAttrSet(id, "eip_id"),
3232
resource.TestCheckResourceAttrSet(id, "instance_id"),
3333
resource.TestCheckNoResourceAttr(id, "network_interface_id"),
3434
resource.TestCheckNoResourceAttr(id, "private_ip"),
35-
resource.TestCheckResourceAttrSet("tencentcloud_eip.foo", "public_ip"),
36-
resource.TestCheckResourceAttr("tencentcloud_eip.foo", "name", tcacctest.DefaultInsName),
37-
resource.TestCheckResourceAttr("tencentcloud_eip.foo", "status", "UNBIND"),
35+
resource.TestCheckResourceAttrSet("tencentcloud_eip.example", "public_ip"),
36+
resource.TestCheckResourceAttr("tencentcloud_eip.example", "name", "tf-example"),
37+
resource.TestCheckResourceAttr("tencentcloud_eip.example", "status", "UNBIND"),
3838
),
3939
},
4040
{
@@ -49,24 +49,24 @@ func TestAccTencentCloudEipAssociationWithInstance(t *testing.T) {
4949
// go test -i; go test -test.run TestAccTencentCloudEipAssociationWithNetworkInterface -v
5050
func TestAccTencentCloudEipAssociationWithNetworkInterface(t *testing.T) {
5151
t.Parallel()
52-
id := "tencentcloud_eip_association.foo"
52+
id := "tencentcloud_eip_association.example"
5353
resource.Test(t, resource.TestCase{
5454
PreCheck: func() { tcacctest.AccPreCheck(t) },
5555
Providers: tcacctest.AccProviders,
5656
CheckDestroy: testAccCheckEipAssociationDestroy,
5757
Steps: []resource.TestStep{
5858
{
59-
PreConfig: func() { tcacctest.AccStepPreConfigSetTempAKSK(t, tcacctest.ACCOUNT_TYPE_COMMON) },
60-
Config: testAccTencentCloudEipAssociationWithNetworkInterface,
59+
//PreConfig: func() { tcacctest.AccStepPreConfigSetTempAKSK(t, tcacctest.ACCOUNT_TYPE_COMMON) },
60+
Config: testAccTencentCloudEipAssociationWithNetworkInterface,
6161
Check: resource.ComposeTestCheckFunc(
6262
testAccCheckEipAssociationExists(id),
6363
resource.TestCheckResourceAttrSet(id, "eip_id"),
6464
resource.TestCheckResourceAttrSet(id, "network_interface_id"),
6565
resource.TestCheckResourceAttrSet(id, "private_ip"),
6666
resource.TestCheckNoResourceAttr(id, "instance_id"),
67-
resource.TestCheckResourceAttrSet("tencentcloud_eip.foo", "public_ip"),
68-
resource.TestCheckResourceAttr("tencentcloud_eip.foo", "name", tcacctest.DefaultInsName),
69-
resource.TestCheckResourceAttr("tencentcloud_eip.foo", "status", "UNBIND"),
67+
resource.TestCheckResourceAttrSet("tencentcloud_eip.example", "public_ip"),
68+
resource.TestCheckResourceAttr("tencentcloud_eip.example", "name", "tf-example"),
69+
resource.TestCheckResourceAttr("tencentcloud_eip.example", "status", "UNBIND"),
7070
),
7171
},
7272
},
@@ -149,41 +149,114 @@ func testAccCheckEipAssociationExists(n string) resource.TestCheckFunc {
149149
}
150150
}
151151

152-
const testAccTencentCloudEipAssociationWithInstance = tcacctest.DefaultInstanceVariable + `
153-
resource "tencentcloud_eip" "foo" {
154-
name = var.instance_name
152+
const testAccTencentCloudEipAssociationWithInstance = `
153+
# create eip
154+
resource "tencentcloud_eip" "example" {
155+
name = "tf-example"
155156
}
156157
157-
resource "tencentcloud_instance" "foo" {
158-
instance_name = var.instance_name
159-
availability_zone = var.availability_cvm_zone
160-
image_id = data.tencentcloud_images.default.images.0.image_id
161-
instance_type = data.tencentcloud_instance_types.default.instance_types.0.instance_type
162-
system_disk_type = "CLOUD_PREMIUM"
158+
# create vpc
159+
resource "tencentcloud_vpc" "vpc" {
160+
name = "vpc"
161+
cidr_block = "10.0.0.0/16"
163162
}
164163
165-
resource "tencentcloud_eip_association" "foo" {
166-
eip_id = tencentcloud_eip.foo.id
167-
instance_id = tencentcloud_instance.foo.id
164+
# create vpc subnet
165+
resource "tencentcloud_subnet" "subnet" {
166+
name = "subnet"
167+
vpc_id = tencentcloud_vpc.vpc.id
168+
availability_zone = "ap-guangzhou-6"
169+
cidr_block = "10.0.20.0/28"
170+
is_multicast = false
171+
}
172+
173+
# create cvm
174+
resource "tencentcloud_instance" "example" {
175+
instance_name = "tf_example"
176+
availability_zone = "ap-guangzhou-6"
177+
image_id = "img-9qrfy1xt"
178+
instance_type = "SA3.MEDIUM4"
179+
system_disk_type = "CLOUD_HSSD"
180+
system_disk_size = 100
181+
hostname = "example"
182+
project_id = 0
183+
vpc_id = tencentcloud_vpc.vpc.id
184+
subnet_id = tencentcloud_subnet.subnet.id
185+
186+
data_disks {
187+
data_disk_type = "CLOUD_HSSD"
188+
data_disk_size = 50
189+
encrypt = false
190+
}
191+
192+
tags = {
193+
tagKey = "tagValue"
194+
}
195+
}
196+
197+
resource "tencentcloud_eip_association" "example" {
198+
eip_id = tencentcloud_eip.example.id
199+
instance_id = tencentcloud_instance.example.id
168200
}
169201
`
170202

171-
const testAccTencentCloudEipAssociationWithNetworkInterface = tcacctest.DefaultVpcVariable + `
172-
resource "tencentcloud_eip" "foo" {
173-
name = var.instance_name
203+
const testAccTencentCloudEipAssociationWithNetworkInterface = `
204+
# create eip
205+
resource "tencentcloud_eip" "example" {
206+
name = "tf-example"
207+
}
208+
209+
# create vpc
210+
resource "tencentcloud_vpc" "vpc" {
211+
name = "vpc"
212+
cidr_block = "10.0.0.0/16"
213+
}
214+
215+
# create vpc subnet
216+
resource "tencentcloud_subnet" "subnet" {
217+
name = "subnet"
218+
vpc_id = tencentcloud_vpc.vpc.id
219+
availability_zone = "ap-guangzhou-6"
220+
cidr_block = "10.0.20.0/28"
221+
is_multicast = false
174222
}
175223
176-
resource "tencentcloud_eni" "foo" {
177-
name = var.instance_name
178-
vpc_id = var.vpc_id
179-
subnet_id = var.subnet_id
180-
description = var.instance_name
224+
# create eni
225+
resource "tencentcloud_eni" "example" {
226+
name = "tf-example"
227+
vpc_id = tencentcloud_vpc.vpc.id
228+
subnet_id = tencentcloud_subnet.subnet.id
229+
description = "remark."
181230
ipv4_count = 1
182231
}
183232
184-
resource "tencentcloud_eip_association" "foo" {
185-
eip_id = tencentcloud_eip.foo.id
186-
network_interface_id = tencentcloud_eni.foo.id
187-
private_ip = tencentcloud_eni.foo.ipv4_info.0.ip
233+
# create cvm
234+
resource "tencentcloud_instance" "example" {
235+
instance_name = "tf_example"
236+
availability_zone = "ap-guangzhou-6"
237+
image_id = "img-9qrfy1xt"
238+
instance_type = "SA3.MEDIUM4"
239+
system_disk_type = "CLOUD_HSSD"
240+
system_disk_size = 100
241+
hostname = "example"
242+
project_id = 0
243+
vpc_id = tencentcloud_vpc.vpc.id
244+
subnet_id = tencentcloud_subnet.subnet.id
245+
246+
data_disks {
247+
data_disk_type = "CLOUD_HSSD"
248+
data_disk_size = 50
249+
encrypt = false
250+
}
251+
252+
tags = {
253+
tagKey = "tagValue"
254+
}
255+
}
256+
257+
resource "tencentcloud_eip_association" "example" {
258+
eip_id = tencentcloud_eip.example.id
259+
network_interface_id = tencentcloud_eni.example.id
260+
private_ip = tencentcloud_eni.example.ipv4_info[0].ip
188261
}
189262
`

‎tencentcloud/services/cvm/resource_tc_eip_normal_address_return.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Provides a resource to create a vpc normal_address_return
33
Example Usage
44

55
```hcl
6-
resource "tencentcloud_eip_normal_address_return" "normal_address_return" {
6+
resource "tencentcloud_eip_normal_address_return" "example" {
77
address_ips = ["172.16.17.32"]
88
}
9-
```
9+
```

‎tencentcloud/services/cvm/resource_tc_eip_normal_address_return_test.go

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
99
)
1010

11+
// go test -i; go test -test.run TestAccTencentCloudNeedFixEipNormalAddressReturnResource_basic -v
1112
func TestAccTencentCloudNeedFixEipNormalAddressReturnResource_basic(t *testing.T) {
1213
t.Parallel()
1314
resource.Test(t, resource.TestCase{
@@ -18,15 +19,58 @@ func TestAccTencentCloudNeedFixEipNormalAddressReturnResource_basic(t *testing.T
1819
Steps: []resource.TestStep{
1920
{
2021
Config: testAccEipNormalAddressReturn,
21-
Check: resource.ComposeTestCheckFunc(resource.TestCheckResourceAttrSet("tencentcloud_eip_normal_address_return.normal_address_return", "id")),
22+
Check: resource.ComposeTestCheckFunc(
23+
resource.TestCheckResourceAttrSet("tencentcloud_eip_normal_address_return.example", "id"),
24+
resource.TestCheckResourceAttrSet("tencentcloud_eip_normal_address_return.example", "address_ips.#"),
25+
),
2226
},
2327
},
2428
})
2529
}
2630

2731
const testAccEipNormalAddressReturn = `
32+
# create vpc
33+
resource "tencentcloud_vpc" "vpc" {
34+
name = "vpc"
35+
cidr_block = "10.0.0.0/16"
36+
}
37+
38+
# create vpc subnet
39+
resource "tencentcloud_subnet" "subnet" {
40+
name = "subnet"
41+
vpc_id = tencentcloud_vpc.vpc.id
42+
availability_zone = "ap-guangzhou-6"
43+
cidr_block = "10.0.20.0/28"
44+
is_multicast = false
45+
}
46+
47+
# create cvm
48+
resource "tencentcloud_instance" "example" {
49+
instance_name = "tf_example"
50+
availability_zone = "ap-guangzhou-6"
51+
image_id = "img-9qrfy1xt"
52+
instance_type = "SA3.MEDIUM4"
53+
system_disk_type = "CLOUD_HSSD"
54+
system_disk_size = 100
55+
hostname = "example"
56+
project_id = 0
57+
vpc_id = tencentcloud_vpc.vpc.id
58+
subnet_id = tencentcloud_subnet.subnet.id
59+
allocate_public_ip = true
60+
internet_max_bandwidth_out = 10
61+
62+
data_disks {
63+
data_disk_type = "CLOUD_HSSD"
64+
data_disk_size = 50
65+
encrypt = false
66+
}
67+
68+
tags = {
69+
tagKey = "tagValue"
70+
}
71+
}
2872
29-
resource "tencentcloud_eip_normal_address_return" "normal_address_return" {
30-
address_ips = ["111.230.44.68"]
73+
resource "tencentcloud_eip_normal_address_return" "example" {
74+
address_ips = [tencentcloud_instance.example.public_ip]
3175
}
3276
`

‎tencentcloud/services/cvm/resource_tc_eip_public_address_adjust.md

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,54 @@ Provides a resource to create a eip public_address_adjust
33
Example Usage
44

55
```hcl
6-
resource "tencentcloud_eip_public_address_adjust" "public_address_adjust" {
7-
instance_id = "ins-cr2rfq78"
8-
address_id = "eip-erft45fu"
6+
# create vpc
7+
resource "tencentcloud_vpc" "vpc" {
8+
name = "vpc"
9+
cidr_block = "10.0.0.0/16"
10+
}
11+
12+
# create vpc subnet
13+
resource "tencentcloud_subnet" "subnet" {
14+
name = "subnet"
15+
vpc_id = tencentcloud_vpc.vpc.id
16+
availability_zone = "ap-guangzhou-6"
17+
cidr_block = "10.0.20.0/28"
18+
is_multicast = false
19+
}
20+
21+
# create cvm
22+
resource "tencentcloud_instance" "example" {
23+
instance_name = "tf_example"
24+
availability_zone = "ap-guangzhou-6"
25+
image_id = "img-9qrfy1xt"
26+
instance_type = "SA3.MEDIUM4"
27+
system_disk_type = "CLOUD_HSSD"
28+
system_disk_size = 100
29+
hostname = "example"
30+
project_id = 0
31+
vpc_id = tencentcloud_vpc.vpc.id
32+
subnet_id = tencentcloud_subnet.subnet.id
33+
allocate_public_ip = true
34+
internet_max_bandwidth_out = 10
35+
36+
data_disks {
37+
data_disk_type = "CLOUD_HSSD"
38+
data_disk_size = 50
39+
encrypt = false
40+
}
41+
42+
tags = {
43+
tagKey = "tagValue"
44+
}
45+
}
46+
47+
# create eip
48+
resource "tencentcloud_eip" "example" {
49+
name = "tf-example"
50+
}
51+
52+
resource "tencentcloud_eip_public_address_adjust" "example" {
53+
instance_id = tencentcloud_instance.example.id
54+
address_id = tencentcloud_eip.example.id
955
}
1056
```

‎tencentcloud/services/cvm/resource_tc_eip_public_address_adjust_test.go

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import (
88
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
99
)
1010

11-
// go test -i; go test -test.run TestAccTencentCloudNeedFixVpcPublicAddressAdjustResource_basic -v
12-
func TestAccTencentCloudNeedFixVpcPublicAddressAdjustResource_basic(t *testing.T) {
11+
// go test -i; go test -test.run TestAccTencentCloudVpcPublicAddressAdjustResource_basic -v
12+
func TestAccTencentCloudVpcPublicAddressAdjustResource_basic(t *testing.T) {
1313
t.Parallel()
1414
resource.Test(t, resource.TestCase{
1515
PreCheck: func() {
@@ -20,16 +20,64 @@ func TestAccTencentCloudNeedFixVpcPublicAddressAdjustResource_basic(t *testing.T
2020
{
2121
Config: testAccVpcPublicAddressAdjust,
2222
Check: resource.ComposeTestCheckFunc(
23-
resource.TestCheckResourceAttrSet("tencentcloud_eip_public_address_adjust.public_address_adjust", "id"),
23+
resource.TestCheckResourceAttrSet("tencentcloud_eip_public_address_adjust.example", "id"),
24+
resource.TestCheckResourceAttrSet("tencentcloud_eip_public_address_adjust.example", "instance_id"),
25+
resource.TestCheckResourceAttrSet("tencentcloud_eip_public_address_adjust.example", "address_id"),
2426
),
2527
},
2628
},
2729
})
2830
}
2931

3032
const testAccVpcPublicAddressAdjust = `
31-
resource "tencentcloud_eip_public_address_adjust" "public_address_adjust" {
32-
instance_id = "ins-cr2rfq78"
33-
address_id = "eip-erft45fu"
33+
# create vpc
34+
resource "tencentcloud_vpc" "vpc" {
35+
name = "vpc"
36+
cidr_block = "10.0.0.0/16"
37+
}
38+
39+
# create vpc subnet
40+
resource "tencentcloud_subnet" "subnet" {
41+
name = "subnet"
42+
vpc_id = tencentcloud_vpc.vpc.id
43+
availability_zone = "ap-guangzhou-6"
44+
cidr_block = "10.0.20.0/28"
45+
is_multicast = false
46+
}
47+
48+
# create cvm
49+
resource "tencentcloud_instance" "example" {
50+
instance_name = "tf_example"
51+
availability_zone = "ap-guangzhou-6"
52+
image_id = "img-9qrfy1xt"
53+
instance_type = "SA3.MEDIUM4"
54+
system_disk_type = "CLOUD_HSSD"
55+
system_disk_size = 100
56+
hostname = "example"
57+
project_id = 0
58+
vpc_id = tencentcloud_vpc.vpc.id
59+
subnet_id = tencentcloud_subnet.subnet.id
60+
allocate_public_ip = true
61+
internet_max_bandwidth_out = 10
62+
63+
data_disks {
64+
data_disk_type = "CLOUD_HSSD"
65+
data_disk_size = 50
66+
encrypt = false
67+
}
68+
69+
tags = {
70+
tagKey = "tagValue"
71+
}
72+
}
73+
74+
# create eip
75+
resource "tencentcloud_eip" "example" {
76+
name = "tf-example"
77+
}
78+
79+
resource "tencentcloud_eip_public_address_adjust" "example" {
80+
instance_id = tencentcloud_instance.example.id
81+
address_id = tencentcloud_eip.example.id
3482
}
3583
`

‎tencentcloud/services/cvm/resource_tc_instance.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,7 +1442,7 @@ func resourceTencentCloudInstanceDelete(d *schema.ResourceData, meta interface{}
14421442
instanceId := d.Id()
14431443
//check is force delete or not
14441444
forceDelete := d.Get("force_delete").(bool)
1445-
//instanceChargeType := d.Get("instance_charge_type").(string)
1445+
instanceChargeType := d.Get("instance_charge_type").(string)
14461446

14471447
cvmService := CvmService{
14481448
client: meta.(tccommon.ProviderMeta).GetAPIV3Conn(),
@@ -1465,18 +1465,18 @@ func resourceTencentCloudInstanceDelete(d *schema.ResourceData, meta interface{}
14651465
}
14661466

14671467
// prepaid need delete again
1468-
//if instanceChargeType == CVM_CHARGE_TYPE_PREPAID {
1469-
// err = resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
1470-
// errRet := cvmService.DeleteInstance(ctx, instanceId)
1471-
// if errRet != nil {
1472-
// return tccommon.RetryError(errRet)
1473-
// }
1474-
// return nil
1475-
// })
1476-
// if err != nil {
1477-
// return err
1478-
// }
1479-
//}
1468+
if instanceChargeType == CVM_CHARGE_TYPE_PREPAID {
1469+
err = resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
1470+
errRet := cvmService.DeleteInstance(ctx, instanceId)
1471+
if errRet != nil {
1472+
return tccommon.RetryError(errRet)
1473+
}
1474+
return nil
1475+
})
1476+
if err != nil {
1477+
return err
1478+
}
1479+
}
14801480

14811481
//check recycling
14821482
notExist := false

‎tencentcloud/services/cvm/resource_tc_reserved_instance_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package cvm_test
22

33
import (
4-
tcacctest "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/acctest"
54
"testing"
65

6+
tcacctest "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/acctest"
7+
78
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
89
)
910

‎website/docs/r/cvm_sync_image.html.markdown

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,13 @@ Provides a resource to create a cvm sync_image
1414
## Example Usage
1515

1616
```hcl
17-
resource "tencentcloud_cvm_sync_image" "sync_image" {
18-
image_id = "img-xxxxxx"
17+
data "tencentcloud_images" "example" {
18+
image_type = ["PRIVATE_IMAGE"]
19+
image_name_regex = "MyImage"
20+
}
21+
22+
resource "tencentcloud_cvm_sync_image" "example" {
23+
image_id = data.tencentcloud_images.example.images.0.image_id
1924
destination_regions = ["ap-guangzhou", "ap-shanghai"]
2025
}
2126
```

‎website/docs/r/eip_address_transform.html.markdown

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,49 @@ Provides a resource to create a eip address_transform
1414
## Example Usage
1515

1616
```hcl
17-
resource "tencentcloud_eip_address_transform" "address_transform" {
18-
instance_id = ""
17+
# create vpc
18+
resource "tencentcloud_vpc" "vpc" {
19+
name = "vpc"
20+
cidr_block = "10.0.0.0/16"
21+
}
22+
23+
# create vpc subnet
24+
resource "tencentcloud_subnet" "subnet" {
25+
name = "subnet"
26+
vpc_id = tencentcloud_vpc.vpc.id
27+
availability_zone = "ap-guangzhou-6"
28+
cidr_block = "10.0.20.0/28"
29+
is_multicast = false
30+
}
31+
32+
# create cvm
33+
resource "tencentcloud_instance" "example" {
34+
instance_name = "tf_example"
35+
availability_zone = "ap-guangzhou-6"
36+
image_id = "img-9qrfy1xt"
37+
instance_type = "SA3.MEDIUM4"
38+
system_disk_type = "CLOUD_HSSD"
39+
system_disk_size = 100
40+
hostname = "example"
41+
project_id = 0
42+
vpc_id = tencentcloud_vpc.vpc.id
43+
subnet_id = tencentcloud_subnet.subnet.id
44+
allocate_public_ip = true
45+
internet_max_bandwidth_out = 10
46+
47+
data_disks {
48+
data_disk_type = "CLOUD_HSSD"
49+
data_disk_size = 50
50+
encrypt = false
51+
}
52+
53+
tags = {
54+
tagKey = "tagValue"
55+
}
56+
}
57+
58+
resource "tencentcloud_eip_address_transform" "example" {
59+
instance_id = tencentcloud_instance.example.id
1960
}
2061
```
2162

@@ -33,11 +74,3 @@ In addition to all arguments above, the following attributes are exported:
3374

3475

3576

36-
## Import
37-
38-
eip address_transform can be imported using the id, e.g.
39-
40-
```
41-
terraform import tencentcloud_eip_address_transform.address_transform address_transform_id
42-
```
43-

‎website/docs/r/eip_normal_address_return.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Provides a resource to create a vpc normal_address_return
1414
## Example Usage
1515

1616
```hcl
17-
resource "tencentcloud_eip_normal_address_return" "normal_address_return" {
17+
resource "tencentcloud_eip_normal_address_return" "example" {
1818
address_ips = ["172.16.17.32"]
1919
}
2020
```

‎website/docs/r/eip_public_address_adjust.html.markdown

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,55 @@ Provides a resource to create a eip public_address_adjust
1414
## Example Usage
1515

1616
```hcl
17-
resource "tencentcloud_eip_public_address_adjust" "public_address_adjust" {
18-
instance_id = "ins-cr2rfq78"
19-
address_id = "eip-erft45fu"
17+
# create vpc
18+
resource "tencentcloud_vpc" "vpc" {
19+
name = "vpc"
20+
cidr_block = "10.0.0.0/16"
21+
}
22+
23+
# create vpc subnet
24+
resource "tencentcloud_subnet" "subnet" {
25+
name = "subnet"
26+
vpc_id = tencentcloud_vpc.vpc.id
27+
availability_zone = "ap-guangzhou-6"
28+
cidr_block = "10.0.20.0/28"
29+
is_multicast = false
30+
}
31+
32+
# create cvm
33+
resource "tencentcloud_instance" "example" {
34+
instance_name = "tf_example"
35+
availability_zone = "ap-guangzhou-6"
36+
image_id = "img-9qrfy1xt"
37+
instance_type = "SA3.MEDIUM4"
38+
system_disk_type = "CLOUD_HSSD"
39+
system_disk_size = 100
40+
hostname = "example"
41+
project_id = 0
42+
vpc_id = tencentcloud_vpc.vpc.id
43+
subnet_id = tencentcloud_subnet.subnet.id
44+
allocate_public_ip = true
45+
internet_max_bandwidth_out = 10
46+
47+
data_disks {
48+
data_disk_type = "CLOUD_HSSD"
49+
data_disk_size = 50
50+
encrypt = false
51+
}
52+
53+
tags = {
54+
tagKey = "tagValue"
55+
}
56+
}
57+
58+
# create eip
59+
resource "tencentcloud_eip" "example" {
60+
name = "tf-example"
61+
}
62+
63+
resource "tencentcloud_eip_public_address_adjust" "example" {
64+
instance_id = tencentcloud_instance.example.id
65+
address_id = tencentcloud_eip.example.id
2066
}
2167
```
2268

0 commit comments

Comments
 (0)
Please sign in to comment.