Aws-cli: Unable to create a rule group with a Rate based rules in wafv2

Created on 27 Feb 2020  路  3Comments  路  Source: aws/aws-cli

I'm trying to create a rule group using the following command -

aws wafv2 create-rule-group --name RateBasedRuleGroup \
--scope REGIONAL \
--capacity 1500 \
--rules file://rulegroup.json \
--visibility-config SampledRequestsEnabled=true,CloudWatchMetricsEnabled=true,MetricName=SomeNameMetrics \
--region ap-south-1 

It returns the error

An error occurred (WAFInvalidParameterException) when calling the CreateRuleGroup operation: Error reason: A reference in your rule statement is not valid., field: RATE_BASED_STATEMENT, parameter: RateBasedStatement

My rulegroup.json file looks like -

[
    {
        "Name": "RateBasedRule",
        "Priority": 2,
        "Action": {
            "Block": {}
        },
        "Statement": {
            "RateBasedStatement": {
                "Limit": 2000,
                "AggregateKeyType": "IP"
            }
        },
        "VisibilityConfig": {
            "SampledRequestsEnabled": true,
            "CloudWatchMetricsEnabled": true,
            "MetricName": "RateBasedRuleMetric"
        }
    }
]

However when I try to add the rule individually through aws console using the same json, it works like a charm.

service-api wafv2

Most helpful comment

I get this error too. Any solution?

All 3 comments

I get this error too. Any solution?

I can reproduce, and it looks like a problem with the API.

Hi @vologue,

Rate-based rule statements are not allowed in rule groups. This is documented here:

https://docs.aws.amazon.com/waf/latest/developerguide/waf-rule-groups.html

Unfortunately, due to how the API model was written, this statement type is included erroneously, which is then propagated to all AWS SDKs, including documentation. This is a known issue, but no ETA on a resolution is known.

Was this page helpful?
0 / 5 - 0 ratings