Skip to content

Commit ed16d39

Browse files
authored
optimize tem (#1212)
1 parent 39fa4fe commit ed16d39

11 files changed

+325
-86
lines changed

tencentcloud/resource_tc_tem_app_config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,14 @@ func resourceTencentCloudTemAppConfig() *schema.Resource {
5151
"environment_id": {
5252
Type: schema.TypeString,
5353
Required: true,
54+
ForceNew: true,
5455
Description: "environment ID.",
5556
},
5657

5758
"name": {
5859
Type: schema.TypeString,
5960
Required: true,
61+
ForceNew: true,
6062
Description: "appConfig name.",
6163
},
6264

tencentcloud/resource_tc_tem_gateway.go

Lines changed: 32 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ resource "tencentcloud_tem_gateway" "gateway" {
88
ingress {
99
ingress_name = "demo"
1010
environment_id = "en-853mggjm"
11-
cluster_namespace = "default"
12-
address_i_p_version = "IPV4"
11+
address_ip_version = "IPV4"
1312
rewrite_type = "NONE"
1413
mixed = false
1514
rules {
@@ -46,7 +45,7 @@ Import
4645
4746
tem gateway can be imported using the id, e.g.
4847
```
49-
$ terraform import tencentcloud_tem_gateway.gateway gateway_id
48+
$ terraform import tencentcloud_tem_gateway.gateway environmentId#gatewayName
5049
```
5150
*/
5251
package tencentcloud
@@ -83,32 +82,29 @@ func resourceTencentCloudTemGateway() *schema.Resource {
8382
"ingress_name": {
8483
Type: schema.TypeString,
8584
Required: true,
85+
ForceNew: true,
8686
Description: "gateway name.",
8787
},
8888
"environment_id": {
8989
Type: schema.TypeString,
9090
Required: true,
91+
ForceNew: true,
9192
Description: "environment ID.",
9293
},
93-
"cluster_namespace": {
94+
"address_ip_version": {
9495
Type: schema.TypeString,
9596
Required: true,
96-
Description: "inner namespace, default only.",
97-
},
98-
"address_i_p_version": {
99-
Type: schema.TypeString,
100-
Required: true,
101-
Description: "ip version, IPV4 only.",
97+
Description: "ip version, support IPV4.",
10298
},
10399
"rewrite_type": {
104100
Type: schema.TypeString,
105101
Optional: true,
106-
Description: "redirect http to https.",
102+
Description: "redirect mode, support AUTO and NONE.",
107103
},
108104
"mixed": {
109105
Type: schema.TypeBool,
110106
Required: true,
111-
Description: "vpc ID.",
107+
Description: "mixing HTTP and HTTPS.",
112108
},
113109
"tls": {
114110
Type: schema.TypeList,
@@ -229,10 +225,9 @@ func resourceTencentCloudTemGatewayCreate(d *schema.ResourceData, meta interface
229225
logId := getLogId(contextNil)
230226

231227
var (
232-
request = tem.NewModifyIngressRequest()
233-
environmentId string
234-
ingressName string
235-
clusterNamespace string
228+
request = tem.NewModifyIngressRequest()
229+
environmentId string
230+
ingressName string
236231
)
237232

238233
if dMap, ok := helper.InterfacesHeadMap(d, "ingress"); ok {
@@ -245,11 +240,10 @@ func resourceTencentCloudTemGatewayCreate(d *schema.ResourceData, meta interface
245240
environmentId = v.(string)
246241
ingressInfo.EnvironmentId = helper.String(v.(string))
247242
}
248-
if v, ok := dMap["cluster_namespace"]; ok {
249-
clusterNamespace = v.(string)
250-
ingressInfo.ClusterNamespace = helper.String(v.(string))
251-
}
252-
if v, ok := dMap["address_i_p_version"]; ok {
243+
244+
ingressInfo.ClusterNamespace = helper.String("default")
245+
246+
if v, ok := dMap["address_ip_version"]; ok {
253247
ingressInfo.AddressIPVersion = helper.String(v.(string))
254248
}
255249
if v, ok := dMap["rewrite_type"]; ok {
@@ -334,7 +328,7 @@ func resourceTencentCloudTemGatewayCreate(d *schema.ResourceData, meta interface
334328
return err
335329
}
336330

337-
d.SetId(environmentId + FILED_SP + ingressName + FILED_SP + clusterNamespace)
331+
d.SetId(environmentId + FILED_SP + ingressName)
338332

339333
return resourceTencentCloudTemGatewayRead(d, meta)
340334
}
@@ -349,14 +343,13 @@ func resourceTencentCloudTemGatewayRead(d *schema.ResourceData, meta interface{}
349343
service := TemService{client: meta.(*TencentCloudClient).apiV3Conn}
350344

351345
idSplit := strings.Split(d.Id(), FILED_SP)
352-
if len(idSplit) != 3 {
346+
if len(idSplit) != 2 {
353347
return fmt.Errorf("id is broken,%s", d.Id())
354348
}
355349
environmentId := idSplit[0]
356350
ingressName := idSplit[1]
357-
clusterNamespace := idSplit[2]
358351

359-
gateway, err := service.DescribeTemGateway(ctx, environmentId, ingressName, clusterNamespace)
352+
gateway, err := service.DescribeTemGateway(ctx, environmentId, ingressName)
360353

361354
if err != nil {
362355
return err
@@ -374,11 +367,8 @@ func resourceTencentCloudTemGatewayRead(d *schema.ResourceData, meta interface{}
374367
if gateway.EnvironmentId != nil {
375368
ingressMap["environment_id"] = gateway.EnvironmentId
376369
}
377-
if gateway.ClusterNamespace != nil {
378-
ingressMap["cluster_namespace"] = gateway.ClusterNamespace
379-
}
380370
if gateway.AddressIPVersion != nil {
381-
ingressMap["address_i_p_version"] = gateway.AddressIPVersion
371+
ingressMap["address_ip_version"] = gateway.AddressIPVersion
382372
}
383373
if gateway.RewriteType != nil {
384374
ingressMap["rewrite_type"] = gateway.RewriteType
@@ -473,16 +463,18 @@ func resourceTencentCloudTemGatewayUpdate(d *schema.ResourceData, meta interface
473463
if d.HasChange("ingress") {
474464
if dMap, ok := helper.InterfacesHeadMap(d, "ingress"); ok {
475465
ingressInfo := tem.IngressInfo{}
476-
if v, ok := dMap["ingress_name"]; ok {
477-
ingressInfo.IngressName = helper.String(v.(string))
478-
}
479-
if v, ok := dMap["environment_id"]; ok {
480-
ingressInfo.EnvironmentId = helper.String(v.(string))
481-
}
482-
if v, ok := dMap["cluster_namespace"]; ok {
483-
ingressInfo.ClusterNamespace = helper.String(v.(string))
466+
467+
idSplit := strings.Split(d.Id(), FILED_SP)
468+
if len(idSplit) != 2 {
469+
return fmt.Errorf("id is broken,%s", d.Id())
484470
}
485-
if v, ok := dMap["address_i_p_version"]; ok {
471+
environmentId := idSplit[0]
472+
ingressName := idSplit[1]
473+
ingressInfo.IngressName = helper.String(ingressName)
474+
ingressInfo.EnvironmentId = helper.String(environmentId)
475+
ingressInfo.ClusterNamespace = helper.String("default")
476+
477+
if v, ok := dMap["address_ip_version"]; ok {
486478
ingressInfo.AddressIPVersion = helper.String(v.(string))
487479
}
488480
if v, ok := dMap["rewrite_type"]; ok {
@@ -579,14 +571,13 @@ func resourceTencentCloudTemGatewayDelete(d *schema.ResourceData, meta interface
579571

580572
service := TemService{client: meta.(*TencentCloudClient).apiV3Conn}
581573
idSplit := strings.Split(d.Id(), FILED_SP)
582-
if len(idSplit) != 3 {
574+
if len(idSplit) != 2 {
583575
return fmt.Errorf("id is broken,%s", d.Id())
584576
}
585577
environmentId := idSplit[0]
586578
ingressName := idSplit[1]
587-
clusterNamespace := idSplit[2]
588579

589-
if err := service.DeleteTemGatewayById(ctx, environmentId, ingressName, clusterNamespace); err != nil {
580+
if err := service.DeleteTemGatewayById(ctx, environmentId, ingressName); err != nil {
590581
return err
591582
}
592583

tencentcloud/resource_tc_tem_log_config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,21 @@ func resourceTencentCloudTemLogConfig() *schema.Resource {
4949
"environment_id": {
5050
Type: schema.TypeString,
5151
Required: true,
52+
ForceNew: true,
5253
Description: "environment ID.",
5354
},
5455

5556
"application_id": {
5657
Type: schema.TypeString,
5758
Required: true,
59+
ForceNew: true,
5860
Description: "application ID.",
5961
},
6062

6163
"name": {
6264
Type: schema.TypeString,
6365
Required: true,
66+
ForceNew: true,
6467
Description: "appConfig name.",
6568
},
6669

tencentcloud/resource_tc_tem_scale_rule.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,14 @@ func resourceTencentCloudTemScaleRule() *schema.Resource {
7979
"environment_id": {
8080
Type: schema.TypeString,
8181
Required: true,
82+
ForceNew: true,
8283
Description: "environment ID.",
8384
},
8485

8586
"application_id": {
8687
Type: schema.TypeString,
8788
Required: true,
89+
ForceNew: true,
8890
Description: "application ID.",
8991
},
9092

0 commit comments

Comments
 (0)