Skip to content

Commit 6cd43d2

Browse files
author
mikatong
committed
update
1 parent 5e49563 commit 6cd43d2

12 files changed

+36
-184
lines changed

tencentcloud/resource_tc_as_protect_instances.go

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ Example Usage
55
66
```hcl
77
resource "tencentcloud_as_protect_instances" "protect_instances" {
8-
auto_scaling_group_id = ""
9-
instance_ids = ""
10-
protected_from_scale_in = ""
8+
auto_scaling_group_id = tencentcloud_as_scaling_group.scaling_group.id
9+
instance_ids = ["ins-xxxxx"]
10+
protected_from_scale_in = true
1111
}
1212
```
1313
@@ -57,24 +57,23 @@ func resourceTencentCloudAsProtectInstances() *schema.Resource {
5757
}
5858

5959
func resourceTencentCloudAsProtectInstancesCreate(d *schema.ResourceData, meta interface{}) error {
60-
defer logElapsed("data_source.tencentcloud_as_protect_instances.read")()
60+
defer logElapsed("data_source.tencentcloud_as_protect_instances.create")()
6161
defer inconsistentCheck(d, meta)()
6262

6363
logId := getLogId(contextNil)
6464

6565
var (
66-
request = as.NewSetInstancesProtectionRequest()
67-
response = as.NewSetInstancesProtectionResponse()
68-
//instanceIds string
66+
request = as.NewSetInstancesProtectionRequest()
6967
)
7068
if v, ok := d.GetOk("auto_scaling_group_id"); ok {
7169
request.AutoScalingGroupId = helper.String(v.(string))
7270
}
73-
71+
ids := make([]string, 0)
7472
if v, ok := d.GetOk("instance_ids"); ok {
7573
instanceIdsSet := v.(*schema.Set).List()
7674
for i := range instanceIdsSet {
7775
instanceIds := instanceIdsSet[i].(string)
76+
ids = append(ids, instanceIds)
7877
request.InstanceIds = append(request.InstanceIds, &instanceIds)
7978
}
8079
}
@@ -88,18 +87,17 @@ func resourceTencentCloudAsProtectInstancesCreate(d *schema.ResourceData, meta i
8887
if e != nil {
8988
return retryError(e)
9089
} else {
91-
log.Println("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString())
90+
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString())
9291
}
93-
response = result
9492
return nil
9593
})
9694
if err != nil {
97-
log.Println("[CRITAL]%s operate as protectInstances failed, reason:%+v", logId, err)
95+
log.Printf("[CRITAL]%s operate as protectInstances failed, reason:%+v", logId, err)
9896
return nil
9997
}
10098

10199
// 需要 setId,可以通过InstancesId作为ID
102-
d.SetId("")
100+
d.SetId(helper.DataResourceIdsHash(ids))
103101

104102
return resourceTencentCloudAsProtectInstancesRead(d, meta)
105103
}

tencentcloud/resource_tc_as_protect_instances_test.go

Lines changed: 0 additions & 33 deletions
This file was deleted.

tencentcloud/resource_tc_as_remove_instances.go

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,10 @@ Example Usage
55
66
```hcl
77
resource "tencentcloud_as_remove_instances" "remove_instances" {
8-
auto_scaling_group_id = ""
9-
instance_ids = ""
8+
auto_scaling_group_id = tencentcloud_as_scaling_group.scaling_group.id
9+
instance_ids = ["ins-xxxxxx"]
1010
}
1111
```
12-
13-
Import
14-
15-
as remove_instances can be imported using the id, e.g.
16-
17-
```
18-
terraform import tencentcloud_as_remove_instances.remove_instances remove_instances_id
19-
```
2012
*/
2113
package tencentcloud
2214

@@ -56,7 +48,7 @@ func resourceTencentCloudAsRemoveInstances() *schema.Resource {
5648
}
5749

5850
func resourceTencentCloudAsRemoveInstancesCreate(d *schema.ResourceData, meta interface{}) error {
59-
defer logElapsed("data_source.tencentcloud_as_remove_instances.read")()
51+
defer logElapsed("data_source.tencentcloud_as_remove_instances.create")()
6052
defer inconsistentCheck(d, meta)()
6153

6254
logId := getLogId(contextNil)
@@ -83,13 +75,13 @@ func resourceTencentCloudAsRemoveInstancesCreate(d *schema.ResourceData, meta in
8375
if e != nil {
8476
return retryError(e)
8577
} else {
86-
log.Println("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString())
78+
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString())
8779
}
8880
response = result
8981
return nil
9082
})
9183
if err != nil {
92-
log.Println("[CRITAL]%s operate as removeInstances failed, reason:%+v", logId, err)
84+
log.Printf("[CRITAL]%s operate as removeInstances failed, reason:%+v", logId, err)
9385
return nil
9486
}
9587

tencentcloud/resource_tc_as_remove_instances_test.go

Lines changed: 0 additions & 32 deletions
This file was deleted.

tencentcloud/resource_tc_as_start_instances.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ Example Usage
55
66
```hcl
77
resource "tencentcloud_as_start_instances" "start_instances" {
8-
auto_scaling_group_id = ""
9-
instance_ids = ""
8+
auto_scaling_group_id = tencentcloud_as_scaling_group.scaling_group.id
9+
instance_ids = ["ins-xxxxx"]
1010
}
1111
```
1212
@@ -51,7 +51,7 @@ func resourceTencentCloudAsStartInstances() *schema.Resource {
5151
}
5252

5353
func resourceTencentCloudAsStartInstancesCreate(d *schema.ResourceData, meta interface{}) error {
54-
defer logElapsed("data_source.tencentcloud_as_start_instances.read")()
54+
defer logElapsed("data_source.tencentcloud_as_start_instances.create")()
5555
defer inconsistentCheck(d, meta)()
5656

5757
logId := getLogId(contextNil)
@@ -78,13 +78,13 @@ func resourceTencentCloudAsStartInstancesCreate(d *schema.ResourceData, meta int
7878
if e != nil {
7979
return retryError(e)
8080
} else {
81-
log.Println("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString())
81+
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString())
8282
}
8383
response = result
8484
return nil
8585
})
8686
if err != nil {
87-
log.Println("[CRITAL]%s operate as startInstances failed, reason:%+v", logId, err)
87+
log.Printf("[CRITAL]%s operate as startInstances failed, reason:%+v", logId, err)
8888
return nil
8989
}
9090

tencentcloud/resource_tc_as_start_instances_test.go

Lines changed: 0 additions & 32 deletions
This file was deleted.

tencentcloud/resource_tc_as_stop_instances.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ Example Usage
55
66
```hcl
77
resource "tencentcloud_as_stop_instances" "stop_instances" {
8-
auto_scaling_group_id = ""
9-
instance_ids = ""
10-
stopped_mode = ""
8+
auto_scaling_group_id = tencentcloud_as_scaling_group.scaling_group.id
9+
instance_ids = ["ins-xxxx"]
10+
stopped_mode = "STOP_CHARGING"
1111
}
1212
```
1313
@@ -59,7 +59,7 @@ func resourceTencentCloudAsStopInstances() *schema.Resource {
5959
}
6060

6161
func resourceTencentCloudAsStopInstancesCreate(d *schema.ResourceData, meta interface{}) error {
62-
defer logElapsed("data_source.tencentcloud_as_stop_instances.read")()
62+
defer logElapsed("data_source.tencentcloud_as_stop_instances.create")()
6363
defer inconsistentCheck(d, meta)()
6464

6565
logId := getLogId(contextNil)
@@ -90,13 +90,13 @@ func resourceTencentCloudAsStopInstancesCreate(d *schema.ResourceData, meta inte
9090
if e != nil {
9191
return retryError(e)
9292
} else {
93-
log.Println("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString())
93+
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString())
9494
}
9595
response = result
9696
return nil
9797
})
9898
if err != nil {
99-
log.Println("[CRITAL]%s operate as stopInstances failed, reason:%+v", logId, err)
99+
log.Printf("[CRITAL]%s operate as stopInstances failed, reason:%+v", logId, err)
100100
return nil
101101
}
102102

tencentcloud/resource_tc_as_stop_instances_test.go

Lines changed: 0 additions & 33 deletions
This file was deleted.

website/docs/r/as_protect_instances.html.markdown

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ Provides a resource to create a as protect_instances
1515

1616
```hcl
1717
resource "tencentcloud_as_protect_instances" "protect_instances" {
18-
auto_scaling_group_id = ""
19-
instance_ids = ""
20-
protected_from_scale_in = ""
18+
auto_scaling_group_id = tencentcloud_as_scaling_group.scaling_group.id
19+
instance_ids = ["ins-xxxxx"]
20+
protected_from_scale_in = true
2121
}
2222
```
2323

website/docs/r/as_remove_instances.html.markdown

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ Provides a resource to create a as remove_instances
1515

1616
```hcl
1717
resource "tencentcloud_as_remove_instances" "remove_instances" {
18-
auto_scaling_group_id = ""
19-
instance_ids = ""
18+
auto_scaling_group_id = tencentcloud_as_scaling_group.scaling_group.id
19+
instance_ids = ["ins-xxxxxx"]
2020
}
2121
```
2222

@@ -35,11 +35,3 @@ In addition to all arguments above, the following attributes are exported:
3535

3636

3737

38-
## Import
39-
40-
as remove_instances can be imported using the id, e.g.
41-
42-
```
43-
terraform import tencentcloud_as_remove_instances.remove_instances remove_instances_id
44-
```
45-

0 commit comments

Comments
 (0)