File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed
Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff 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
4445var 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}
Original file line number Diff line number Diff 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 ),
You can’t perform that action at this time.
0 commit comments