Rate Limit Args
data class RateLimitArgs(val action: Output<RateLimitActionArgs>? = null, val match: Output<RateLimitMatchArgs>? = null, val period: Output<Double>? = null, val threshold: Output<Double>? = null, val zoneId: Output<String>? = null) : ConvertibleToJava<RateLimitArgs>
cloudflare.RateLimit
is in a deprecation phase until June 15th, 2025. During this time period, this resource is still fully supported but you are strongly advised to move to thecloudflare.Ruleset
resource. Full details can be found in the developer documentation.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as cloudflare from "@pulumi/cloudflare";
const exampleRateLimit = new cloudflare.RateLimit("example_rate_limit", {
zoneId: "023e105f4ecef8ad9ca31a8372d0c353",
action: {
mode: "simulate",
response: {
body: "<error>This request has been rate-limited.</error>",
contentType: "text/xml",
},
timeout: 86400,
},
match: {
headers: [{
name: "Cf-Cache-Status",
op: "eq",
value: "HIT",
}],
request: {
methods: [
"GET",
"POST",
],
schemes: [
"HTTP",
"HTTPS",
],
url: "*.example.org/path*",
},
response: {
originTraffic: true,
},
},
period: 900,
threshold: 60,
});
Content copied to clipboard
import pulumi
import pulumi_cloudflare as cloudflare
example_rate_limit = cloudflare.RateLimit("example_rate_limit",
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
action={
"mode": "simulate",
"response": {
"body": "<error>This request has been rate-limited.</error>",
"content_type": "text/xml",
},
"timeout": 86400,
},
match={
"headers": [{
"name": "Cf-Cache-Status",
"op": "eq",
"value": "HIT",
}],
"request": {
"methods": [
"GET",
"POST",
],
"schemes": [
"HTTP",
"HTTPS",
],
"url": "*.example.org/path*",
},
"response": {
"origin_traffic": True,
},
},
period=900,
threshold=60)
Content copied to clipboard
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Cloudflare = Pulumi.Cloudflare;
return await Deployment.RunAsync(() =>
{
var exampleRateLimit = new Cloudflare.RateLimit("example_rate_limit", new()
{
ZoneId = "023e105f4ecef8ad9ca31a8372d0c353",
Action = new Cloudflare.Inputs.RateLimitActionArgs
{
Mode = "simulate",
Response = new Cloudflare.Inputs.RateLimitActionResponseArgs
{
Body = "<error>This request has been rate-limited.</error>",
ContentType = "text/xml",
},
Timeout = 86400,
},
Match = new Cloudflare.Inputs.RateLimitMatchArgs
{
Headers = new[]
{
new Cloudflare.Inputs.RateLimitMatchHeaderArgs
{
Name = "Cf-Cache-Status",
Op = "eq",
Value = "HIT",
},
},
Request = new Cloudflare.Inputs.RateLimitMatchRequestArgs
{
Methods = new[]
{
"GET",
"POST",
},
Schemes = new[]
{
"HTTP",
"HTTPS",
},
Url = "*.example.org/path*",
},
Response = new Cloudflare.Inputs.RateLimitMatchResponseArgs
{
OriginTraffic = true,
},
},
Period = 900,
Threshold = 60,
});
});
Content copied to clipboard
package main
import (
"github.com/pulumi/pulumi-cloudflare/sdk/v6/go/cloudflare"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := cloudflare.NewRateLimit(ctx, "example_rate_limit", &cloudflare.RateLimitArgs{
ZoneId: pulumi.String("023e105f4ecef8ad9ca31a8372d0c353"),
Action: &cloudflare.RateLimitActionArgs{
Mode: pulumi.String("simulate"),
Response: &cloudflare.RateLimitActionResponseArgs{
Body: pulumi.String("<error>This request has been rate-limited.</error>"),
ContentType: pulumi.String("text/xml"),
},
Timeout: pulumi.Float64(86400),
},
Match: &cloudflare.RateLimitMatchArgs{
Headers: cloudflare.RateLimitMatchHeaderArray{
&cloudflare.RateLimitMatchHeaderArgs{
Name: pulumi.String("Cf-Cache-Status"),
Op: pulumi.String("eq"),
Value: pulumi.String("HIT"),
},
},
Request: &cloudflare.RateLimitMatchRequestArgs{
Methods: pulumi.StringArray{
pulumi.String("GET"),
pulumi.String("POST"),
},
Schemes: pulumi.StringArray{
pulumi.String("HTTP"),
pulumi.String("HTTPS"),
},
Url: pulumi.String("*.example.org/path*"),
},
Response: &cloudflare.RateLimitMatchResponseArgs{
OriginTraffic: pulumi.Bool(true),
},
},
Period: pulumi.Float64(900),
Threshold: pulumi.Float64(60),
})
if err != nil {
return err
}
return nil
})
}
Content copied to clipboard
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.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 exampleRateLimit = new RateLimit("exampleRateLimit", RateLimitArgs.builder()
.zoneId("023e105f4ecef8ad9ca31a8372d0c353")
.action(RateLimitActionArgs.builder()
.mode("simulate")
.response(RateLimitActionResponseArgs.builder()
.body("<error>This request has been rate-limited.</error>")
.contentType("text/xml")
.build())
.timeout(86400.0)
.build())
.match(RateLimitMatchArgs.builder()
.headers(RateLimitMatchHeaderArgs.builder()
.name("Cf-Cache-Status")
.op("eq")
.value("HIT")
.build())
.request(RateLimitMatchRequestArgs.builder()
.methods(
"GET",
"POST")
.schemes(
"HTTP",
"HTTPS")
.url("*.example.org/path*")
.build())
.response(RateLimitMatchResponseArgs.builder()
.originTraffic(true)
.build())
.build())
.period(900.0)
.threshold(60.0)
.build());
}
}
Content copied to clipboard
resources:
exampleRateLimit:
type: cloudflare:RateLimit
name: example_rate_limit
properties:
zoneId: 023e105f4ecef8ad9ca31a8372d0c353
action:
mode: simulate
response:
body: <error>This request has been rate-limited.</error>
contentType: text/xml
timeout: 86400
match:
headers:
- name: Cf-Cache-Status
op: eq
value: HIT
request:
methods:
- GET
- POST
schemes:
- HTTP
- HTTPS
url: '*.example.org/path*'
response:
originTraffic: true
period: 900
threshold: 60
Content copied to clipboard
Import
$ pulumi import cloudflare:index/rateLimit:RateLimit example '<zone_id>/<rate_limit_id>'
Content copied to clipboard
Constructors
Link copied to clipboard
constructor(action: Output<RateLimitActionArgs>? = null, match: Output<RateLimitMatchArgs>? = null, period: Output<Double>? = null, threshold: Output<Double>? = null, zoneId: Output<String>? = null)