Skip to content

Commit 8781a06

Browse files
authored
Merge pull request #501 from Sesede/master
fix update issue in resource `tencentcloud_vpn_connection`
2 parents 4b6c127 + 6237c95 commit 8781a06

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
## 1.41.2 (Unreleased)
2+
3+
BUG FIXES:
4+
* Resource: `tencentcloud_vpn_connection` fix `security_group_policy` update issue when apply repeatedly.
5+
26
## 1.41.1 (August 27, 2020)
37

48
BUG FIXES:

tencentcloud/resource_tc_vpn_connection.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func resourceTencentCloudVpnConnection() *schema.Resource {
110110
Description: "Pre-shared key of the VPN connection.",
111111
},
112112
"security_group_policy": {
113-
Type: schema.TypeList,
113+
Type: schema.TypeSet,
114114
Required: true,
115115
Description: "Security group policy of the VPN connection.",
116116
Elem: &schema.Resource{
@@ -320,7 +320,7 @@ func resourceTencentCloudVpnConnectionCreate(d *schema.ResourceData, meta interf
320320

321321
//set up SecurityPolicyDatabases
322322

323-
sgps := d.Get("security_group_policy").([]interface{})
323+
sgps := d.Get("security_group_policy").(*schema.Set).List()
324324
if len(sgps) < 1 {
325325
return fmt.Errorf("Para `security_group_policy` should be set at least one.")
326326
}
@@ -639,13 +639,13 @@ func resourceTencentCloudVpnConnectionUpdate(d *schema.ResourceData, meta interf
639639

640640
//set up SecurityPolicyDatabases
641641
if d.HasChange("security_group_policy") {
642-
sgps := d.Get("security_group_policy").([]interface{})
642+
sgps := d.Get("security_group_policy").(*schema.Set).List()
643643
if len(sgps) < 1 {
644644
return fmt.Errorf("Para `security_group_policy` should be set at least one.")
645645
}
646+
request.SecurityPolicyDatabases = make([]*vpc.SecurityPolicyDatabase, 0, len(sgps))
646647
for _, v := range sgps {
647648
m := v.(map[string]interface{})
648-
request.SecurityPolicyDatabases = make([]*vpc.SecurityPolicyDatabase, 0, len(sgps))
649649
var sgp vpc.SecurityPolicyDatabase
650650
local := m["local_cidr_block"].(string)
651651
sgp.LocalCidrBlock = &local

0 commit comments

Comments
 (0)