Skip to content

Commit 4db6e2f

Browse files
authored
add throttle cfg for waf (kubernetes-sigs#1505)
1 parent 069ba9b commit 4db6e2f

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

pkg/aws/throttle/defaults.go

+33-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,40 @@
11
package throttle
22

3+
import (
4+
"github.com/aws/aws-sdk-go/service/wafregional"
5+
"github.com/aws/aws-sdk-go/service/wafv2"
6+
"golang.org/x/time/rate"
7+
"regexp"
8+
)
9+
310
// NewDefaultServiceOperationsThrottleConfig returns a ServiceOperationsThrottleConfig with default settings.
411
func NewDefaultServiceOperationsThrottleConfig() *ServiceOperationsThrottleConfig {
512
return &ServiceOperationsThrottleConfig{
6-
value: map[string][]throttleConfig{},
13+
value: map[string][]throttleConfig{
14+
wafregional.ServiceID: {
15+
{
16+
operationPtn: regexp.MustCompile("^AssociateWebACL|DisassociateWebACL"),
17+
r: rate.Limit(0.5),
18+
burst: 1,
19+
},
20+
{
21+
operationPtn: regexp.MustCompile("^GetWebACLForResource|ListResourcesForWebACL"),
22+
r: rate.Limit(1),
23+
burst: 1,
24+
},
25+
},
26+
wafv2.ServiceID: {
27+
{
28+
operationPtn: regexp.MustCompile("^AssociateWebACL|DisassociateWebACL"),
29+
r: rate.Limit(0.5),
30+
burst: 1,
31+
},
32+
{
33+
operationPtn: regexp.MustCompile("^GetWebACLForResource|ListResourcesForWebACL"),
34+
r: rate.Limit(1),
35+
burst: 1,
36+
},
37+
},
38+
},
739
}
840
}

0 commit comments

Comments
 (0)