Skip to content

Commit 1a6be80

Browse files
authored
fix(cfw): [121355580] Update CFW resource logic (#3142)
* add * add * add * add * add
1 parent bdf1a3a commit 1a6be80

7 files changed

+77
-17
lines changed

.changelog/3142.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
```release-note:enhancement
2+
resource/tencentcloud_cfw_edge_policy: Update resource fields and code logic
3+
```
4+
5+
```release-note:enhancement
6+
resource/tencentcloud_cfw_nat_policy: Update resource fields and code logic
7+
```

tencentcloud/services/cfw/resource_tc_cfw_edge_policy.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,13 @@ func ResourceTencentCloudCfwEdgePolicy() *schema.Resource {
8888
"scope": {
8989
Type: schema.TypeString,
9090
Optional: true,
91-
Default: POLICY_SCOPE_ALL,
91+
Computed: true,
9292
ValidateFunc: tccommon.ValidateAllowedStringValue(POLICY_SCOPE),
9393
Description: "Effective range. serial: serial; side: bypass; all: global, Default is all.",
9494
},
9595
"param_template_id": {
9696
Type: schema.TypeString,
97+
Optional: true,
9798
Computed: true,
9899
Description: "Parameter template id.",
99100
},
@@ -157,6 +158,10 @@ func resourceTencentCloudCfwEdgePolicyCreate(d *schema.ResourceData, meta interf
157158
createRuleItem.Scope = helper.String(v.(string))
158159
}
159160

161+
if v, ok := d.GetOk("param_template_id"); ok {
162+
createRuleItem.ParamTemplateId = helper.String(v.(string))
163+
}
164+
160165
request.Rules = append(request.Rules, &createRuleItem)
161166

162167
err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
@@ -251,6 +256,10 @@ func resourceTencentCloudCfwEdgePolicyRead(d *schema.ResourceData, meta interfac
251256
_ = d.Set("protocol", edgePolicy.Protocol)
252257
}
253258

259+
if edgePolicy.RuleAction != nil {
260+
_ = d.Set("rule_action", edgePolicy.RuleAction)
261+
}
262+
254263
if edgePolicy.Port != nil {
255264
_ = d.Set("port", edgePolicy.Port)
256265
}
@@ -348,6 +357,10 @@ func resourceTencentCloudCfwEdgePolicyUpdate(d *schema.ResourceData, meta interf
348357
modifyRuleItem.Scope = helper.String(v.(string))
349358
}
350359

360+
if v, ok := d.GetOk("param_template_id"); ok {
361+
modifyRuleItem.ParamTemplateId = helper.String(v.(string))
362+
}
363+
351364
request.Rules = append(request.Rules, &modifyRuleItem)
352365

353366
err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {

tencentcloud/services/cfw/resource_tc_cfw_edge_policy.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Provides a resource to create a cfw edge_policy
1+
Provides a resource to create a CFW edge policy
22

33
Example Usage
44

@@ -38,8 +38,8 @@ resource "tencentcloud_cfw_edge_policy" "example" {
3838

3939
Import
4040

41-
cfw edge_policy can be imported using the id, e.g.
41+
CFW edge policy can be imported using the id, e.g.
4242

4343
```
44-
terraform import tencentcloud_cfw_edge_policy.example edge_policy_id
44+
terraform import tencentcloud_cfw_edge_policy.example 1859582
4545
```

tencentcloud/services/cfw/resource_tc_cfw_nat_policy.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,21 @@ func ResourceTencentCloudCfwNatPolicy() *schema.Resource {
8585
},
8686
"param_template_id": {
8787
Type: schema.TypeString,
88+
Optional: true,
8889
Computed: true,
8990
Description: "Parameter template id. Note: This field may return null, indicating that no valid value can be obtained.",
9091
},
92+
"internal_uuid": {
93+
Type: schema.TypeInt,
94+
Computed: true,
95+
Description: "Internal ID.",
96+
},
97+
"scope": {
98+
Type: schema.TypeString,
99+
Optional: true,
100+
Computed: true,
101+
Description: "Scope of effective rules. ALL: Global effectiveness; ap-guangzhou: Effective territory; cfwnat-xxx: Effectiveness based on instance dimension.",
102+
},
91103
},
92104
}
93105
}
@@ -144,6 +156,14 @@ func resourceTencentCloudCfwNatPolicyCreate(d *schema.ResourceData, meta interfa
144156
createNatRuleItem.Description = helper.String(v.(string))
145157
}
146158

159+
if v, ok := d.GetOk("param_template_id"); ok {
160+
createNatRuleItem.ParamTemplateId = helper.String(v.(string))
161+
}
162+
163+
if v, ok := d.GetOk("scope"); ok {
164+
createNatRuleItem.Scope = helper.String(v.(string))
165+
}
166+
147167
request.Rules = append(request.Rules, &createNatRuleItem)
148168

149169
err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
@@ -212,6 +232,10 @@ func resourceTencentCloudCfwNatPolicyRead(d *schema.ResourceData, meta interface
212232
_ = d.Set("protocol", natPolicy.Protocol)
213233
}
214234

235+
if natPolicy.RuleAction != nil {
236+
_ = d.Set("rule_action", natPolicy.RuleAction)
237+
}
238+
215239
if natPolicy.Port != nil {
216240
_ = d.Set("port", natPolicy.Port)
217241
}
@@ -240,6 +264,10 @@ func resourceTencentCloudCfwNatPolicyRead(d *schema.ResourceData, meta interface
240264
_ = d.Set("param_template_id", natPolicy.ParamTemplateId)
241265
}
242266

267+
if natPolicy.InternalUuid != nil {
268+
_ = d.Set("internal_uuid", natPolicy.InternalUuid)
269+
}
270+
243271
return nil
244272
}
245273

@@ -305,6 +333,14 @@ func resourceTencentCloudCfwNatPolicyUpdate(d *schema.ResourceData, meta interfa
305333
modifyRuleItem.Description = helper.String(v.(string))
306334
}
307335

336+
if v, ok := d.GetOk("param_template_id"); ok {
337+
modifyRuleItem.ParamTemplateId = helper.String(v.(string))
338+
}
339+
340+
if v, ok := d.GetOk("scope"); ok {
341+
modifyRuleItem.Scope = helper.String(v.(string))
342+
}
343+
308344
request.Rules = append(request.Rules, &modifyRuleItem)
309345

310346
err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {

tencentcloud/services/cfw/resource_tc_cfw_nat_policy.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Provides a resource to create a cfw nat_policy
1+
Provides a resource to create a CFW nat policy
22

33
Example Usage
44

@@ -14,13 +14,14 @@ resource "tencentcloud_cfw_nat_policy" "example" {
1414
direction = 1
1515
enable = "true"
1616
description = "policy description."
17+
scope = "ALL"
1718
}
1819
```
1920

2021
Import
2122

22-
cfw nat_policy can be imported using the id, e.g.
23+
CFW nat policy can be imported using the id, e.g.
2324

2425
```
25-
terraform import tencentcloud_cfw_nat_policy.example nat_policy_id
26+
terraform import tencentcloud_cfw_nat_policy.example 134123
2627
```

website/docs/r/cfw_edge_policy.html.markdown

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ layout: "tencentcloud"
44
page_title: "TencentCloud: tencentcloud_cfw_edge_policy"
55
sidebar_current: "docs-tencentcloud-resource-cfw_edge_policy"
66
description: |-
7-
Provides a resource to create a cfw edge_policy
7+
Provides a resource to create a CFW edge policy
88
---
99

1010
# tencentcloud_cfw_edge_policy
1111

12-
Provides a resource to create a cfw edge_policy
12+
Provides a resource to create a CFW edge policy
1313

1414
## Example Usage
1515

@@ -61,22 +61,22 @@ The following arguments are supported:
6161
* `target_type` - (Required, String) Access purpose type: For inbound rules, the type can be net, instance, tag, template, group; for outbound rules, it can be net, location, vendor, template.
6262
* `description` - (Optional, String) Description.
6363
* `enable` - (Optional, String) Rule status, true means enabled, false means disabled. Default is true.
64+
* `param_template_id` - (Optional, String) Parameter template id.
6465
* `scope` - (Optional, String) Effective range. serial: serial; side: bypass; all: global, Default is all.
6566

6667
## Attributes Reference
6768

6869
In addition to all arguments above, the following attributes are exported:
6970

7071
* `id` - ID of the resource.
71-
* `param_template_id` - Parameter template id.
7272
* `uuid` - The unique id corresponding to the rule, no need to fill in when creating the rule.
7373

7474

7575
## Import
7676

77-
cfw edge_policy can be imported using the id, e.g.
77+
CFW edge policy can be imported using the id, e.g.
7878

7979
```
80-
terraform import tencentcloud_cfw_edge_policy.example edge_policy_id
80+
terraform import tencentcloud_cfw_edge_policy.example 1859582
8181
```
8282

website/docs/r/cfw_nat_policy.html.markdown

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ layout: "tencentcloud"
44
page_title: "TencentCloud: tencentcloud_cfw_nat_policy"
55
sidebar_current: "docs-tencentcloud-resource-cfw_nat_policy"
66
description: |-
7-
Provides a resource to create a cfw nat_policy
7+
Provides a resource to create a CFW nat policy
88
---
99

1010
# tencentcloud_cfw_nat_policy
1111

12-
Provides a resource to create a cfw nat_policy
12+
Provides a resource to create a CFW nat policy
1313

1414
## Example Usage
1515

@@ -25,6 +25,7 @@ resource "tencentcloud_cfw_nat_policy" "example" {
2525
direction = 1
2626
enable = "true"
2727
description = "policy description."
28+
scope = "ALL"
2829
}
2930
```
3031

@@ -42,21 +43,23 @@ The following arguments are supported:
4243
* `target_type` - (Required, String) Access purpose type: For inbound rules, the type can be net, instance, tag, template, group; for outbound rules, it can be net, location, vendor, template.
4344
* `description` - (Optional, String) Description.
4445
* `enable` - (Optional, String) Rule status, true means enabled, false means disabled. Default is true.
46+
* `param_template_id` - (Optional, String) Parameter template id. Note: This field may return null, indicating that no valid value can be obtained.
47+
* `scope` - (Optional, String) Scope of effective rules. ALL: Global effectiveness; ap-guangzhou: Effective territory; cfwnat-xxx: Effectiveness based on instance dimension.
4548

4649
## Attributes Reference
4750

4851
In addition to all arguments above, the following attributes are exported:
4952

5053
* `id` - ID of the resource.
51-
* `param_template_id` - Parameter template id. Note: This field may return null, indicating that no valid value can be obtained.
54+
* `internal_uuid` - Internal ID.
5255
* `uuid` - The unique id corresponding to the rule, no need to fill in when creating the rule.
5356

5457

5558
## Import
5659

57-
cfw nat_policy can be imported using the id, e.g.
60+
CFW nat policy can be imported using the id, e.g.
5861

5962
```
60-
terraform import tencentcloud_cfw_nat_policy.example nat_policy_id
63+
terraform import tencentcloud_cfw_nat_policy.example 134123
6164
```
6265

0 commit comments

Comments
 (0)