Class RateLimit
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
using Pulumi;
using Cloudflare = Pulumi.Cloudflare;
class MyStack : Stack
{
public MyStack()
{
var example = new Cloudflare.RateLimit("example", new Cloudflare.RateLimitArgs
{
ZoneId = @var.Cloudflare_zone_id,
Threshold = 2000,
Period = 2,
Match = new Cloudflare.Inputs.RateLimitMatchArgs
{
Request = new Cloudflare.Inputs.RateLimitMatchRequestArgs
{
UrlPattern = $"{@var.Cloudflare_zone}/*",
Schemes =
{
"HTTP",
"HTTPS",
},
Methods =
{
"GET",
"POST",
"PUT",
"DELETE",
"PATCH",
"HEAD",
},
},
Response = new Cloudflare.Inputs.RateLimitMatchResponseArgs
{
Statuses =
{
200,
201,
202,
301,
429,
},
OriginTraffic = false,
},
},
Action = new Cloudflare.Inputs.RateLimitActionArgs
{
Mode = "simulate",
Timeout = 43200,
Response = new Cloudflare.Inputs.RateLimitActionResponseArgs
{
ContentType = "text/plain",
Body = "custom response body",
},
},
Correlate = new Cloudflare.Inputs.RateLimitCorrelateArgs
{
By = "nat",
},
Disabled = false,
Description = "example rate limit for a zone",
BypassUrlPatterns =
{
$"{@var.Cloudflare_zone}/bypass1",
$"{@var.Cloudflare_zone}/bypass2",
},
});
}
}
Inherited Members
Namespace: Pulumi.Cloudflare
Assembly: Pulumi.Cloudflare.dll
Syntax
public class RateLimit : CustomResource
Constructors
View SourceRateLimit(String, RateLimitArgs, CustomResourceOptions)
Create a RateLimit resource with the given unique name, arguments, and options.
Declaration
public RateLimit(string name, RateLimitArgs args, CustomResourceOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The unique name of the resource |
| RateLimitArgs | args | The arguments used to populate this resource's properties |
| CustomResourceOptions | options | A bag of options that control this resource's behavior |
Properties
View SourceAction
The action to be performed when the threshold of matched traffic within the period defined is exceeded.
Declaration
public Output<RateLimitAction> Action { get; }
Property Value
| Type | Description |
|---|---|
| Output<RateLimitAction> |
BypassUrlPatterns
URLs matching the patterns specified here will be excluded from rate limiting.
Declaration
public Output<ImmutableArray<string>> BypassUrlPatterns { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableArray<System.String>> |
Correlate
Determines how rate limiting is applied. By default if not specified, rate limiting applies to the clients IP address.
Declaration
public Output<RateLimitCorrelate> Correlate { get; }
Property Value
| Type | Description |
|---|---|
| Output<RateLimitCorrelate> |
Description
A note that you can use to describe the reason for a rate limit. This value is sanitized and all tags are removed.
Declaration
public Output<string> Description { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
Disabled
Whether this ratelimit is currently disabled. Default: false.
Declaration
public Output<bool?> Disabled { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Nullable<System.Boolean>> |
Match
Determines which traffic the rate limit counts towards the threshold. By default matches all traffic in the zone. See definition below.
Declaration
public Output<RateLimitMatch> Match { get; }
Property Value
| Type | Description |
|---|---|
| Output<RateLimitMatch> |
Period
The time in seconds to count matching traffic. If the count exceeds threshold within this period the action will be performed (min: 1, max: 86,400).
Declaration
public Output<int> Period { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Int32> |
Threshold
The threshold that triggers the rate limit mitigations, combine with period. i.e. threshold per period (min: 2, max: 1,000,000).
Declaration
public Output<int> Threshold { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Int32> |
ZoneId
The DNS zone ID to apply rate limiting to.
Declaration
public Output<string> ZoneId { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
Methods
View SourceGet(String, Input<String>, RateLimitState, CustomResourceOptions)
Get an existing RateLimit resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
Declaration
public static RateLimit Get(string name, Input<string> id, RateLimitState state = null, CustomResourceOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The unique name of the resulting resource. |
| Input<System.String> | id | The unique provider ID of the resource to lookup. |
| RateLimitState | state | Any extra arguments used during the lookup. |
| CustomResourceOptions | options | A bag of options that control this resource's behavior |
Returns
| Type | Description |
|---|---|
| RateLimit |