Skip to content

Commit e73d699

Browse files
authored
allow to configure rule group capacity (#7)
1 parent 6b86c70 commit e73d699

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

config.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ type AclConfig struct {
3939
AWSProfile string `yaml:"aws_profile"`
4040
IPHeader string `yaml:"ip_header"`
4141
IPHeaderPosition string `yaml:"ip_header_position"`
42+
Capacity int `yaml:"capacity"`
4243
}
4344

4445
var validActions = []string{"ban", "captcha"}
@@ -93,6 +94,12 @@ func getConfigFromEnv(config *bouncerConfig) {
9394
acl.IPHeader = value
9495
case "IP_HEADER_POSITION":
9596
acl.IPHeaderPosition = value
97+
case "CAPACITY":
98+
acl.Capacity, err = strconv.Atoi(value)
99+
if err != nil {
100+
log.Warnf("Invalid value for %s: %s", key, value)
101+
acl.Capacity = 300
102+
}
96103
}
97104
} else {
98105
switch key {
@@ -262,6 +269,10 @@ func newConfig(configPath string) (bouncerConfig, error) {
262269
} else {
263270
ruleGroupNames[c.RuleGroupName] = true
264271
}
272+
273+
if c.Capacity == 0 {
274+
c.Capacity = 300
275+
}
265276
}
266277
return config, nil
267278
}

waf.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func (w *WAF) CreateRuleGroup(ruleGroupName string) error {
116116
},
117117
},
118118
Scope: aws.String(w.config.Scope),
119-
Capacity: aws.Int64(300), //FIXME: update it dynamically
119+
Capacity: aws.Int64(int64(w.config.Capacity)), //FIXME: Automatically set capacity if not provided by the user
120120
VisibilityConfig: &wafv2.VisibilityConfig{
121121
SampledRequestsEnabled: aws.Bool(false),
122122
CloudWatchMetricsEnabled: aws.Bool(false),

0 commit comments

Comments
 (0)