in typescript/waf/waf-cloudfront.ts [19:119]
protected makeRules(listOfRules: listOfRules[] = []) {
var rules: wafv2.CfnRuleGroup.RuleProperty[] = [];
listOfRules.forEach(function (r) {
var mrgsp: wafv2.CfnWebACL.ManagedRuleGroupStatementProperty = {
name: r['name'],
vendorName: "AWS",
excludedRules: []
};
var stateProp: wafv2.CfnWebACL.StatementProperty = {
managedRuleGroupStatement: {
name: r['name'],
vendorName: "AWS",
}
};
var overrideAction: wafv2.CfnWebACL.OverrideActionProperty = { none: {} }
var rule: wafv2.CfnWebACL.RuleProperty = {
name: r['name'],
priority: r['priority'],
overrideAction: overrideAction,
statement: stateProp,
visibilityConfig: {
sampledRequestsEnabled: true,
cloudWatchMetricsEnabled: true,
metricName: r['name']
},
};
rules.push(rule);
}); // forEach
// Allowed country list
var ruleGeoMatch: wafv2.CfnWebACL.RuleProperty = {
name: 'GeoMatch',
priority: 0,
action: {
block: {} // To disable, change to *count*
},
statement: {
notStatement: {
statement: {
geoMatchStatement: {
// block connection if source not in the below country list
countryCodes: [
"AR", // Argentina
"BO", // Bolivia
"BR", // Brazil
"CL", // Chile
"CO", // Colombia
"EC", // Ecuador
"FK", // Falkland Islands
"GF", // French Guiana
"GY", // Guiana
"GY", // Guyana
"PY", // Paraguay
"PE", // Peru
"SR", // Suriname
"UY", // Uruguay
"VE", // Venezuela
]
}
}
}
},
visibilityConfig: {
sampledRequestsEnabled: true,
cloudWatchMetricsEnabled: true,
metricName: 'GeoMatch'
}
}; // GeoMatch
rules.push(ruleGeoMatch);
/**
* The rate limit is the maximum number of requests from a
* single IP address that are allowed in a five-minute period.
* This value is continually evaluated,
* and requests will be blocked once this limit is reached.
* The IP address is automatically unblocked after it falls below the limit.
*/
var ruleLimitRequests100: wafv2.CfnWebACL.RuleProperty = {
name: 'LimitRequests100',
priority: 1,
action: {
block: {} // To disable, change to *count*
},
statement: {
rateBasedStatement: {
limit: 100,
aggregateKeyType: "IP"
}
},
visibilityConfig: {
sampledRequestsEnabled: true,
cloudWatchMetricsEnabled: true,
metricName: 'LimitRequests100'
}
}; // limit requests to 100
rules.push(ruleLimitRequests100);
return rules;
} // function makeRules