GeoMatchStatementProperty Struct
A rule statement that labels web requests by country and region and that matches against web requests based on country code.
A geo match rule labels every request that it inspects regardless of whether it finds a match.
- To manage requests only by country, you can use this statement by itself and specify the countries that you want to match against in the
CountryCodesarray. - Otherwise, configure your geo match rule with Count action so that it only labels requests. Then, add one or more label match rules to run after the geo match rule and configure them to match against the geographic labels and handle the requests as needed.
AWS WAF labels requests using the alpha-2 country and region codes from the International Organization for Standardization (ISO) 3166 standard. AWS WAF determines the codes using either the IP address in the web request origin or, if you specify it, the address in the geo match ForwardedIPConfig .
If you use the web request origin, the label formats are awswaf:clientip:geo:region:<ISO country code>-<ISO region code> and awswaf:clientip:geo:country:<ISO country code> .
If you use a forwarded IP address, the label formats are awswaf:forwardedip:geo:region:<ISO country code>-<ISO region code> and awswaf:forwardedip:geo:country:<ISO country code> .
For additional details, see Geographic match rule statement in the AWS WAF Developer Guide .
Example
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_wafv2 as wafv2 } from 'aws-cdk-lib';
const geoMatchStatementProperty: wafv2.CfnWebACL.GeoMatchStatementProperty = {
countryCodes: ['countryCodes'],
forwardedIpConfig: {
fallbackBehavior: 'fallbackBehavior',
headerName: 'headerName',
},
};
Properties
countryCodesoptionalstring[]country_codesoptionaltyping.List[str]countryCodesoptionalList<String>CountryCodesoptionalstring[]CountryCodesoptional*[]*string#notes
When you use a geo match statement just for the region and country labels that it adds to requests, you still have to supply a country code for the rule to evaluate. In this case, you configure the rule to only count matching requests, but it will still generate logging and count metrics for any matches. You can reduce the logging and metrics that the rule produces by specifying a country that's unlikely to be a source of traffic to your site.
forwardedIpConfigoptionalIResolvable | CfnWebACL.ForwardedIPConfigurationPropertyforwarded_ip_configoptionaltyping.Union[IResolvable, ForwardedIPConfigurationProperty]forwardedIpConfigoptionalIResolvableForwardedIpConfigoptionalIResolvableForwardedIpConfigoptionalinterface{}#Commonly, this is the X-Forwarded-For (XFF) header, but you can specify any header name.
If the specified header isn't present in the request, AWS WAF doesn't apply the rule to the web request at all.