Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(waf): [] support post_cls_action, post_ckafka_action params #2517

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
7 changes: 7 additions & 0 deletions .changelog/2517.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
```release-note:enhancement
resource/tencentcloud_waf_clb_domain: support param `post_cls_action`, `post_ckafka_action`
```

```release-note:enhancement
resource/tencentcloud_waf_saas_domain: support param `post_cls_action`, `post_ckafka_action`
```
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ require (
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb v1.0.860
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cloudaudit v1.0.544
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls v1.0.860
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.910
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.911
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.624
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cwp v1.0.762
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cynosdb v1.0.692
Expand Down Expand Up @@ -97,7 +97,7 @@ require (
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf v1.0.674
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vod v1.0.860
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc v1.0.845
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/waf v1.0.833
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/waf v1.0.856
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/wedata v1.0.792
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/wss v1.0.199
github.com/tencentyun/cos-go-sdk-v5 v0.7.42-0.20230629101357-7edd77448a0f
Expand Down
20 changes: 6 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -922,10 +922,10 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.857/go.mod
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.859/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.860/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.873/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.888 h1:FqVcZ+POUhckq6ZRlwOR819fsXp49YyizpmWZJYAAGg=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.888/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.910 h1:u+rAnHhLixQaNYy8vtnuClj4kYWs77VAHEbi9jl8k/4=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.910/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.911 h1:dRkofaSMvvyrfi5bUA2RiV05HYMfYd1nFk0Y1L+VMGs=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.911/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/csip v1.0.860 h1:F3esKBIT3HW9+7Gt8cVgf8X06VdGIczpgLBUECzSEzU=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/csip v1.0.860/go.mod h1:NZo1WplQcC314kMlCRUoy8NQju2BnolIJj7NAWgsuhY=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.624 h1:nEZqsoqt1pEoaP9JjkHQy3/H00suCfzlHW1qOm2nYD8=
Expand Down Expand Up @@ -976,8 +976,6 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/mps v1.0.853 h1:abGpWsA
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/mps v1.0.853/go.mod h1:xIprIT+IW+3Fj05GCWmgvxJOhICqFGoW4Ef77cDD2JQ=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/oceanus v1.0.831 h1:oyazF5wgAgoinGo/SDGfUReE3JFxqcpI6/pstWhK7yE=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/oceanus v1.0.831/go.mod h1:2WuTlTnKCnZoa6l0JxY9GNfo0UG6nU7AEsljF8rMMsM=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/organization v1.0.856 h1:W1FLC178fBj5HigbNkAUIBGPPTit20RVycuXQ6u2lSg=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/organization v1.0.856/go.mod h1:Ln9igPci1mCEe4gzekGpMMn/x9im6XlDh2bqvWnUMDo=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/organization v1.0.910 h1:KQJSiP2zV2VP4brIqSGGvx/3uoJ2Y3X5S5RsqjR77Ag=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/organization v1.0.910/go.mod h1:9cT5rPLn6J+M5Gt5eS6NrgJnqsAcQjimu4JMS76UORQ=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/postgres v1.0.873 h1:kqNFHpILFWPbOUAUrH1i6+IfkLWWEAZLYfj9RZ0WM+0=
Expand Down Expand Up @@ -1034,17 +1032,17 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vod v1.0.860 h1:vW2NgAH
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vod v1.0.860/go.mod h1:uCkDh/AW/tb8JGq5b2kqLjqZuhCFR+6oTsq1SrrvT44=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc v1.0.845 h1:c9TSh+kuEwxAuPndCMI7QeERfY/XWkZWRniFI1Gak60=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc v1.0.845/go.mod h1:sz+RI5GLDNIQMKJAR2N93fyxFv/FQo322xq/iAg2Z/g=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/waf v1.0.833 h1:avaBlZ+Qqv7bfMg/u0jlRsbEBbE18CfqKWbfGc84PLg=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/waf v1.0.833/go.mod h1:fUWG217b//46Oa3VXxC5mgeYeewVAbF+lc81uET89EM=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/waf v1.0.856 h1:019LsAoQz76hUYZKXfNLtmmGwp2u4Lx7PFe9Hi8ceiQ=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/waf v1.0.856/go.mod h1:rlVASPNXcnU/AomXIqJd38UPqXRE1Q7RQqjIbErtMbg=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/waf v1.0.911 h1:TJ4OsvE+wjNn9xkdSDmNAEBfOw/Ml1Uzb33d9MIA9NY=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/waf v1.0.911/go.mod h1:emYIGjN30xjVvwReyHv2EuD4qyMiveBJWLynddGJNQ0=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/wedata v1.0.792 h1:NLgKNOIHWa38AmW7dyfI9Jlcp2Kr9VRD94f48pPNmxM=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/wedata v1.0.792/go.mod h1:Xz6vPV3gHlzPwtEcmWdWO1EUXJDgn2p7UMCXbJiVioQ=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/wss v1.0.199 h1:hMBLtiJPnZ9GvA677cTB6ELBR6B68wCR2QY1sNoGQc4=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/wss v1.0.199/go.mod h1:nnY91/H3j/Gu7V/oCA6Zeg8T5D3q36EUdBh4EjmHwqY=
github.com/tencentyun/cos-go-sdk-v5 v0.7.42-0.20230629101357-7edd77448a0f h1:yTMDoBvFuXjZat10d98DIKbPnN9FQG+drt1SbNfMW5U=
github.com/tencentyun/cos-go-sdk-v5 v0.7.42-0.20230629101357-7edd77448a0f/go.mod h1:LUFnaqRmGk6pEHOaRmdn2dCZR2j0cSsM5xowWFPTPao=
github.com/tenntenn/modver v1.0.1 h1:2klLppGhDgzJrScMpkj9Ujy3rXPUspSjAcev9tSEBgA=
github.com/tenntenn/modver v1.0.1/go.mod h1:bePIyQPb7UeioSRkw3Q0XeMhYZSMx9B8ePqg6SAMGH0=
github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3 h1:f+jULpRQGxTSkNYKJ51yaw6ChIqO+Je8UqsTKN/cDag=
github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3/go.mod h1:ON8b8w4BN/kE1EOhwT0o+d62W65a6aPw1nouo9LMgyY=
github.com/tetafro/godot v1.4.11 h1:BVoBIqAf/2QdbFmSwAWnaIqDivZdOV0ZRwEm6jivLKw=
github.com/tetafro/godot v1.4.11/go.mod h1:LR3CJpxDVGlYOWn3ZZg1PgNZdTUvzsZWu8xaEohUpn8=
Expand Down Expand Up @@ -1082,7 +1080,6 @@ github.com/vmihailenco/tagparser v0.1.1 h1:quXMXlA39OCbd2wAdTsGDlK9RkOk6Wuw+x37w
github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI=
github.com/wI2L/jsondiff v0.3.0 h1:iTzQ9u/d86GE9RsBzVHX88f2EA1vQUboHwLhSQFc1s4=
github.com/wI2L/jsondiff v0.3.0/go.mod h1:y1IMzNNjlSsk3IUoJdRJO7VRBtzMvRgyo4Vu0LdHpTc=
github.com/xanzy/ssh-agent v0.3.0 h1:wUMzuKtKilRgBAD1sUb8gOwwRr2FGoBVumcjoOACClI=
github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6eAcqrDh0=
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 h1:QldyIu/L63oPpyvQmHgvgickp1Yw510KJOqX7H24mg8=
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778/go.mod h1:2MuV+tbUrU1zIOPMxZ5EncGwgmMJsa+9ucAQZXxsObs=
Expand Down Expand Up @@ -1121,7 +1118,6 @@ go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0=
go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo=
go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw=
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI=
go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4=
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60=
Expand Down Expand Up @@ -1365,7 +1361,6 @@ golang.org/x/term v0.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA=
golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand Down Expand Up @@ -1573,7 +1568,6 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/cheggaaa/pb.v1 v1.0.27/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
Expand All @@ -1583,7 +1577,6 @@ gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
Expand Down Expand Up @@ -1631,5 +1624,4 @@ sigs.k8s.io/structured-merge-diff/v4 v4.0.2/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK
sigs.k8s.io/structured-merge-diff/v4 v4.1.2/go.mod h1:j/nl6xW8vLS49O8YvXW1ocPhZawJtm+Yrr7PPRQ0Vg4=
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 h1:PRbqxJClWWYMNV1dhaG4NsibJbArud9kFxnAMREiWFE=
sigs.k8s.io/structured-merge-diff/v4 v4.2.3/go.mod h1:qjx8mGObPmV2aSZepjQjbmb2ihdVs8cGKBraizNC69E=
sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q=
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package tco_test

import (
tcacctest "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/acctest"
"testing"

tcacctest "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/acctest"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

Expand Down
20 changes: 20 additions & 0 deletions tencentcloud/services/waf/extension_waf.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,26 @@ var API_SAFE_STATUS = []int{
API_SAFE_STATUS_1,
}

const (
POST_CLS_ACTION_0 = 0
POST_CLS_ACTION_1 = 1
)

var POST_CLS_ACTION = []int{
POST_CLS_ACTION_0,
POST_CLS_ACTION_1,
}

const (
POST_CKAFKA_ACTION_0 = 0
POST_CKAFKA_ACTION_1 = 1
)

var POST_CKAFKA_ACTION = []int{
POST_CKAFKA_ACTION_0,
POST_CKAFKA_ACTION_1,
}

const (
PROTECTION_STATUS_0 = 0
PROTECTION_STATUS_1 = 1
Expand Down
121 changes: 107 additions & 14 deletions tencentcloud/services/waf/resource_tc_waf_clb_domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,20 @@ func ResourceTencentCloudWafClbDomain() *schema.Resource {
ValidateFunc: tccommon.ValidateAllowedStringValue(ALB_TYPES),
Description: "Load balancer type: clb, apisix or tsegw, default clb.",
},
"post_cls_action": {
Type: schema.TypeInt,
Optional: true,
Default: POST_CLS_ACTION_0,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里一定要设置 default 属性吗

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK 这里我去掉

ValidateFunc: tccommon.ValidateAllowedIntValue(POST_CLS_ACTION),
Description: "0-off, 1-on. default is 0.",
},
"post_ckafka_action": {
Type: schema.TypeInt,
Optional: true,
Default: POST_CKAFKA_ACTION_0,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK 这里我去掉

ValidateFunc: tccommon.ValidateAllowedIntValue(POST_CKAFKA_ACTION),
Description: "0-off, 1-on. default is 0.",
},
"ip_headers": {
Type: schema.TypeList,
Optional: true,
Expand All @@ -182,20 +196,22 @@ func resourceTencentCloudWafClbDomainCreate(d *schema.ResourceData, meta interfa
defer tccommon.InconsistentCheck(d, meta)()

var (
logId = tccommon.GetLogId(tccommon.ContextNil)
ctx = context.WithValue(context.TODO(), tccommon.LogIdKey, logId)
service = WafService{client: meta.(tccommon.ProviderMeta).GetAPIV3Conn()}
request = waf.NewCreateHostRequest()
instanceID string
domain string
domainId string
wafStatus uint64
engine uint64
botStatus uint64
apiSafeStatus uint64
clsStatus uint64
isCdn int
albType string
logId = tccommon.GetLogId(tccommon.ContextNil)
ctx = context.WithValue(context.TODO(), tccommon.LogIdKey, logId)
service = WafService{client: meta.(tccommon.ProviderMeta).GetAPIV3Conn()}
request = waf.NewCreateHostRequest()
instanceID string
domain string
domainId string
wafStatus uint64
engine uint64
botStatus uint64
apiSafeStatus uint64
clsStatus uint64
postCLSAction int
postCKafkaAction int
isCdn int
albType string
)

if v, ok := d.GetOk("instance_id"); ok {
Expand Down Expand Up @@ -503,6 +519,38 @@ func resourceTencentCloudWafClbDomainCreate(d *schema.ResourceData, meta interfa
}
}

// set domain post
if v, ok := d.GetOkExists("post_cls_action"); ok {
postCLSAction = v.(int)
}

if v, ok := d.GetOkExists("post_ckafka_action"); ok {
postCKafkaAction = v.(int)
}

if postCLSAction == POST_CLS_ACTION_1 || postCKafkaAction == POST_CKAFKA_ACTION_1 {
modifyDomainPostActionRequest := waf.NewModifyDomainPostActionRequest()
modifyDomainPostActionRequest.Domain = helper.String(domain)
modifyDomainPostActionRequest.PostCLSAction = helper.IntInt64(postCLSAction)
modifyDomainPostActionRequest.PostCKafkaAction = helper.IntInt64(postCKafkaAction)

err = resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseWafClient().ModifyDomainPostAction(modifyDomainPostActionRequest)
if e != nil {
return tccommon.RetryError(e)
} else {
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, modifyDomainPostActionRequest.GetAction(), modifyDomainPostActionRequest.ToJsonString(), result.ToJsonString())
}

return nil
})

if err != nil {
log.Printf("[CRITAL]%s modify waf clbDomain post action failed, reason:%+v", logId, err)
return err
}
}

// set waf status
if v, ok := d.GetOkExists("status"); ok {
tmpWafStatus := v.(int)
Expand Down Expand Up @@ -677,6 +725,14 @@ func resourceTencentCloudWafClbDomainRead(d *schema.ResourceData, meta interface
_ = d.Set("domain_id", domainInfo.DomainId)
}

if domainInfo.PostCLSStatus != nil {
_ = d.Set("post_cls_action", domainInfo.PostCLSStatus)
}

if domainInfo.PostCKafkaStatus != nil {
_ = d.Set("post_ckafka_action", domainInfo.PostCKafkaStatus)
}

clbInfo, err := service.DescribeWafClbDomainById(ctx, instanceID, domain, domainId)
if err != nil {
return err
Expand Down Expand Up @@ -713,6 +769,8 @@ func resourceTencentCloudWafClbDomainUpdate(d *schema.ResourceData, meta interfa
botStatus uint64
apiSafeStatus uint64
clsStatus uint64
postCLSAction int
postCKafkaAction int
)

idSplit := strings.Split(d.Id(), tccommon.FILED_SP)
Expand Down Expand Up @@ -1023,6 +1081,41 @@ func resourceTencentCloudWafClbDomainUpdate(d *schema.ResourceData, meta interfa
}
}

// set domain post
if d.HasChange("post_cls_action") || d.HasChange("post_ckafka_action") {
if v, ok := d.GetOkExists("post_cls_action"); ok {
postCLSAction = v.(int)
}

if v, ok := d.GetOkExists("post_ckafka_action"); ok {
postCKafkaAction = v.(int)
}

if postCLSAction == POST_CLS_ACTION_1 || postCKafkaAction == POST_CKAFKA_ACTION_1 {
modifyDomainPostActionRequest := waf.NewModifyDomainPostActionRequest()
modifyDomainPostActionRequest.Domain = helper.String(domain)
modifyDomainPostActionRequest.PostCLSAction = helper.IntInt64(postCLSAction)
modifyDomainPostActionRequest.PostCKafkaAction = helper.IntInt64(postCKafkaAction)

err = resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseWafClient().ModifyDomainPostAction(modifyDomainPostActionRequest)
if e != nil {
return tccommon.RetryError(e)
} else {
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, modifyDomainPostActionRequest.GetAction(), modifyDomainPostActionRequest.ToJsonString(), result.ToJsonString())
}

return nil
})

if err != nil {
log.Printf("[CRITAL]%s modify waf clbDomain post action failed, reason:%+v", logId, err)
return err
}
}

}

// set waf status
if d.HasChange("status") {
if v, ok := d.GetOkExists("status"); ok {
Expand Down
Loading
Loading