Topic class
A Managed Service for Apache Kafka topic. Apache Kafka is a trademark owned by the Apache Software Foundation.
Example Usage
Managedkafka Topic Basic
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const project = gcp.organizations.getProject({});
const cluster = new gcp.managedkafka.Cluster("cluster", {
clusterId: "my-cluster",
location: "us-central1",
capacityConfig: {
vcpuCount: "3",
memoryBytes: "3221225472",
},
gcpConfig: {
accessConfig: {
networkConfigs: [{
subnet: project.then(project => `projects/${project.number}/regions/us-central1/subnetworks/default`),
}],
},
},
});
const example = new gcp.managedkafka.Topic("example", {
topicId: "my-topic",
cluster: cluster.clusterId,
location: "us-central1",
partitionCount: 2,
replicationFactor: 3,
configs: {
"cleanup.policy": "compact",
},
});
import pulumi
import pulumi_gcp as gcp
project = gcp.organizations.get_project()
cluster = gcp.managedkafka.Cluster("cluster",
cluster_id="my-cluster",
location="us-central1",
capacity_config={
"vcpu_count": "3",
"memory_bytes": "3221225472",
},
gcp_config={
"access_config": {
"network_configs": [{
"subnet": f"projects/{project.number}/regions/us-central1/subnetworks/default",
}],
},
})
example = gcp.managedkafka.Topic("example",
topic_id="my-topic",
cluster=cluster.cluster_id,
location="us-central1",
partition_count=2,
replication_factor=3,
configs={
"cleanup.policy": "compact",
})
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
return await Deployment.RunAsync(() =>
{
var project = Gcp.Organizations.GetProject.Invoke();
var cluster = new Gcp.ManagedKafka.Cluster("cluster", new()
{
ClusterId = "my-cluster",
Location = "us-central1",
CapacityConfig = new Gcp.ManagedKafka.Inputs.ClusterCapacityConfigArgs
{
VcpuCount = "3",
MemoryBytes = "3221225472",
},
GcpConfig = new Gcp.ManagedKafka.Inputs.ClusterGcpConfigArgs
{
AccessConfig = new Gcp.ManagedKafka.Inputs.ClusterGcpConfigAccessConfigArgs
{
NetworkConfigs = new[]
{
new Gcp.ManagedKafka.Inputs.ClusterGcpConfigAccessConfigNetworkConfigArgs
{
Subnet = $"projects/{project.Apply(getProjectResult => getProjectResult.Number)}/regions/us-central1/subnetworks/default",
},
},
},
},
});
var example = new Gcp.ManagedKafka.Topic("example", new()
{
TopicId = "my-topic",
Cluster = cluster.ClusterId,
Location = "us-central1",
PartitionCount = 2,
ReplicationFactor = 3,
Configs =
{
{ "cleanup.policy", "compact" },
},
});
});
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/managedkafka"
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/organizations"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
project, err := organizations.LookupProject(ctx, &organizations.LookupProjectArgs{}, nil)
if err != nil {
return err
}
cluster, err := managedkafka.NewCluster(ctx, "cluster", &managedkafka.ClusterArgs{
ClusterId: pulumi.String("my-cluster"),
Location: pulumi.String("us-central1"),
CapacityConfig: &managedkafka.ClusterCapacityConfigArgs{
VcpuCount: pulumi.String("3"),
MemoryBytes: pulumi.String("3221225472"),
},
GcpConfig: &managedkafka.ClusterGcpConfigArgs{
AccessConfig: &managedkafka.ClusterGcpConfigAccessConfigArgs{
NetworkConfigs: managedkafka.ClusterGcpConfigAccessConfigNetworkConfigArray{
&managedkafka.ClusterGcpConfigAccessConfigNetworkConfigArgs{
Subnet: pulumi.Sprintf("projects/%v/regions/us-central1/subnetworks/default", project.Number),
},
},
},
},
})
if err != nil {
return err
}
_, err = managedkafka.NewTopic(ctx, "example", &managedkafka.TopicArgs{
TopicId: pulumi.String("my-topic"),
Cluster: cluster.ClusterId,
Location: pulumi.String("us-central1"),
PartitionCount: pulumi.Int(2),
ReplicationFactor: pulumi.Int(3),
Configs: pulumi.StringMap{
"cleanup.policy": pulumi.String("compact"),
},
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
gcp = {
source = "pulumi/gcp"
}
}
}
data "gcp_organizations_getproject" "project" {
}
resource "gcp_managedkafka_cluster" "cluster" {
cluster_id = "my-cluster"
location = "us-central1"
capacity_config = {
vcpu_count = 3
memory_bytes = 3221225472
}
gcp_config = {
access_config = {
network_configs = [{
"subnet" ="projects/${data.gcp_organizations_getproject.project.number}/regions/us-central1/subnetworks/default"
}]
}
}
}
resource "gcp_managedkafka_topic" "example" {
topic_id = "my-topic"
cluster = gcp_managedkafka_cluster.cluster.cluster_id
location = "us-central1"
partition_count = 2
replication_factor = 3
configs = {
"cleanup.policy" = "compact"
}
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.organizations.OrganizationsFunctions;
import com.pulumi.gcp.organizations.inputs.GetProjectArgs;
import com.pulumi.gcp.managedkafka.Cluster;
import com.pulumi.gcp.managedkafka.ClusterArgs;
import com.pulumi.gcp.managedkafka.inputs.ClusterCapacityConfigArgs;
import com.pulumi.gcp.managedkafka.inputs.ClusterGcpConfigArgs;
import com.pulumi.gcp.managedkafka.inputs.ClusterGcpConfigAccessConfigArgs;
import com.pulumi.gcp.managedkafka.inputs.ClusterGcpConfigAccessConfigNetworkConfigArgs;
import com.pulumi.gcp.managedkafka.Topic;
import com.pulumi.gcp.managedkafka.TopicArgs;
import java.util.ArrayList;
import java.util.Arrays;
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) {
final var project = OrganizationsFunctions.getProject(GetProjectArgs.builder()
.build());
var cluster = new Cluster("cluster", ClusterArgs.builder()
.clusterId("my-cluster")
.location("us-central1")
.capacityConfig(ClusterCapacityConfigArgs.builder()
.vcpuCount("3")
.memoryBytes("3221225472")
.build())
.gcpConfig(ClusterGcpConfigArgs.builder()
.accessConfig(ClusterGcpConfigAccessConfigArgs.builder()
.networkConfigs(ClusterGcpConfigAccessConfigNetworkConfigArgs.builder()
.subnet(String.format("projects/%s/regions/us-central1/subnetworks/default", project.number()))
.build())
.build())
.build())
.build());
var example = new Topic("example", TopicArgs.builder()
.topicId("my-topic")
.cluster(cluster.clusterId())
.location("us-central1")
.partitionCount(2)
.replicationFactor(3)
.configs(Map.of("cleanup.policy", "compact"))
.build());
}
}
resources:
cluster:
type: gcp:managedkafka:Cluster
properties:
clusterId: my-cluster
location: us-central1
capacityConfig:
vcpuCount: 3
memoryBytes: 3.221225472e+09
gcpConfig:
accessConfig:
networkConfigs:
- subnet: projects/${project.number}/regions/us-central1/subnetworks/default
example:
type: gcp:managedkafka:Topic
properties:
topicId: my-topic
cluster: ${cluster.clusterId}
location: us-central1
partitionCount: 2
replicationFactor: 3
configs:
cleanup.policy: compact
variables:
project:
fn::invoke:
function: gcp:organizations:getProject
arguments: {}
Import
Topic can be imported using any of these accepted formats:
projects/{{project}}/locations/{{location}}/clusters/{{cluster}}/topics/{{topic_id}}{{project}}/{{location}}/{{cluster}}/{{topic_id}}{{location}}/{{cluster}}/{{topic_id}}
When using the pulumi import command, Topic can be imported using one of the formats above. For example:
$ pulumi import gcp:managedkafka/topic:Topic default projects/{{project}}/locations/{{location}}/clusters/{{cluster}}/topics/{{topic_id}}
$ pulumi import gcp:managedkafka/topic:Topic default {{project}}/{{location}}/{{cluster}}/{{topic_id}}
$ pulumi import gcp:managedkafka/topic:Topic default {{location}}/{{cluster}}/{{topic_id}}
Constructors
- Topic(String name, {TopicArgs? args, CustomResourceOptions? options})
-
Creates a new Topic.
nameThe Pulumi resource name.argsArguments used to configure this Topic. The set of arguments for Topic.optionsResource options controlling this resource's behavior. - Topic.reference(String urn)
- Creates a typed reference to an existing Topic resource.
Properties
-
childResources
→ Set<
Resource> -
finalinherited
-
cluster
↔ Output<
String> -
The cluster name.
latefinal
-
completionSources
↔ Map<
String, IOutputCompletionSource> -
latefinalinherited
-
configs
↔ Output<
Map< String, String> ?> -
Configuration for the topic that are overridden from the cluster defaults. The key of the map is a Kafka topic property name, for example:
cleanup.policy=compact,compression.type=producer.latefinal -
deletionPolicy
↔ Output<
String> -
Whether Terraform will be prevented from destroying the resource. Defaults to DELETE.
When a 'terraform destroy' or 'pulumi up' would delete the resource,
the command will fail if this field is set to "PREVENT" in Terraform state.
When set to "ABANDON", the command will remove the resource from Terraform
management without updating or deleting the resource in the API.
When set to "DELETE", deleting the resource is allowed.
latefinal
- hashCode → int
-
The hash code for this object.
no setterinherited
-
id
↔ Output<
String> -
getter/setter pairinherited
- isCustom → bool
-
Returns whether this resource is provider-managed.
no setterinherited
- isProtected → bool
-
Returns whether this resource is protected from deletion.
no setterinherited
- isRemote → bool
-
Whether this resource is registered as remote.
no setterinherited
- isResourceReference → bool
-
Whether this instance represents a resource value returned over RPC.
finalinherited
-
location
↔ Output<
String> -
ID of the location of the Kafka resource. See https://cloud.google.com/managed-kafka/docs/locations for a list of supported locations.
latefinal
-
name
↔ Output<
String> -
The name of the topic. The
topicsegment is used when connecting directly to the cluster. Must be in the formatprojects/PROJECT_ID/locations/LOCATION/clusters/CLUSTER_ID/topics/TOPIC_ID.latefinal -
partitionCount
↔ Output<
int?> -
The number of partitions in a topic. You can increase the partition count for a topic, but you cannot decrease it. Increasing partitions for a topic that uses a key might change how messages are distributed.
latefinal
-
project
↔ Output<
String> -
The ID of the project in which the resource belongs.
If it is not provided, the provider project is used.
latefinal
-
replicationFactor
↔ Output<
int> -
The number of replicas of each partition. A replication factor of 3 is recommended for high availability.
latefinal
-
resourceTransforms
→ List<
ResourceTransform> -
Inherited/explicit async transforms.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
topicId
↔ Output<
String> -
The ID to use for the topic, which will become the final component of the topic's name. This value is structured like:
my-topic-name.latefinal -
transformations
→ List<
ResourceTransformation> -
Inherited/explicit legacy transformations.
no setterinherited
-
urn
↔ Output<
String> -
latefinalinherited
Methods
-
failId(
Object error) → void -
Completes this resource ID with an error when registration fails.
inherited
-
failOutputs(
Object error) → void -
Completes all output properties with
error.inherited -
failUrn(
Object error) → void -
Completes this resource URN with an error when registration fails.
inherited
-
getProvider(
String moduleMember) → ProviderResource? -
Returns provider for
moduleMember's package, if configured.inherited -
getResourceName(
) → String -
Returns this resource's logical name.
inherited
-
getResourceType(
) → String -
Returns this resource's Pulumi type token.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerOutput<
T> (String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output< T> -
Registers a dynamic output property for this resource.
inherited
-
resolveId(
String? value, {required bool isKnown}) → void -
Resolves the provider-assigned ID for this resource.
inherited
-
resolveOutputs(
Struct outputs) → void -
Resolves all output properties from a monitor response payload.
inherited
-
resolveUrn(
String value) → void -
Resolves this resource's URN once assigned by the engine.
inherited
-
serializeProperties(
Map< String, dynamic> properties) → Future<Struct> -
Serializes resource properties for RPC transmission.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited