@@ -31,19 +31,22 @@ type bouncerConfig struct {
3131}
3232
3333type AclConfig struct {
34- WebACLName string `yaml:"web_acl_name"`
35- RuleGroupName string `yaml:"rule_group_name"`
36- Region string `yaml:"region"`
37- Scope string `yaml:"scope"`
38- IpsetPrefix string `yaml:"ipset_prefix"`
39- FallbackAction string `yaml:"fallback_action"`
40- AWSProfile string `yaml:"aws_profile"`
41- IPHeader string `yaml:"ip_header"`
42- IPHeaderPosition string `yaml:"ip_header_position"`
43- Capacity int `yaml:"capacity"`
34+ WebACLName string `yaml:"web_acl_name"`
35+ RuleGroupName string `yaml:"rule_group_name"`
36+ Region string `yaml:"region"`
37+ Scope string `yaml:"scope"`
38+ IpsetPrefix string `yaml:"ipset_prefix"`
39+ FallbackAction string `yaml:"fallback_action"`
40+ AWSProfile string `yaml:"aws_profile"`
41+ IPHeader string `yaml:"ip_header"`
42+ IPHeaderPosition string `yaml:"ip_header_position"`
43+ Capacity int `yaml:"capacity"`
44+ CloudWatchEnabled bool `yaml:"cloudwatch_enabled"`
45+ CloudWatchMetricName string `yaml:"cloudwatch_metric_name"`
46+ SampleRequests bool `yaml:"sample_requests"`
4447}
4548
46- var validActions = []string {"ban" , "captcha" }
49+ var validActions = []string {"ban" , "captcha" , "count" }
4750var validScopes = []string {"REGIONAL" , "CLOUDFRONT" }
4851var validIpHeaderPosition = []string {"FIRST" , "LAST" , "ANY" }
4952
@@ -101,6 +104,20 @@ func getConfigFromEnv(config *bouncerConfig) {
101104 log .Warnf ("Invalid value for %s: %s" , key , value )
102105 acl .Capacity = 300
103106 }
107+ case "CLOUDWATCH_ENABLED" :
108+ acl .CloudWatchEnabled , err = strconv .ParseBool (value )
109+ if err != nil {
110+ log .Warnf ("Invalid value for %s: %s, defaulting to false" , key , value )
111+ acl .CloudWatchEnabled = false
112+ }
113+ case "CLOUDWATCH_METRIC_NAME" :
114+ acl .CloudWatchMetricName = value
115+ case "SAMPLE_REQUESTS" :
116+ acl .SampleRequests , err = strconv .ParseBool (value )
117+ if err != nil {
118+ log .Warnf ("Invalid value for %s: %s, defaulting to false" , key , value )
119+ acl .SampleRequests = false
120+ }
104121 }
105122 } else {
106123 switch key {
@@ -234,6 +251,10 @@ func newConfig(configPath string) (bouncerConfig, error) {
234251 }
235252 }
236253
254+ if len (config .SupportedActions ) == 0 {
255+ config .SupportedActions = validActions
256+ }
257+
237258 if len (config .WebACLConfig ) == 0 {
238259 return bouncerConfig {}, fmt .Errorf ("waf_config is required" )
239260 }
0 commit comments