Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 26 additions & 10 deletions tencentcloud/services/teo/resource_tc_teo_bind_security_template.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Code generated by iacg; DO NOT EDIT.
package teo

import (
Expand All @@ -19,7 +18,6 @@ func ResourceTencentCloudTeoBindSecurityTemplate() *schema.Resource {
return &schema.Resource{
Create: resourceTencentCloudTeoBindSecurityTemplateCreate,
Read: resourceTencentCloudTeoBindSecurityTemplateRead,
Update: resourceTencentCloudTeoBindSecurityTemplateUpdate,
Delete: resourceTencentCloudTeoBindSecurityTemplateDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
Expand Down Expand Up @@ -48,11 +46,20 @@ func ResourceTencentCloudTeoBindSecurityTemplate() *schema.Resource {

"operate": {
Type: schema.TypeString,
ForceNew: true,
Optional: true,
Computed: true,
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`.",
},

"over_write": {
Type: schema.TypeBool,
ForceNew: true,
Optional: true,
Computed: true,
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.",
},

"status": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -92,7 +99,12 @@ func resourceTencentCloudTeoBindSecurityTemplateCreate(d *schema.ResourceData, m
request.TemplateId = helper.String(v.(string))
}

request.OverWrite = helper.Bool(true)
if v, ok := d.GetOkExists("over_write"); ok {
request.OverWrite = helper.Bool(v.(bool))
} else {
request.OverWrite = helper.Bool(true)
}

request.Operate = helper.String("bind")

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

return nil
}
func resourceTencentCloudTeoBindSecurityTemplateUpdate(d *schema.ResourceData, meta interface{}) error {
defer tccommon.LogElapsed("resource.tencentcloud_teo_bind_security_template.update")()
defer tccommon.InconsistentCheck(d, meta)()
if v, ok := d.GetOkExists("over_write"); ok {
_ = d.Set("over_write", v.(bool))
} else {
_ = d.Set("over_write", true)
}

return resourceTencentCloudTeoBindSecurityTemplateRead(d, meta)
return nil
}

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

request.OverWrite = helper.Bool(true)
if v, ok := d.GetOkExists("over_write"); ok {
request.OverWrite = helper.Bool(v.(bool))
} else {
request.OverWrite = helper.Bool(true)
}

reqErr := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseTeoV20220901Client().BindSecurityTemplateToEntityWithContext(ctx, request)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ resource "tencentcloud_teo_bind_security_template" "teo_bind_security_template"
operate = "unbind-use-default"
template_id = "temp-7dr7dm78"
zone_id = "zone-39quuimqg8r6"
entity = "aaa.makn.cn"
entity = "aaa.makn.cn"
over_write = false
}

`
3 changes: 2 additions & 1 deletion website/docs/r/teo_bind_security_template.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ The following arguments are supported:

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.
* `zone_id` - (Required, String, ForceNew) Site ID of the policy template to be bound to or unbound from.
* `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`.
* `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`.
* `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.

## Attributes Reference

Expand Down
Loading