-
Notifications
You must be signed in to change notification settings - Fork 136
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
SevenEarth
wants to merge
2
commits into
master
Choose a base branch
from
fix/waf
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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` | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
tencentcloud/services/tco/resource_tc_organization_org_manage_policy_config_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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, | ||
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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 同上 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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, | ||
|
@@ -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 { | ||
|
@@ -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) | ||
|
@@ -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 | ||
|
@@ -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) | ||
|
@@ -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 { | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里一定要设置 default 属性吗
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK 这里我去掉