redpanda.Topic
Topic represents a Kafka topic configuration
Creates a topic in a Redpanda Cluster
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as redpanda from "@pulumi/redpanda";
const exampleResourceGroup = new redpanda.ResourceGroup("exampleResourceGroup", {});
const exampleNetwork = new redpanda.Network("exampleNetwork", {
resourceGroupId: exampleResourceGroup.id,
cloudProvider: "aws",
region: "us-west-2",
clusterType: "dedicated",
cidrBlock: "10.0.0.0/20",
});
const exampleCluster = new redpanda.Cluster("exampleCluster", {
resourceGroupId: exampleResourceGroup.id,
networkId: exampleNetwork.id,
cloudProvider: "aws",
region: "us-west-2",
clusterType: "dedicated",
connectionType: "public",
throughputTier: "tier-1-aws",
zones: [
"us-west-2a",
"us-west-2b",
"us-west-2c",
],
});
const exampleTopic = new redpanda.Topic("exampleTopic", {
partitionCount: 3,
replicationFactor: 3,
clusterApiUrl: exampleCluster.clusterApiUrl,
configuration: {
"cleanup.policy": "delete",
"retention.ms": "604800000",
},
});
import pulumi
import pulumi_redpanda as redpanda
example_resource_group = redpanda.ResourceGroup("exampleResourceGroup")
example_network = redpanda.Network("exampleNetwork",
resource_group_id=example_resource_group.id,
cloud_provider="aws",
region="us-west-2",
cluster_type="dedicated",
cidr_block="10.0.0.0/20")
example_cluster = redpanda.Cluster("exampleCluster",
resource_group_id=example_resource_group.id,
network_id=example_network.id,
cloud_provider="aws",
region="us-west-2",
cluster_type="dedicated",
connection_type="public",
throughput_tier="tier-1-aws",
zones=[
"us-west-2a",
"us-west-2b",
"us-west-2c",
])
example_topic = redpanda.Topic("exampleTopic",
partition_count=3,
replication_factor=3,
cluster_api_url=example_cluster.cluster_api_url,
configuration={
"cleanup.policy": "delete",
"retention.ms": "604800000",
})
package main
import (
"github.com/pulumi/pulumi-terraform-provider/sdks/go/redpanda/redpanda"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
exampleResourceGroup, err := redpanda.NewResourceGroup(ctx, "exampleResourceGroup", nil)
if err != nil {
return err
}
exampleNetwork, err := redpanda.NewNetwork(ctx, "exampleNetwork", &redpanda.NetworkArgs{
ResourceGroupId: exampleResourceGroup.ID(),
CloudProvider: pulumi.String("aws"),
Region: pulumi.String("us-west-2"),
ClusterType: pulumi.String("dedicated"),
CidrBlock: pulumi.String("10.0.0.0/20"),
})
if err != nil {
return err
}
exampleCluster, err := redpanda.NewCluster(ctx, "exampleCluster", &redpanda.ClusterArgs{
ResourceGroupId: exampleResourceGroup.ID(),
NetworkId: exampleNetwork.ID(),
CloudProvider: pulumi.String("aws"),
Region: pulumi.String("us-west-2"),
ClusterType: pulumi.String("dedicated"),
ConnectionType: pulumi.String("public"),
ThroughputTier: pulumi.String("tier-1-aws"),
Zones: pulumi.StringArray{
pulumi.String("us-west-2a"),
pulumi.String("us-west-2b"),
pulumi.String("us-west-2c"),
},
})
if err != nil {
return err
}
_, err = redpanda.NewTopic(ctx, "exampleTopic", &redpanda.TopicArgs{
PartitionCount: pulumi.Float64(3),
ReplicationFactor: pulumi.Float64(3),
ClusterApiUrl: exampleCluster.ClusterApiUrl,
Configuration: pulumi.StringMap{
"cleanup.policy": pulumi.String("delete"),
"retention.ms": pulumi.String("604800000"),
},
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Redpanda = Pulumi.Redpanda;
return await Deployment.RunAsync(() =>
{
var exampleResourceGroup = new Redpanda.ResourceGroup("exampleResourceGroup");
var exampleNetwork = new Redpanda.Network("exampleNetwork", new()
{
ResourceGroupId = exampleResourceGroup.Id,
CloudProvider = "aws",
Region = "us-west-2",
ClusterType = "dedicated",
CidrBlock = "10.0.0.0/20",
});
var exampleCluster = new Redpanda.Cluster("exampleCluster", new()
{
ResourceGroupId = exampleResourceGroup.Id,
NetworkId = exampleNetwork.Id,
CloudProvider = "aws",
Region = "us-west-2",
ClusterType = "dedicated",
ConnectionType = "public",
ThroughputTier = "tier-1-aws",
Zones = new[]
{
"us-west-2a",
"us-west-2b",
"us-west-2c",
},
});
var exampleTopic = new Redpanda.Topic("exampleTopic", new()
{
PartitionCount = 3,
ReplicationFactor = 3,
ClusterApiUrl = exampleCluster.ClusterApiUrl,
Configuration =
{
{ "cleanup.policy", "delete" },
{ "retention.ms", "604800000" },
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.redpanda.ResourceGroup;
import com.pulumi.redpanda.Network;
import com.pulumi.redpanda.NetworkArgs;
import com.pulumi.redpanda.Cluster;
import com.pulumi.redpanda.ClusterArgs;
import com.pulumi.redpanda.Topic;
import com.pulumi.redpanda.TopicArgs;
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 exampleResourceGroup = new ResourceGroup("exampleResourceGroup");
var exampleNetwork = new Network("exampleNetwork", NetworkArgs.builder()
.resourceGroupId(exampleResourceGroup.id())
.cloudProvider("aws")
.region("us-west-2")
.clusterType("dedicated")
.cidrBlock("10.0.0.0/20")
.build());
var exampleCluster = new Cluster("exampleCluster", ClusterArgs.builder()
.resourceGroupId(exampleResourceGroup.id())
.networkId(exampleNetwork.id())
.cloudProvider("aws")
.region("us-west-2")
.clusterType("dedicated")
.connectionType("public")
.throughputTier("tier-1-aws")
.zones(
"us-west-2a",
"us-west-2b",
"us-west-2c")
.build());
var exampleTopic = new Topic("exampleTopic", TopicArgs.builder()
.partitionCount(3)
.replicationFactor(3)
.clusterApiUrl(exampleCluster.clusterApiUrl())
.configuration(Map.ofEntries(
Map.entry("cleanup.policy", "delete"),
Map.entry("retention.ms", "604800000")
))
.build());
}
}
resources:
exampleResourceGroup:
type: redpanda:ResourceGroup
exampleNetwork:
type: redpanda:Network
properties:
resourceGroupId: ${exampleResourceGroup.id}
cloudProvider: aws
region: us-west-2
clusterType: dedicated
cidrBlock: 10.0.0.0/20
exampleCluster:
type: redpanda:Cluster
properties:
resourceGroupId: ${exampleResourceGroup.id}
networkId: ${exampleNetwork.id}
cloudProvider: aws
region: us-west-2
clusterType: dedicated
connectionType: public
throughputTier: tier-1-aws
zones:
- us-west-2a
- us-west-2b
- us-west-2c
exampleTopic:
type: redpanda:Topic
properties:
partitionCount: 3
replicationFactor: 3
clusterApiUrl: ${exampleCluster.clusterApiUrl}
configuration:
cleanup.policy: delete
retention.ms: '604800000'
Limitations
We are not currently able to support topic creation in self hosted clusters. This is an area of active development so expect that to change soon.
API Reference
For more information, see the Redpanda Cloud Data Plane API documentation.
Create Topic Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new Topic(name: string, args: TopicArgs, opts?: CustomResourceOptions);
@overload
def Topic(resource_name: str,
args: TopicArgs,
opts: Optional[ResourceOptions] = None)
@overload
def Topic(resource_name: str,
opts: Optional[ResourceOptions] = None,
cluster_api_url: Optional[str] = None,
allow_deletion: Optional[bool] = None,
configuration: Optional[Mapping[str, str]] = None,
name: Optional[str] = None,
partition_count: Optional[float] = None,
replication_factor: Optional[float] = None)
func NewTopic(ctx *Context, name string, args TopicArgs, opts ...ResourceOption) (*Topic, error)
public Topic(string name, TopicArgs args, CustomResourceOptions? opts = null)
type: redpanda:Topic
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 TopicArgs
- 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 TopicArgs
- 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 TopicArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args TopicArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args TopicArgs
- 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 topicResource = new Redpanda.Topic("topicResource", new()
{
ClusterApiUrl = "string",
AllowDeletion = false,
Configuration =
{
{ "string", "string" },
},
Name = "string",
PartitionCount = 0,
ReplicationFactor = 0,
});
example, err := redpanda.NewTopic(ctx, "topicResource", &redpanda.TopicArgs{
ClusterApiUrl: pulumi.String("string"),
AllowDeletion: pulumi.Bool(false),
Configuration: pulumi.StringMap{
"string": pulumi.String("string"),
},
Name: pulumi.String("string"),
PartitionCount: pulumi.Float64(0),
ReplicationFactor: pulumi.Float64(0),
})
var topicResource = new Topic("topicResource", TopicArgs.builder()
.clusterApiUrl("string")
.allowDeletion(false)
.configuration(Map.of("string", "string"))
.name("string")
.partitionCount(0.0)
.replicationFactor(0.0)
.build());
topic_resource = redpanda.Topic("topicResource",
cluster_api_url="string",
allow_deletion=False,
configuration={
"string": "string",
},
name="string",
partition_count=0,
replication_factor=0)
const topicResource = new redpanda.Topic("topicResource", {
clusterApiUrl: "string",
allowDeletion: false,
configuration: {
string: "string",
},
name: "string",
partitionCount: 0,
replicationFactor: 0,
});
type: redpanda:Topic
properties:
allowDeletion: false
clusterApiUrl: string
configuration:
string: string
name: string
partitionCount: 0
replicationFactor: 0
Topic 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 Topic resource accepts the following input properties:
- Cluster
Api stringUrl - The cluster API URL. Changing this will prevent deletion of the resource on the existing cluster. It is generally a better idea to delete an existing resource and create a new one than to change this value unless you are planning to do state imports
- Allow
Deletion bool - Indicates whether the topic can be deleted.
- Configuration Dictionary<string, string>
- A map of string key/value pairs of topic configurations.
- Name string
- The name of the topic.
- Partition
Count double - The number of partitions for the topic. This determines how the data is distributed across brokers. Increases are fully supported without data loss. Decreases will destroy and recreate the topic if allow_deletion is set to true (defaults to false).
- Replication
Factor double - The replication factor for the topic, which defines how many copies of the data are kept across different brokers for fault tolerance.
- Cluster
Api stringUrl - The cluster API URL. Changing this will prevent deletion of the resource on the existing cluster. It is generally a better idea to delete an existing resource and create a new one than to change this value unless you are planning to do state imports
- Allow
Deletion bool - Indicates whether the topic can be deleted.
- Configuration map[string]string
- A map of string key/value pairs of topic configurations.
- Name string
- The name of the topic.
- Partition
Count float64 - The number of partitions for the topic. This determines how the data is distributed across brokers. Increases are fully supported without data loss. Decreases will destroy and recreate the topic if allow_deletion is set to true (defaults to false).
- Replication
Factor float64 - The replication factor for the topic, which defines how many copies of the data are kept across different brokers for fault tolerance.
- cluster
Api StringUrl - The cluster API URL. Changing this will prevent deletion of the resource on the existing cluster. It is generally a better idea to delete an existing resource and create a new one than to change this value unless you are planning to do state imports
- allow
Deletion Boolean - Indicates whether the topic can be deleted.
- configuration Map<String,String>
- A map of string key/value pairs of topic configurations.
- name String
- The name of the topic.
- partition
Count Double - The number of partitions for the topic. This determines how the data is distributed across brokers. Increases are fully supported without data loss. Decreases will destroy and recreate the topic if allow_deletion is set to true (defaults to false).
- replication
Factor Double - The replication factor for the topic, which defines how many copies of the data are kept across different brokers for fault tolerance.
- cluster
Api stringUrl - The cluster API URL. Changing this will prevent deletion of the resource on the existing cluster. It is generally a better idea to delete an existing resource and create a new one than to change this value unless you are planning to do state imports
- allow
Deletion boolean - Indicates whether the topic can be deleted.
- configuration {[key: string]: string}
- A map of string key/value pairs of topic configurations.
- name string
- The name of the topic.
- partition
Count number - The number of partitions for the topic. This determines how the data is distributed across brokers. Increases are fully supported without data loss. Decreases will destroy and recreate the topic if allow_deletion is set to true (defaults to false).
- replication
Factor number - The replication factor for the topic, which defines how many copies of the data are kept across different brokers for fault tolerance.
- cluster_
api_ strurl - The cluster API URL. Changing this will prevent deletion of the resource on the existing cluster. It is generally a better idea to delete an existing resource and create a new one than to change this value unless you are planning to do state imports
- allow_
deletion bool - Indicates whether the topic can be deleted.
- configuration Mapping[str, str]
- A map of string key/value pairs of topic configurations.
- name str
- The name of the topic.
- partition_
count float - The number of partitions for the topic. This determines how the data is distributed across brokers. Increases are fully supported without data loss. Decreases will destroy and recreate the topic if allow_deletion is set to true (defaults to false).
- replication_
factor float - The replication factor for the topic, which defines how many copies of the data are kept across different brokers for fault tolerance.
- cluster
Api StringUrl - The cluster API URL. Changing this will prevent deletion of the resource on the existing cluster. It is generally a better idea to delete an existing resource and create a new one than to change this value unless you are planning to do state imports
- allow
Deletion Boolean - Indicates whether the topic can be deleted.
- configuration Map<String>
- A map of string key/value pairs of topic configurations.
- name String
- The name of the topic.
- partition
Count Number - The number of partitions for the topic. This determines how the data is distributed across brokers. Increases are fully supported without data loss. Decreases will destroy and recreate the topic if allow_deletion is set to true (defaults to false).
- replication
Factor Number - The replication factor for the topic, which defines how many copies of the data are kept across different brokers for fault tolerance.
Outputs
All input properties are implicitly available as output properties. Additionally, the Topic 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 Topic Resource
Get an existing Topic 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?: TopicState, opts?: CustomResourceOptions): Topic
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
allow_deletion: Optional[bool] = None,
cluster_api_url: Optional[str] = None,
configuration: Optional[Mapping[str, str]] = None,
name: Optional[str] = None,
partition_count: Optional[float] = None,
replication_factor: Optional[float] = None) -> Topic
func GetTopic(ctx *Context, name string, id IDInput, state *TopicState, opts ...ResourceOption) (*Topic, error)
public static Topic Get(string name, Input<string> id, TopicState? state, CustomResourceOptions? opts = null)
public static Topic get(String name, Output<String> id, TopicState state, CustomResourceOptions options)
resources: _: type: redpanda:Topic 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.
- Allow
Deletion bool - Indicates whether the topic can be deleted.
- Cluster
Api stringUrl - The cluster API URL. Changing this will prevent deletion of the resource on the existing cluster. It is generally a better idea to delete an existing resource and create a new one than to change this value unless you are planning to do state imports
- Configuration Dictionary<string, string>
- A map of string key/value pairs of topic configurations.
- Name string
- The name of the topic.
- Partition
Count double - The number of partitions for the topic. This determines how the data is distributed across brokers. Increases are fully supported without data loss. Decreases will destroy and recreate the topic if allow_deletion is set to true (defaults to false).
- Replication
Factor double - The replication factor for the topic, which defines how many copies of the data are kept across different brokers for fault tolerance.
- Allow
Deletion bool - Indicates whether the topic can be deleted.
- Cluster
Api stringUrl - The cluster API URL. Changing this will prevent deletion of the resource on the existing cluster. It is generally a better idea to delete an existing resource and create a new one than to change this value unless you are planning to do state imports
- Configuration map[string]string
- A map of string key/value pairs of topic configurations.
- Name string
- The name of the topic.
- Partition
Count float64 - The number of partitions for the topic. This determines how the data is distributed across brokers. Increases are fully supported without data loss. Decreases will destroy and recreate the topic if allow_deletion is set to true (defaults to false).
- Replication
Factor float64 - The replication factor for the topic, which defines how many copies of the data are kept across different brokers for fault tolerance.
- allow
Deletion Boolean - Indicates whether the topic can be deleted.
- cluster
Api StringUrl - The cluster API URL. Changing this will prevent deletion of the resource on the existing cluster. It is generally a better idea to delete an existing resource and create a new one than to change this value unless you are planning to do state imports
- configuration Map<String,String>
- A map of string key/value pairs of topic configurations.
- name String
- The name of the topic.
- partition
Count Double - The number of partitions for the topic. This determines how the data is distributed across brokers. Increases are fully supported without data loss. Decreases will destroy and recreate the topic if allow_deletion is set to true (defaults to false).
- replication
Factor Double - The replication factor for the topic, which defines how many copies of the data are kept across different brokers for fault tolerance.
- allow
Deletion boolean - Indicates whether the topic can be deleted.
- cluster
Api stringUrl - The cluster API URL. Changing this will prevent deletion of the resource on the existing cluster. It is generally a better idea to delete an existing resource and create a new one than to change this value unless you are planning to do state imports
- configuration {[key: string]: string}
- A map of string key/value pairs of topic configurations.
- name string
- The name of the topic.
- partition
Count number - The number of partitions for the topic. This determines how the data is distributed across brokers. Increases are fully supported without data loss. Decreases will destroy and recreate the topic if allow_deletion is set to true (defaults to false).
- replication
Factor number - The replication factor for the topic, which defines how many copies of the data are kept across different brokers for fault tolerance.
- allow_
deletion bool - Indicates whether the topic can be deleted.
- cluster_
api_ strurl - The cluster API URL. Changing this will prevent deletion of the resource on the existing cluster. It is generally a better idea to delete an existing resource and create a new one than to change this value unless you are planning to do state imports
- configuration Mapping[str, str]
- A map of string key/value pairs of topic configurations.
- name str
- The name of the topic.
- partition_
count float - The number of partitions for the topic. This determines how the data is distributed across brokers. Increases are fully supported without data loss. Decreases will destroy and recreate the topic if allow_deletion is set to true (defaults to false).
- replication_
factor float - The replication factor for the topic, which defines how many copies of the data are kept across different brokers for fault tolerance.
- allow
Deletion Boolean - Indicates whether the topic can be deleted.
- cluster
Api StringUrl - The cluster API URL. Changing this will prevent deletion of the resource on the existing cluster. It is generally a better idea to delete an existing resource and create a new one than to change this value unless you are planning to do state imports
- configuration Map<String>
- A map of string key/value pairs of topic configurations.
- name String
- The name of the topic.
- partition
Count Number - The number of partitions for the topic. This determines how the data is distributed across brokers. Increases are fully supported without data loss. Decreases will destroy and recreate the topic if allow_deletion is set to true (defaults to false).
- replication
Factor Number - The replication factor for the topic, which defines how many copies of the data are kept across different brokers for fault tolerance.
Import
$ pulumi import redpanda:index/topic:Topic example topicName,clusterId
Where clusterId is the ID of the cluster in Redpanda Cloud
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- redpanda redpanda-data/terraform-provider-redpanda
- License
- Notes
- This Pulumi package is based on the
redpanda
Terraform Provider.