Skip to content

Commit e99a23c

Browse files
authored
fix: support over_write field (#3620)
1 parent 6a5020d commit e99a23c

File tree

3 files changed

+30
-12
lines changed

3 files changed

+30
-12
lines changed

tencentcloud/services/teo/resource_tc_teo_bind_security_template.go

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// Code generated by iacg; DO NOT EDIT.
21
package teo
32

43
import (
@@ -19,7 +18,6 @@ func ResourceTencentCloudTeoBindSecurityTemplate() *schema.Resource {
1918
return &schema.Resource{
2019
Create: resourceTencentCloudTeoBindSecurityTemplateCreate,
2120
Read: resourceTencentCloudTeoBindSecurityTemplateRead,
22-
Update: resourceTencentCloudTeoBindSecurityTemplateUpdate,
2321
Delete: resourceTencentCloudTeoBindSecurityTemplateDelete,
2422
Importer: &schema.ResourceImporter{
2523
State: schema.ImportStatePassthrough,
@@ -48,11 +46,20 @@ func ResourceTencentCloudTeoBindSecurityTemplate() *schema.Resource {
4846

4947
"operate": {
5048
Type: schema.TypeString,
49+
ForceNew: true,
5150
Optional: true,
5251
Computed: true,
5352
Description: "Unbind operation option. valid values: `unbind-keep-policy`: unbind a domain name from the policy template while retaining the current policy. `unbind-use-default`: unbind a domain name from the policy template and use the default blank policy. default value: `unbind-keep-policy`.",
5453
},
5554

55+
"over_write": {
56+
Type: schema.TypeBool,
57+
ForceNew: true,
58+
Optional: true,
59+
Computed: true,
60+
Description: "If the passed-in domain is already bound to a policy template (including site-level protection policies), setting this parameter indicates whether to replace that template. The default value is true. Supported values are: `true`: Replace the currently bound template for the domain. `false`: Do not replace the currently bound template for the domain. Note: When set to false, if the passed-in domain is already bound to a policy template, the API will return an error; site-level protection policies are also a type of policy template.",
61+
},
62+
5663
"status": {
5764
Type: schema.TypeString,
5865
Computed: true,
@@ -92,7 +99,12 @@ func resourceTencentCloudTeoBindSecurityTemplateCreate(d *schema.ResourceData, m
9299
request.TemplateId = helper.String(v.(string))
93100
}
94101

95-
request.OverWrite = helper.Bool(true)
102+
if v, ok := d.GetOkExists("over_write"); ok {
103+
request.OverWrite = helper.Bool(v.(bool))
104+
} else {
105+
request.OverWrite = helper.Bool(true)
106+
}
107+
96108
request.Operate = helper.String("bind")
97109

98110
reqErr := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
@@ -170,13 +182,13 @@ func resourceTencentCloudTeoBindSecurityTemplateRead(d *schema.ResourceData, met
170182
_ = d.Set("operate", "unbind-keep-policy")
171183
}
172184

173-
return nil
174-
}
175-
func resourceTencentCloudTeoBindSecurityTemplateUpdate(d *schema.ResourceData, meta interface{}) error {
176-
defer tccommon.LogElapsed("resource.tencentcloud_teo_bind_security_template.update")()
177-
defer tccommon.InconsistentCheck(d, meta)()
185+
if v, ok := d.GetOkExists("over_write"); ok {
186+
_ = d.Set("over_write", v.(bool))
187+
} else {
188+
_ = d.Set("over_write", true)
189+
}
178190

179-
return resourceTencentCloudTeoBindSecurityTemplateRead(d, meta)
191+
return nil
180192
}
181193

182194
func resourceTencentCloudTeoBindSecurityTemplateDelete(d *schema.ResourceData, meta interface{}) error {
@@ -206,7 +218,11 @@ func resourceTencentCloudTeoBindSecurityTemplateDelete(d *schema.ResourceData, m
206218
request.Operate = helper.String("unbind-keep-policy")
207219
}
208220

209-
request.OverWrite = helper.Bool(true)
221+
if v, ok := d.GetOkExists("over_write"); ok {
222+
request.OverWrite = helper.Bool(v.(bool))
223+
} else {
224+
request.OverWrite = helper.Bool(true)
225+
}
210226

211227
reqErr := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
212228
result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseTeoV20220901Client().BindSecurityTemplateToEntityWithContext(ctx, request)

tencentcloud/services/teo/resource_tc_teo_bind_security_template_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ resource "tencentcloud_teo_bind_security_template" "teo_bind_security_template"
4343
operate = "unbind-use-default"
4444
template_id = "temp-7dr7dm78"
4545
zone_id = "zone-39quuimqg8r6"
46-
entity = "aaa.makn.cn"
46+
entity = "aaa.makn.cn"
47+
over_write = false
4748
}
4849
4950
`

website/docs/r/teo_bind_security_template.html.markdown

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ The following arguments are supported:
3636

3737
Note: After unbinding, the domain name will use an independent policy and rule quota will be calculated separately. Please make sure there is sufficient rule quota before unbinding.
3838
* `zone_id` - (Required, String, ForceNew) Site ID of the policy template to be bound to or unbound from.
39-
* `operate` - (Optional, String) Unbind operation option. valid values: `unbind-keep-policy`: unbind a domain name from the policy template while retaining the current policy. `unbind-use-default`: unbind a domain name from the policy template and use the default blank policy. default value: `unbind-keep-policy`.
39+
* `operate` - (Optional, String, ForceNew) Unbind operation option. valid values: `unbind-keep-policy`: unbind a domain name from the policy template while retaining the current policy. `unbind-use-default`: unbind a domain name from the policy template and use the default blank policy. default value: `unbind-keep-policy`.
40+
* `over_write` - (Optional, Bool, ForceNew) If the passed-in domain is already bound to a policy template (including site-level protection policies), setting this parameter indicates whether to replace that template. The default value is true. Supported values are: `true`: Replace the currently bound template for the domain. `false`: Do not replace the currently bound template for the domain. Note: When set to false, if the passed-in domain is already bound to a policy template, the API will return an error; site-level protection policies are also a type of policy template.
4041

4142
## Attributes Reference
4243

0 commit comments

Comments
 (0)