diff --git a/.changelog/3142.txt b/.changelog/3142.txt new file mode 100644 index 0000000000..baa243986f --- /dev/null +++ b/.changelog/3142.txt @@ -0,0 +1,7 @@ +```release-note:enhancement +resource/tencentcloud_cfw_edge_policy: Update resource fields and code logic +``` + +```release-note:enhancement +resource/tencentcloud_cfw_nat_policy: Update resource fields and code logic +``` \ No newline at end of file diff --git a/tencentcloud/services/cfw/resource_tc_cfw_edge_policy.go b/tencentcloud/services/cfw/resource_tc_cfw_edge_policy.go index 9f76ad94c1..6c6de3e1b6 100644 --- a/tencentcloud/services/cfw/resource_tc_cfw_edge_policy.go +++ b/tencentcloud/services/cfw/resource_tc_cfw_edge_policy.go @@ -88,12 +88,13 @@ func ResourceTencentCloudCfwEdgePolicy() *schema.Resource { "scope": { Type: schema.TypeString, Optional: true, - Default: POLICY_SCOPE_ALL, + Computed: true, ValidateFunc: tccommon.ValidateAllowedStringValue(POLICY_SCOPE), Description: "Effective range. serial: serial; side: bypass; all: global, Default is all.", }, "param_template_id": { Type: schema.TypeString, + Optional: true, Computed: true, Description: "Parameter template id.", }, @@ -157,6 +158,10 @@ func resourceTencentCloudCfwEdgePolicyCreate(d *schema.ResourceData, meta interf createRuleItem.Scope = helper.String(v.(string)) } + if v, ok := d.GetOk("param_template_id"); ok { + createRuleItem.ParamTemplateId = helper.String(v.(string)) + } + request.Rules = append(request.Rules, &createRuleItem) err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError { @@ -251,6 +256,10 @@ func resourceTencentCloudCfwEdgePolicyRead(d *schema.ResourceData, meta interfac _ = d.Set("protocol", edgePolicy.Protocol) } + if edgePolicy.RuleAction != nil { + _ = d.Set("rule_action", edgePolicy.RuleAction) + } + if edgePolicy.Port != nil { _ = d.Set("port", edgePolicy.Port) } @@ -348,6 +357,10 @@ func resourceTencentCloudCfwEdgePolicyUpdate(d *schema.ResourceData, meta interf modifyRuleItem.Scope = helper.String(v.(string)) } + if v, ok := d.GetOk("param_template_id"); ok { + modifyRuleItem.ParamTemplateId = helper.String(v.(string)) + } + request.Rules = append(request.Rules, &modifyRuleItem) err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError { diff --git a/tencentcloud/services/cfw/resource_tc_cfw_edge_policy.md b/tencentcloud/services/cfw/resource_tc_cfw_edge_policy.md index 212f7a96d0..d3238937e7 100644 --- a/tencentcloud/services/cfw/resource_tc_cfw_edge_policy.md +++ b/tencentcloud/services/cfw/resource_tc_cfw_edge_policy.md @@ -1,4 +1,4 @@ -Provides a resource to create a cfw edge_policy +Provides a resource to create a CFW edge policy Example Usage @@ -38,8 +38,8 @@ resource "tencentcloud_cfw_edge_policy" "example" { Import -cfw edge_policy can be imported using the id, e.g. +CFW edge policy can be imported using the id, e.g. ``` -terraform import tencentcloud_cfw_edge_policy.example edge_policy_id +terraform import tencentcloud_cfw_edge_policy.example 1859582 ``` \ No newline at end of file diff --git a/tencentcloud/services/cfw/resource_tc_cfw_nat_policy.go b/tencentcloud/services/cfw/resource_tc_cfw_nat_policy.go index 36ba09d7fc..e6cdbc262e 100644 --- a/tencentcloud/services/cfw/resource_tc_cfw_nat_policy.go +++ b/tencentcloud/services/cfw/resource_tc_cfw_nat_policy.go @@ -85,9 +85,21 @@ func ResourceTencentCloudCfwNatPolicy() *schema.Resource { }, "param_template_id": { Type: schema.TypeString, + Optional: true, Computed: true, Description: "Parameter template id. Note: This field may return null, indicating that no valid value can be obtained.", }, + "internal_uuid": { + Type: schema.TypeInt, + Computed: true, + Description: "Internal ID.", + }, + "scope": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Scope of effective rules. ALL: Global effectiveness; ap-guangzhou: Effective territory; cfwnat-xxx: Effectiveness based on instance dimension.", + }, }, } } @@ -144,6 +156,14 @@ func resourceTencentCloudCfwNatPolicyCreate(d *schema.ResourceData, meta interfa createNatRuleItem.Description = helper.String(v.(string)) } + if v, ok := d.GetOk("param_template_id"); ok { + createNatRuleItem.ParamTemplateId = helper.String(v.(string)) + } + + if v, ok := d.GetOk("scope"); ok { + createNatRuleItem.Scope = helper.String(v.(string)) + } + request.Rules = append(request.Rules, &createNatRuleItem) err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError { @@ -212,6 +232,10 @@ func resourceTencentCloudCfwNatPolicyRead(d *schema.ResourceData, meta interface _ = d.Set("protocol", natPolicy.Protocol) } + if natPolicy.RuleAction != nil { + _ = d.Set("rule_action", natPolicy.RuleAction) + } + if natPolicy.Port != nil { _ = d.Set("port", natPolicy.Port) } @@ -240,6 +264,10 @@ func resourceTencentCloudCfwNatPolicyRead(d *schema.ResourceData, meta interface _ = d.Set("param_template_id", natPolicy.ParamTemplateId) } + if natPolicy.InternalUuid != nil { + _ = d.Set("internal_uuid", natPolicy.InternalUuid) + } + return nil } @@ -305,6 +333,14 @@ func resourceTencentCloudCfwNatPolicyUpdate(d *schema.ResourceData, meta interfa modifyRuleItem.Description = helper.String(v.(string)) } + if v, ok := d.GetOk("param_template_id"); ok { + modifyRuleItem.ParamTemplateId = helper.String(v.(string)) + } + + if v, ok := d.GetOk("scope"); ok { + modifyRuleItem.Scope = helper.String(v.(string)) + } + request.Rules = append(request.Rules, &modifyRuleItem) err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError { diff --git a/tencentcloud/services/cfw/resource_tc_cfw_nat_policy.md b/tencentcloud/services/cfw/resource_tc_cfw_nat_policy.md index f32550a666..630267c93c 100644 --- a/tencentcloud/services/cfw/resource_tc_cfw_nat_policy.md +++ b/tencentcloud/services/cfw/resource_tc_cfw_nat_policy.md @@ -1,4 +1,4 @@ -Provides a resource to create a cfw nat_policy +Provides a resource to create a CFW nat policy Example Usage @@ -14,13 +14,14 @@ resource "tencentcloud_cfw_nat_policy" "example" { direction = 1 enable = "true" description = "policy description." + scope = "ALL" } ``` Import -cfw nat_policy can be imported using the id, e.g. +CFW nat policy can be imported using the id, e.g. ``` -terraform import tencentcloud_cfw_nat_policy.example nat_policy_id +terraform import tencentcloud_cfw_nat_policy.example 134123 ``` \ No newline at end of file diff --git a/website/docs/r/cfw_edge_policy.html.markdown b/website/docs/r/cfw_edge_policy.html.markdown index 3a357bc000..e4e814e821 100644 --- a/website/docs/r/cfw_edge_policy.html.markdown +++ b/website/docs/r/cfw_edge_policy.html.markdown @@ -4,12 +4,12 @@ layout: "tencentcloud" page_title: "TencentCloud: tencentcloud_cfw_edge_policy" sidebar_current: "docs-tencentcloud-resource-cfw_edge_policy" description: |- - Provides a resource to create a cfw edge_policy + Provides a resource to create a CFW edge policy --- # tencentcloud_cfw_edge_policy -Provides a resource to create a cfw edge_policy +Provides a resource to create a CFW edge policy ## Example Usage @@ -61,6 +61,7 @@ The following arguments are supported: * `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. * `description` - (Optional, String) Description. * `enable` - (Optional, String) Rule status, true means enabled, false means disabled. Default is true. +* `param_template_id` - (Optional, String) Parameter template id. * `scope` - (Optional, String) Effective range. serial: serial; side: bypass; all: global, Default is all. ## Attributes Reference @@ -68,15 +69,14 @@ The following arguments are supported: In addition to all arguments above, the following attributes are exported: * `id` - ID of the resource. -* `param_template_id` - Parameter template id. * `uuid` - The unique id corresponding to the rule, no need to fill in when creating the rule. ## Import -cfw edge_policy can be imported using the id, e.g. +CFW edge policy can be imported using the id, e.g. ``` -terraform import tencentcloud_cfw_edge_policy.example edge_policy_id +terraform import tencentcloud_cfw_edge_policy.example 1859582 ``` diff --git a/website/docs/r/cfw_nat_policy.html.markdown b/website/docs/r/cfw_nat_policy.html.markdown index 683ee2dae7..e742cedeb6 100644 --- a/website/docs/r/cfw_nat_policy.html.markdown +++ b/website/docs/r/cfw_nat_policy.html.markdown @@ -4,12 +4,12 @@ layout: "tencentcloud" page_title: "TencentCloud: tencentcloud_cfw_nat_policy" sidebar_current: "docs-tencentcloud-resource-cfw_nat_policy" description: |- - Provides a resource to create a cfw nat_policy + Provides a resource to create a CFW nat policy --- # tencentcloud_cfw_nat_policy -Provides a resource to create a cfw nat_policy +Provides a resource to create a CFW nat policy ## Example Usage @@ -25,6 +25,7 @@ resource "tencentcloud_cfw_nat_policy" "example" { direction = 1 enable = "true" description = "policy description." + scope = "ALL" } ``` @@ -42,21 +43,23 @@ The following arguments are supported: * `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. * `description` - (Optional, String) Description. * `enable` - (Optional, String) Rule status, true means enabled, false means disabled. Default is true. +* `param_template_id` - (Optional, String) Parameter template id. Note: This field may return null, indicating that no valid value can be obtained. +* `scope` - (Optional, String) Scope of effective rules. ALL: Global effectiveness; ap-guangzhou: Effective territory; cfwnat-xxx: Effectiveness based on instance dimension. ## Attributes Reference In addition to all arguments above, the following attributes are exported: * `id` - ID of the resource. -* `param_template_id` - Parameter template id. Note: This field may return null, indicating that no valid value can be obtained. +* `internal_uuid` - Internal ID. * `uuid` - The unique id corresponding to the rule, no need to fill in when creating the rule. ## Import -cfw nat_policy can be imported using the id, e.g. +CFW nat policy can be imported using the id, e.g. ``` -terraform import tencentcloud_cfw_nat_policy.example nat_policy_id +terraform import tencentcloud_cfw_nat_policy.example 134123 ```