Skip to content

Commit c2d4079

Browse files
authored
feat(teo): [124357710]support teo_bind_security_template (#3393)
* feat(teo): [124357710]support teo_bind_security_template * feat(teo): [124357710]support teo_bind_security_template * fix: add changelog * fix: update bind security_template
1 parent 9382141 commit c2d4079

10 files changed

+436
-0
lines changed

.changelog/3393.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:new-resource
2+
tencentcloud_teo_bind_security_template
3+
```

tencentcloud/provider.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1873,6 +1873,7 @@ func Provider() *schema.Provider {
18731873
"tencentcloud_teo_function_runtime_environment": teo.ResourceTencentCloudTeoFunctionRuntimeEnvironment(),
18741874
"tencentcloud_teo_security_policy_config": teo.ResourceTencentCloudTeoSecurityPolicyConfig(),
18751875
"tencentcloud_teo_dns_record": teo.ResourceTencentCloudTeoDnsRecord(),
1876+
"tencentcloud_teo_bind_security_template": teo.ResourceTencentCloudTeoBindSecurityTemplate(),
18761877
"tencentcloud_tcm_mesh": tcm.ResourceTencentCloudTcmMesh(),
18771878
"tencentcloud_tcm_cluster_attachment": tcm.ResourceTencentCloudTcmClusterAttachment(),
18781879
"tencentcloud_tcm_prometheus_attachment": tcm.ResourceTencentCloudTcmPrometheusAttachment(),

tencentcloud/provider.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,6 +1512,7 @@ tencentcloud_teo_l7_acc_setting
15121512
tencentcloud_teo_security_ip_group
15131513
tencentcloud_teo_security_policy_config
15141514
tencentcloud_teo_dns_record
1515+
tencentcloud_teo_bind_security_template
15151516

15161517
TencentCloud ServiceMesh(TCM)
15171518
Data Source

tencentcloud/services/teo/resource_tc_teo_bind_security_template.go

Lines changed: 226 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Provides a resource to create a teo bind_security_template
2+
3+
~> **NOTE:** If the domain name you input has been bound to a policy template (including site-level protection policies), the default value is to replace the template currently bound to the domain name.
4+
~> **NOTE:** The current resource can only bind/unbind the template and domain name belonging to the same site.
5+
6+
Example Usage
7+
8+
```hcl
9+
resource "tencentcloud_teo_bind_security_template" "teo_bind_security_template" {
10+
operate = "unbind-use-default"
11+
template_id = "temp-7dr7dm78"
12+
zone_id = "zone-39quuimqg8r6"
13+
entity = "aaa.makn.cn"
14+
}
15+
16+
```
17+
Import
18+
19+
teo application_proxy_rule can be imported using the zoneId#templateId#entity, e.g.
20+
```
21+
terraform import tencentcloud_teo_bind_security_template.teo_bind_security_template zone-39quuimqg8r6#temp-7dr7dm78#aaa.makn.cn
22+
```
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package teo
2+
3+
import (
4+
"context"
5+
"fmt"
6+
7+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
8+
teov20220901 "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/teo/v20220901"
9+
tccommon "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/common"
10+
)
11+
12+
func resourceTeoBindSecurityTemplateCreateStateRefreshFunc_0_0(ctx context.Context, zoneId string, templateId string, entity string) resource.StateRefreshFunc {
13+
var req *teov20220901.DescribeSecurityTemplateBindingsRequest
14+
return func() (interface{}, string, error) {
15+
meta := tccommon.ProviderMetaFromContext(ctx)
16+
17+
service := TeoService{client: meta.(tccommon.ProviderMeta).GetAPIV3Conn()}
18+
if meta == nil {
19+
return nil, "", fmt.Errorf("resource data can not be nil")
20+
}
21+
if req == nil {
22+
d := tccommon.ResourceDataFromContext(ctx)
23+
if d == nil {
24+
return nil, "", fmt.Errorf("resource data can not be nil")
25+
}
26+
_ = d
27+
req = teov20220901.NewDescribeSecurityTemplateBindingsRequest()
28+
}
29+
resp, err := service.DescribeTeoBindSecurityTemplateById(ctx, zoneId, templateId, entity)
30+
if err != nil {
31+
return nil, "", err
32+
}
33+
if resp == nil {
34+
return nil, "", nil
35+
}
36+
return resp, *resp.Status, nil
37+
}
38+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package teo_test
2+
3+
import (
4+
"testing"
5+
6+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
7+
tcacctest "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/acctest"
8+
)
9+
10+
func TestAccTencentCloudTeoBindSecurityTemplateResource_basic(t *testing.T) {
11+
t.Parallel()
12+
resource.Test(t, resource.TestCase{
13+
PreCheck: func() {
14+
tcacctest.AccPreCheck(t)
15+
},
16+
Providers: tcacctest.AccProviders,
17+
Steps: []resource.TestStep{
18+
{
19+
Config: testAccTeoBindSecurityTemplate,
20+
Check: resource.ComposeTestCheckFunc(
21+
resource.TestCheckResourceAttr("tencentcloud_teo_bind_security_template.teo_bind_security_template", "zone_id", "zone-39quuimqg8r6"),
22+
resource.TestCheckResourceAttr("tencentcloud_teo_bind_security_template.teo_bind_security_template", "template_id", "temp-7dr7dm78"),
23+
resource.TestCheckResourceAttr("tencentcloud_teo_bind_security_template.teo_bind_security_template", "entity", "aaa.makn.cn"),
24+
resource.TestCheckResourceAttr("tencentcloud_teo_bind_security_template.teo_bind_security_template", "operate", "unbind-use-default"),
25+
resource.TestCheckResourceAttr("tencentcloud_teo_bind_security_template.teo_bind_security_template", "status", "online"),
26+
),
27+
},
28+
{
29+
ResourceName: "tencentcloud_teo_bind_security_template.teo_bind_security_template",
30+
ImportState: true,
31+
ImportStateVerify: true,
32+
ImportStateVerifyIgnore: []string{
33+
"operate",
34+
},
35+
},
36+
},
37+
})
38+
}
39+
40+
const testAccTeoBindSecurityTemplate = `
41+
42+
resource "tencentcloud_teo_bind_security_template" "teo_bind_security_template" {
43+
operate = "unbind-use-default"
44+
template_id = "temp-7dr7dm78"
45+
zone_id = "zone-39quuimqg8r6"
46+
entity = "aaa.makn.cn"
47+
}
48+
49+
`

0 commit comments

Comments
 (0)