Rate Limit
Provides a Cloudflare rate limit resource for a given zone. This can be used to limit the traffic you receive zone-wide, or matching more specific types of requests/responses.
Example Usage
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.cloudflare.RateLimit;
import com.pulumi.cloudflare.RateLimitArgs;
import com.pulumi.cloudflare.inputs.RateLimitActionArgs;
import com.pulumi.cloudflare.inputs.RateLimitActionResponseArgs;
import com.pulumi.cloudflare.inputs.RateLimitCorrelateArgs;
import com.pulumi.cloudflare.inputs.RateLimitMatchArgs;
import com.pulumi.cloudflare.inputs.RateLimitMatchRequestArgs;
import com.pulumi.cloudflare.inputs.RateLimitMatchResponseArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var example = new RateLimit("example", RateLimitArgs.builder()
.action(RateLimitActionArgs.builder()
.mode("simulate")
.response(RateLimitActionResponseArgs.builder()
.body("custom response body")
.contentType("text/plain")
.build())
.timeout(43200)
.build())
.bypassUrlPatterns(
"example.com/bypass1",
"example.com/bypass2")
.correlate(RateLimitCorrelateArgs.builder()
.by("nat")
.build())
.description("example rate limit for a zone")
.disabled(false)
.match(RateLimitMatchArgs.builder()
.request(RateLimitMatchRequestArgs.builder()
.methods(
"GET",
"POST",
"PUT",
"DELETE",
"PATCH",
"HEAD")
.schemes(
"HTTP",
"HTTPS")
.urlPattern(String.format("%s/*", var_.cloudflare_zone()))
.build())
.response(RateLimitMatchResponseArgs.builder()
.headers(
Map.ofEntries(
Map.entry("name", "Host"),
Map.entry("op", "eq"),
Map.entry("value", "localhost")
),
Map.ofEntries(
Map.entry("name", "X-Example"),
Map.entry("op", "ne"),
Map.entry("value", "my-example")
))
.originTraffic(false)
.statuses(
200,
201,
202,
301,
429)
.build())
.build())
.period(2)
.threshold(2000)
.zoneId("0da42c8d2132a9ddaf714f9e7c920711")
.build());
}
}
Content copied to clipboard
Import
$ pulumi import cloudflare:index/rateLimit:RateLimit example <zone_id>/<rate_limit_id>
Content copied to clipboard
*/
Properties
Link copied to clipboard
The action to be performed when the threshold of matched traffic within the period defined is exceeded.
Link copied to clipboard
Link copied to clipboard
Determines how rate limiting is applied. By default if not specified, rate limiting applies to the clients IP address.
Link copied to clipboard
A note that you can use to describe the reason for a rate limit. This value is sanitized and all tags are removed.
Link copied to clipboard
Determines which traffic the rate limit counts towards the threshold. By default matches all traffic in the zone.
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard