Skip to content

Commit f571ee6

Browse files
authored
cvm support timeout (#2276)
* cvm support timeout * cvm support timeout
1 parent 342949a commit f571ee6

File tree

3 files changed

+27
-16
lines changed

3 files changed

+27
-16
lines changed

.changelog/2276.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_instance: Support set create timeout.
3+
```

tencentcloud/resource_tc_instance.go

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,26 +65,29 @@ resource "tencentcloud_instance" "cvm_postpaid" {
6565
6666
// Create a PREPAID CVM instance
6767
resource "tencentcloud_instance" "cvm_prepaid" {
68-
instance_name = "cvm_prepaid"
69-
availability_zone = data.tencentcloud_availability_zones.my_favorite_zones.zones.0.name
70-
image_id = data.tencentcloud_images.my_favorite_image.images.0.image_id
71-
instance_type = data.tencentcloud_instance_types.my_favorite_instance_types.instance_types.0.instance_type
72-
system_disk_type = "CLOUD_PREMIUM"
73-
system_disk_size = 50
74-
hostname = "user"
75-
project_id = 0
76-
vpc_id = tencentcloud_vpc.app.id
77-
subnet_id = tencentcloud_subnet.app.id
78-
instance_charge_type = "PREPAID"
79-
instance_charge_type_prepaid_period = 1
68+
timeouts {
69+
create = "30m"
70+
}
71+
instance_name = "cvm_prepaid"
72+
availability_zone = data.tencentcloud_availability_zones.my_favorite_zones.zones.0.name
73+
image_id = data.tencentcloud_images.my_favorite_image.images.0.image_id
74+
instance_type = data.tencentcloud_instance_types.my_favorite_instance_types.instance_types.0.instance_type
75+
system_disk_type = "CLOUD_PREMIUM"
76+
system_disk_size = 50
77+
hostname = "user"
78+
project_id = 0
79+
vpc_id = tencentcloud_vpc.app.id
80+
subnet_id = tencentcloud_subnet.app.id
81+
instance_charge_type = "PREPAID"
82+
instance_charge_type_prepaid_period = 1
8083
instance_charge_type_prepaid_renew_flag = "NOTIFY_AND_MANUAL_RENEW"
8184
data_disks {
8285
data_disk_type = "CLOUD_PREMIUM"
8386
data_disk_size = 50
84-
encrypt = false
87+
encrypt = false
8588
}
8689
force_delete = true
87-
tags = {
90+
tags = {
8891
tagKey = "tagValue"
8992
}
9093
}
@@ -127,7 +130,9 @@ func resourceTencentCloudInstance() *schema.Resource {
127130
Importer: &schema.ResourceImporter{
128131
State: schema.ImportStatePassthrough,
129132
},
130-
133+
Timeouts: &schema.ResourceTimeout{
134+
Create: schema.DefaultTimeout(15 * time.Minute),
135+
},
131136
Schema: map[string]*schema.Schema{
132137
"image_id": {
133138
Type: schema.TypeString,
@@ -765,7 +770,7 @@ func resourceTencentCloudInstanceCreate(d *schema.ResourceData, meta interface{}
765770
//get system disk ID and data disk ID
766771
var systemDiskId string
767772
var dataDiskIds []string
768-
err = resource.Retry(5*readRetryTimeout, func() *resource.RetryError {
773+
err = resource.Retry(d.Timeout(schema.TimeoutCreate), func() *resource.RetryError {
769774
instance, errRet := cvmService.DescribeInstanceById(ctx, instanceId)
770775
if errRet != nil {
771776
return retryError(errRet, InternalError)

website/docs/r/instance.html.markdown

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ resource "tencentcloud_instance" "cvm_postpaid" {
7575
7676
// Create a PREPAID CVM instance
7777
resource "tencentcloud_instance" "cvm_prepaid" {
78+
timeouts {
79+
create = "30m"
80+
}
7881
instance_name = "cvm_prepaid"
7982
availability_zone = data.tencentcloud_availability_zones.my_favorite_zones.zones.0.name
8083
image_id = data.tencentcloud_images.my_favorite_image.images.0.image_id

0 commit comments

Comments
 (0)