Here is how I managed to solve this, used ByteMatchStatement
comparing if the host header STARTS_WITH
'{clientname}', hope it helps someone:
{
"Name": "foobar-acl",
"DefaultAction": {
"Allow": {}
},
"Description": "",
"Rules": [
{
"Name": "rate-limit-main",
"Priority": 0,
"Statement": {
"RateBasedStatement": {
"Limit": 3000,
"AggregateKeyType": "IP"
}
},
"Action": {
"Block": {
"CustomResponse": {
"ResponseCode": 429,
"CustomResponseBodyKey": "html_responce"
}
}
},
"VisibilityConfig": {
"SampledRequestsEnabled": false,
"CloudWatchMetricsEnabled": false,
"MetricName": "foobar-rate-limit-main"
}
},
{
"Name": "rate-limit-clientname",
"Priority": 1,
"Statement": {
"RateBasedStatement": {
"Limit": 100,
"AggregateKeyType": "IP",
"ScopeDownStatement": {
"ByteMatchStatement": {
"SearchString": "clientname",
"FieldToMatch": {
"SingleHeader": {
"Name": "host"
}
},
"TextTransformations": [
{
"Priority": 1,
"Type": "NONE"
}
],
"PositionalConstraint": "STARTS_WITH"
}
}
}
},
"Action": {
"Block": {
"CustomResponse": {
"ResponseCode": 409,
"CustomResponseBodyKey": "html_responce"
}
}
},
"VisibilityConfig": {
"SampledRequestsEnabled": false,
"CloudWatchMetricsEnabled": true,
"MetricName": "foobar-clientname"
}
},
{
"Name": "rate-limit-clientname2",
"Priority":21,
"Statement": {
"RateBasedStatement": {
"Limit": 100,
"AggregateKeyType": "IP",
"ScopeDownStatement": {
"ByteMatchStatement": {
"SearchString": "clientname2",
"FieldToMatch": {
"SingleHeader": {
"Name": "host"
}
},
"TextTransformations": [
{
"Priority": 2,
"Type": "NONE"
}
],
"PositionalConstraint": "STARTS_WITH"
}
}
}
},
"Action": {
"Block": {
"CustomResponse": {
"ResponseCode": 409,
"CustomResponseBodyKey": "html_responce"
}
}
},
"VisibilityConfig": {
"SampledRequestsEnabled": false,
"CloudWatchMetricsEnabled": true,
"MetricName": "foobar-clientname2"
}
}
],
"VisibilityConfig": {
"SampledRequestsEnabled": false,
"CloudWatchMetricsEnabled": true,
"MetricName": "foobar-acl"
},
"Capacity": 6,
"ManagedByFirewallManager": false,
"CustomResponseBodies": {
"html_responce": {
"ContentType": "TEXT_HTML",
"Content": "<div>You exceeded the maximum number of requests !</div>"
}
}
}