1. Packages
  2. Kafka Provider
  3. API Docs
  4. Quota
Kafka v3.11.1 published on Tuesday, Jul 29, 2025 by Pulumi

kafka.Quota

Explore with Pulumi AI

kafka logo
Kafka v3.11.1 published on Tuesday, Jul 29, 2025 by Pulumi

    The kafka.Quota resource manages Kafka quotas, which are used to limit resource usage and prevent any single client from monopolizing broker resources. Quotas can be applied to clients, users, or IP addresses to control bandwidth and request rates.

    Example Usage

    Client ID Quota

    import * as pulumi from "@pulumi/pulumi";
    import * as kafka from "@pulumi/kafka";
    
    // Limit a specific client's bandwidth
    const mobileApp = new kafka.Quota("mobile_app", {
        entityName: "mobile-app-v1",
        entityType: "client-id",
        config: {
            consumer_byte_rate: "5000000",
            producer_byte_rate: "2500000",
            request_percentage: "200",
        },
    });
    
    import pulumi
    import pulumi_kafka as kafka
    
    # Limit a specific client's bandwidth
    mobile_app = kafka.Quota("mobile_app",
        entity_name="mobile-app-v1",
        entity_type="client-id",
        config={
            "consumer_byte_rate": "5000000",
            "producer_byte_rate": "2500000",
            "request_percentage": "200",
        })
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-kafka/sdk/v3/go/kafka"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		// Limit a specific client's bandwidth
    		_, err := kafka.NewQuota(ctx, "mobile_app", &kafka.QuotaArgs{
    			EntityName: pulumi.String("mobile-app-v1"),
    			EntityType: pulumi.String("client-id"),
    			Config: pulumi.StringMap{
    				"consumer_byte_rate": pulumi.String("5000000"),
    				"producer_byte_rate": pulumi.String("2500000"),
    				"request_percentage": pulumi.String("200"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Kafka = Pulumi.Kafka;
    
    return await Deployment.RunAsync(() => 
    {
        // Limit a specific client's bandwidth
        var mobileApp = new Kafka.Quota("mobile_app", new()
        {
            EntityName = "mobile-app-v1",
            EntityType = "client-id",
            Config = 
            {
                { "consumer_byte_rate", "5000000" },
                { "producer_byte_rate", "2500000" },
                { "request_percentage", "200" },
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.kafka.Quota;
    import com.pulumi.kafka.QuotaArgs;
    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) {
            // Limit a specific client's bandwidth
            var mobileApp = new Quota("mobileApp", QuotaArgs.builder()
                .entityName("mobile-app-v1")
                .entityType("client-id")
                .config(Map.ofEntries(
                    Map.entry("consumer_byte_rate", "5000000"),
                    Map.entry("producer_byte_rate", "2500000"),
                    Map.entry("request_percentage", "200")
                ))
                .build());
    
        }
    }
    
    resources:
      # Limit a specific client's bandwidth
      mobileApp:
        type: kafka:Quota
        name: mobile_app
        properties:
          entityName: mobile-app-v1
          entityType: client-id
          config:
            consumer_byte_rate: '5000000'
            producer_byte_rate: '2500000'
            request_percentage: '200'
    

    User Quota

    import * as pulumi from "@pulumi/pulumi";
    import * as kafka from "@pulumi/kafka";
    
    // Set quotas for a specific user
    const serviceAccount = new kafka.Quota("service_account", {
        entityName: "payment-service",
        entityType: "user",
        config: {
            consumer_byte_rate: "10000000",
            producer_byte_rate: "10000000",
            request_percentage: "400",
        },
    });
    
    import pulumi
    import pulumi_kafka as kafka
    
    # Set quotas for a specific user
    service_account = kafka.Quota("service_account",
        entity_name="payment-service",
        entity_type="user",
        config={
            "consumer_byte_rate": "10000000",
            "producer_byte_rate": "10000000",
            "request_percentage": "400",
        })
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-kafka/sdk/v3/go/kafka"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		// Set quotas for a specific user
    		_, err := kafka.NewQuota(ctx, "service_account", &kafka.QuotaArgs{
    			EntityName: pulumi.String("payment-service"),
    			EntityType: pulumi.String("user"),
    			Config: pulumi.StringMap{
    				"consumer_byte_rate": pulumi.String("10000000"),
    				"producer_byte_rate": pulumi.String("10000000"),
    				"request_percentage": pulumi.String("400"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Kafka = Pulumi.Kafka;
    
    return await Deployment.RunAsync(() => 
    {
        // Set quotas for a specific user
        var serviceAccount = new Kafka.Quota("service_account", new()
        {
            EntityName = "payment-service",
            EntityType = "user",
            Config = 
            {
                { "consumer_byte_rate", "10000000" },
                { "producer_byte_rate", "10000000" },
                { "request_percentage", "400" },
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.kafka.Quota;
    import com.pulumi.kafka.QuotaArgs;
    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) {
            // Set quotas for a specific user
            var serviceAccount = new Quota("serviceAccount", QuotaArgs.builder()
                .entityName("payment-service")
                .entityType("user")
                .config(Map.ofEntries(
                    Map.entry("consumer_byte_rate", "10000000"),
                    Map.entry("producer_byte_rate", "10000000"),
                    Map.entry("request_percentage", "400")
                ))
                .build());
    
        }
    }
    
    resources:
      # Set quotas for a specific user
      serviceAccount:
        type: kafka:Quota
        name: service_account
        properties:
          entityName: payment-service
          entityType: user
          config:
            consumer_byte_rate: '10000000'
            producer_byte_rate: '10000000'
            request_percentage: '400'
    

    Default User Quota

    import * as pulumi from "@pulumi/pulumi";
    import * as kafka from "@pulumi/kafka";
    
    // Set default quotas for all users (when entity_name is omitted)
    const defaultUser = new kafka.Quota("default_user", {
        entityType: "user",
        config: {
            consumer_byte_rate: "2000000",
            producer_byte_rate: "1000000",
            request_percentage: "100",
        },
    });
    
    import pulumi
    import pulumi_kafka as kafka
    
    # Set default quotas for all users (when entity_name is omitted)
    default_user = kafka.Quota("default_user",
        entity_type="user",
        config={
            "consumer_byte_rate": "2000000",
            "producer_byte_rate": "1000000",
            "request_percentage": "100",
        })
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-kafka/sdk/v3/go/kafka"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		// Set default quotas for all users (when entity_name is omitted)
    		_, err := kafka.NewQuota(ctx, "default_user", &kafka.QuotaArgs{
    			EntityType: pulumi.String("user"),
    			Config: pulumi.StringMap{
    				"consumer_byte_rate": pulumi.String("2000000"),
    				"producer_byte_rate": pulumi.String("1000000"),
    				"request_percentage": pulumi.String("100"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Kafka = Pulumi.Kafka;
    
    return await Deployment.RunAsync(() => 
    {
        // Set default quotas for all users (when entity_name is omitted)
        var defaultUser = new Kafka.Quota("default_user", new()
        {
            EntityType = "user",
            Config = 
            {
                { "consumer_byte_rate", "2000000" },
                { "producer_byte_rate", "1000000" },
                { "request_percentage", "100" },
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.kafka.Quota;
    import com.pulumi.kafka.QuotaArgs;
    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) {
            // Set default quotas for all users (when entity_name is omitted)
            var defaultUser = new Quota("defaultUser", QuotaArgs.builder()
                .entityType("user")
                .config(Map.ofEntries(
                    Map.entry("consumer_byte_rate", "2000000"),
                    Map.entry("producer_byte_rate", "1000000"),
                    Map.entry("request_percentage", "100")
                ))
                .build());
    
        }
    }
    
    resources:
      # Set default quotas for all users (when entity_name is omitted)
      defaultUser:
        type: kafka:Quota
        name: default_user
        properties:
          entityType: user
          config:
            consumer_byte_rate: '2000000'
            producer_byte_rate: '1000000'
            request_percentage: '100'
    

    IP Address Quota

    import * as pulumi from "@pulumi/pulumi";
    import * as kafka from "@pulumi/kafka";
    
    // Rate limit connections from a specific IP
    const externalIp = new kafka.Quota("external_ip", {
        entityName: "203.0.113.0",
        entityType: "ip",
        config: {
            connection_creation_rate: "10",
        },
    });
    
    import pulumi
    import pulumi_kafka as kafka
    
    # Rate limit connections from a specific IP
    external_ip = kafka.Quota("external_ip",
        entity_name="203.0.113.0",
        entity_type="ip",
        config={
            "connection_creation_rate": "10",
        })
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-kafka/sdk/v3/go/kafka"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		// Rate limit connections from a specific IP
    		_, err := kafka.NewQuota(ctx, "external_ip", &kafka.QuotaArgs{
    			EntityName: pulumi.String("203.0.113.0"),
    			EntityType: pulumi.String("ip"),
    			Config: pulumi.StringMap{
    				"connection_creation_rate": pulumi.String("10"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Kafka = Pulumi.Kafka;
    
    return await Deployment.RunAsync(() => 
    {
        // Rate limit connections from a specific IP
        var externalIp = new Kafka.Quota("external_ip", new()
        {
            EntityName = "203.0.113.0",
            EntityType = "ip",
            Config = 
            {
                { "connection_creation_rate", "10" },
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.kafka.Quota;
    import com.pulumi.kafka.QuotaArgs;
    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) {
            // Rate limit connections from a specific IP
            var externalIp = new Quota("externalIp", QuotaArgs.builder()
                .entityName("203.0.113.0")
                .entityType("ip")
                .config(Map.of("connection_creation_rate", "10"))
                .build());
    
        }
    }
    
    resources:
      # Rate limit connections from a specific IP
      externalIp:
        type: kafka:Quota
        name: external_ip
        properties:
          entityName: 203.0.113.0
          entityType: ip
          config:
            connection_creation_rate: '10'
    

    Quota Configuration Options

    Bandwidth Quotas

    • producer_byte_rate - The maximum bytes per second that can be produced by the entity
    • consumer_byte_rate - The maximum bytes per second that can be consumed by the entity

    Request Rate Quotas

    • request_percentage - The percentage of CPU time on each broker that the entity can use for requests. Values > 100% indicate multiple CPUs (e.g., 200% = 2 CPUs)

    Connection Quotas (IP-based only)

    • connection_creation_rate - The maximum rate of new connections per second from the IP address

    Quota Precedence

    When multiple quotas apply to a request, Kafka uses the most specific quota:

    1. /config/users/<user>/clients/<client-id> (most specific)
    2. /config/users/<user>/clients/<default>
    3. /config/users/<user>
    4. /config/users/<default>/clients/<client-id>
    5. /config/users/<default>/clients/<default>
    6. /config/users/<default> (least specific)

    Best Practices

    1. Start with Conservative Defaults: Set reasonable default quotas for all users/clients and then create specific quotas for services that need higher limits.

    2. Monitor Quota Usage: Use Kafka metrics to monitor quota utilization and adjust as needed. Look for throttling metrics to identify when quotas are being hit.

    3. Use Request Percentage Carefully: The request_percentage quota affects CPU usage. Values over 100% mean the client can use more than one CPU core.

    4. Plan for Growth: Set quotas with some headroom to accommodate traffic growth, but not so high that a misbehaving client can impact the cluster.

    5. Different Quotas for Different Environments: Use stricter quotas in development/staging environments compared to production.

    Note: Quotas are applied immediately but may take a few seconds to propagate across all brokers.

    Create Quota Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new Quota(name: string, args: QuotaArgs, opts?: CustomResourceOptions);
    @overload
    def Quota(resource_name: str,
              args: QuotaArgs,
              opts: Optional[ResourceOptions] = None)
    
    @overload
    def Quota(resource_name: str,
              opts: Optional[ResourceOptions] = None,
              entity_type: Optional[str] = None,
              config: Optional[Mapping[str, str]] = None,
              entity_name: Optional[str] = None)
    func NewQuota(ctx *Context, name string, args QuotaArgs, opts ...ResourceOption) (*Quota, error)
    public Quota(string name, QuotaArgs args, CustomResourceOptions? opts = null)
    public Quota(String name, QuotaArgs args)
    public Quota(String name, QuotaArgs args, CustomResourceOptions options)
    
    type: kafka:Quota
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args QuotaArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args QuotaArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args QuotaArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args QuotaArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args QuotaArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Constructor example

    The following reference example uses placeholder values for all input properties.

    var quotaResource = new Kafka.Quota("quotaResource", new()
    {
        EntityType = "string",
        Config = 
        {
            { "string", "string" },
        },
        EntityName = "string",
    });
    
    example, err := kafka.NewQuota(ctx, "quotaResource", &kafka.QuotaArgs{
    	EntityType: pulumi.String("string"),
    	Config: pulumi.StringMap{
    		"string": pulumi.String("string"),
    	},
    	EntityName: pulumi.String("string"),
    })
    
    var quotaResource = new Quota("quotaResource", QuotaArgs.builder()
        .entityType("string")
        .config(Map.of("string", "string"))
        .entityName("string")
        .build());
    
    quota_resource = kafka.Quota("quotaResource",
        entity_type="string",
        config={
            "string": "string",
        },
        entity_name="string")
    
    const quotaResource = new kafka.Quota("quotaResource", {
        entityType: "string",
        config: {
            string: "string",
        },
        entityName: "string",
    });
    
    type: kafka:Quota
    properties:
        config:
            string: string
        entityName: string
        entityType: string
    

    Quota Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

    The Quota resource accepts the following input properties:

    EntityType string
    The type of the entity (client-id, user, ip)
    Config Dictionary<string, string>
    A map of string k/v properties.
    EntityName string
    The name of the entity (if entity_name is not provided, it will create entity-default Kafka quota)
    EntityType string
    The type of the entity (client-id, user, ip)
    Config map[string]string
    A map of string k/v properties.
    EntityName string
    The name of the entity (if entity_name is not provided, it will create entity-default Kafka quota)
    entityType String
    The type of the entity (client-id, user, ip)
    config Map<String,String>
    A map of string k/v properties.
    entityName String
    The name of the entity (if entity_name is not provided, it will create entity-default Kafka quota)
    entityType string
    The type of the entity (client-id, user, ip)
    config {[key: string]: string}
    A map of string k/v properties.
    entityName string
    The name of the entity (if entity_name is not provided, it will create entity-default Kafka quota)
    entity_type str
    The type of the entity (client-id, user, ip)
    config Mapping[str, str]
    A map of string k/v properties.
    entity_name str
    The name of the entity (if entity_name is not provided, it will create entity-default Kafka quota)
    entityType String
    The type of the entity (client-id, user, ip)
    config Map<String>
    A map of string k/v properties.
    entityName String
    The name of the entity (if entity_name is not provided, it will create entity-default Kafka quota)

    Outputs

    All input properties are implicitly available as output properties. Additionally, the Quota resource produces the following output properties:

    Id string
    The provider-assigned unique ID for this managed resource.
    Id string
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.
    id string
    The provider-assigned unique ID for this managed resource.
    id str
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.

    Look up Existing Quota Resource

    Get an existing Quota resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

    public static get(name: string, id: Input<ID>, state?: QuotaState, opts?: CustomResourceOptions): Quota
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            config: Optional[Mapping[str, str]] = None,
            entity_name: Optional[str] = None,
            entity_type: Optional[str] = None) -> Quota
    func GetQuota(ctx *Context, name string, id IDInput, state *QuotaState, opts ...ResourceOption) (*Quota, error)
    public static Quota Get(string name, Input<string> id, QuotaState? state, CustomResourceOptions? opts = null)
    public static Quota get(String name, Output<String> id, QuotaState state, CustomResourceOptions options)
    resources:  _:    type: kafka:Quota    get:      id: ${id}
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    resource_name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    The following state arguments are supported:
    Config Dictionary<string, string>
    A map of string k/v properties.
    EntityName string
    The name of the entity (if entity_name is not provided, it will create entity-default Kafka quota)
    EntityType string
    The type of the entity (client-id, user, ip)
    Config map[string]string
    A map of string k/v properties.
    EntityName string
    The name of the entity (if entity_name is not provided, it will create entity-default Kafka quota)
    EntityType string
    The type of the entity (client-id, user, ip)
    config Map<String,String>
    A map of string k/v properties.
    entityName String
    The name of the entity (if entity_name is not provided, it will create entity-default Kafka quota)
    entityType String
    The type of the entity (client-id, user, ip)
    config {[key: string]: string}
    A map of string k/v properties.
    entityName string
    The name of the entity (if entity_name is not provided, it will create entity-default Kafka quota)
    entityType string
    The type of the entity (client-id, user, ip)
    config Mapping[str, str]
    A map of string k/v properties.
    entity_name str
    The name of the entity (if entity_name is not provided, it will create entity-default Kafka quota)
    entity_type str
    The type of the entity (client-id, user, ip)
    config Map<String>
    A map of string k/v properties.
    entityName String
    The name of the entity (if entity_name is not provided, it will create entity-default Kafka quota)
    entityType String
    The type of the entity (client-id, user, ip)

    Import

    Kafka quotas can be imported using the entity type and name:

    For named entities

    $ pulumi import kafka:index/quota:Quota example client-id:my-client
    

    For default quotas (no entity name)

    $ pulumi import kafka:index/quota:Quota default_user user:
    

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    Kafka pulumi/pulumi-kafka
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the kafka Terraform Provider.
    kafka logo
    Kafka v3.11.1 published on Tuesday, Jul 29, 2025 by Pulumi