Skip to content

Commit 7f12446

Browse files
committed
fix: modify route_update
1 parent ed8feb2 commit 7f12446

File tree

2 files changed

+68
-27
lines changed

2 files changed

+68
-27
lines changed

tencentcloud/resource_tc_tse_cngw_route.go

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ func resourceTencentCloudTseCngwRouteUpdate(d *schema.ResourceData, meta interfa
476476
request.RouteName = &routeName
477477
request.RouteID = cngwRoute.ID
478478

479-
immutableArgs := []string{"gateway_id", "service_id", "route_name"}
479+
immutableArgs := []string{"gateway_id", "service_id", "route_name", "force_https"}
480480

481481
for _, v := range immutableArgs {
482482
if d.HasChange(v) {
@@ -494,33 +494,27 @@ func resourceTencentCloudTseCngwRouteUpdate(d *schema.ResourceData, meta interfa
494494
}
495495
}
496496

497-
if d.HasChange("hosts") {
498-
if v, ok := d.GetOk("hosts"); ok {
499-
hostsSet := v.(*schema.Set).List()
500-
for i := range hostsSet {
501-
hosts := hostsSet[i].(string)
502-
request.Hosts = append(request.Hosts, &hosts)
503-
}
497+
if v, ok := d.GetOk("hosts"); ok {
498+
hostsSet := v.(*schema.Set).List()
499+
for i := range hostsSet {
500+
hosts := hostsSet[i].(string)
501+
request.Hosts = append(request.Hosts, &hosts)
504502
}
505503
}
506504

507-
if d.HasChange("paths") {
508-
if v, ok := d.GetOk("paths"); ok {
509-
pathsSet := v.(*schema.Set).List()
510-
for i := range pathsSet {
511-
paths := pathsSet[i].(string)
512-
request.Paths = append(request.Paths, &paths)
513-
}
505+
if v, ok := d.GetOk("paths"); ok {
506+
pathsSet := v.(*schema.Set).List()
507+
for i := range pathsSet {
508+
paths := pathsSet[i].(string)
509+
request.Paths = append(request.Paths, &paths)
514510
}
515511
}
516512

517-
if d.HasChange("protocols") {
518-
if v, ok := d.GetOk("protocols"); ok {
519-
protocolsSet := v.(*schema.Set).List()
520-
for i := range protocolsSet {
521-
protocols := protocolsSet[i].(string)
522-
request.Protocols = append(request.Protocols, &protocols)
523-
}
513+
if v, ok := d.GetOk("protocols"); ok {
514+
protocolsSet := v.(*schema.Set).List()
515+
for i := range protocolsSet {
516+
protocols := protocolsSet[i].(string)
517+
request.Protocols = append(request.Protocols, &protocols)
524518
}
525519
}
526520

@@ -542,11 +536,11 @@ func resourceTencentCloudTseCngwRouteUpdate(d *schema.ResourceData, meta interfa
542536
}
543537
}
544538

545-
if d.HasChange("force_https") {
546-
if v, ok := d.GetOkExists("force_https"); ok {
547-
request.ForceHttps = helper.Bool(v.(bool))
548-
}
549-
}
539+
// if d.HasChange("force_https") {
540+
// if v, ok := d.GetOkExists("force_https"); ok {
541+
// request.ForceHttps = helper.Bool(v.(bool))
542+
// }
543+
// }
550544

551545
if d.HasChange("destination_ports") {
552546
if v, ok := d.GetOk("destination_ports"); ok {

tencentcloud/resource_tc_tse_cngw_route_test.go

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,26 @@ func TestAccTencentCloudTseCngwRouteResource_basic(t *testing.T) {
4545
ImportState: true,
4646
ImportStateVerify: true,
4747
},
48+
{
49+
Config: testAccTseCngwRouteUp,
50+
Check: resource.ComposeTestCheckFunc(
51+
testAccCheckTseCngwRouteExists("tencentcloud_tse_cngw_route.cngw_route"),
52+
resource.TestCheckResourceAttrSet("tencentcloud_tse_cngw_route.cngw_route", "id"),
53+
resource.TestCheckResourceAttr("tencentcloud_tse_cngw_route.cngw_route", "gateway_id", defaultTseGatewayId),
54+
// resource.TestCheckResourceAttr("tencentcloud_tse_cngw_route.cngw_route", "force_https", "true"),
55+
resource.TestCheckResourceAttr("tencentcloud_tse_cngw_route.cngw_route", "hosts.#", "1"),
56+
resource.TestCheckResourceAttr("tencentcloud_tse_cngw_route.cngw_route", "https_redirect_status_code", "301"),
57+
resource.TestCheckResourceAttr("tencentcloud_tse_cngw_route.cngw_route", "paths.#", "1"),
58+
resource.TestCheckResourceAttr("tencentcloud_tse_cngw_route.cngw_route", "headers.#", "1"),
59+
resource.TestCheckResourceAttr("tencentcloud_tse_cngw_route.cngw_route", "headers.0.key", "req"),
60+
resource.TestCheckResourceAttr("tencentcloud_tse_cngw_route.cngw_route", "headers.0.value", "terraform1"),
61+
resource.TestCheckResourceAttr("tencentcloud_tse_cngw_route.cngw_route", "preserve_host", "true"),
62+
resource.TestCheckResourceAttr("tencentcloud_tse_cngw_route.cngw_route", "protocols.#", "1"),
63+
resource.TestCheckResourceAttr("tencentcloud_tse_cngw_route.cngw_route", "route_name", "terraform-route"),
64+
resource.TestCheckResourceAttr("tencentcloud_tse_cngw_route.cngw_route", "service_id", "b6017eaf-2363-481e-9e93-8d65aaf498cd"),
65+
resource.TestCheckResourceAttr("tencentcloud_tse_cngw_route.cngw_route", "strip_path", "false"),
66+
),
67+
},
4868
},
4969
})
5070
}
@@ -137,3 +157,30 @@ resource "tencentcloud_tse_cngw_route" "cngw_route" {
137157
strip_path = true
138158
}
139159
`
160+
161+
const testAccTseCngwRouteUp = DefaultTseVar + `
162+
163+
resource "tencentcloud_tse_cngw_route" "cngw_route" {
164+
destination_ports = []
165+
force_https = false
166+
gateway_id = var.gateway_id
167+
hosts = [
168+
"192.168.0.1:9091",
169+
]
170+
https_redirect_status_code = 301
171+
paths = [
172+
"/user1",
173+
]
174+
headers {
175+
key = "req"
176+
value = "terraform1"
177+
}
178+
preserve_host = true
179+
protocols = [
180+
"http",
181+
]
182+
route_name = "terraform-route"
183+
service_id = "b6017eaf-2363-481e-9e93-8d65aaf498cd"
184+
strip_path = false
185+
}
186+
`

0 commit comments

Comments
 (0)