Topic class

Manages an AWS Managed Streaming for Kafka Topic.

Example Usage

Basic Usage

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const example = new aws.msk.Topic("example", {
    name: "Example",
    clusterArn: exampleAwsMskCluster.arn,
    partitionCount: 2,
    replicationFactor: 2,
    configs: JSON.stringify({
        "retention.ms": "604800000",
        "retention.bytes": "-1",
        "cleanup.policy": "delete",
        "min.insync.replicas": "2",
    }),
});
import pulumi
import json
import pulumi_aws as aws

example = aws.msk.Topic("example",
    name="Example",
    cluster_arn=example_aws_msk_cluster["arn"],
    partition_count=2,
    replication_factor=2,
    configs=json.dumps({
        "retention.ms": "604800000",
        "retention.bytes": "-1",
        "cleanup.policy": "delete",
        "min.insync.replicas": "2",
    }))
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() =>
{
    var example = new Aws.Msk.Topic("example", new()
    {
        Name = "Example",
        ClusterArn = exampleAwsMskCluster.Arn,
        PartitionCount = 2,
        ReplicationFactor = 2,
        Configs = JsonSerializer.Serialize(new Dictionary<string, object?>
        {
            ["retention.ms"] = "604800000",
            ["retention.bytes"] = "-1",
            ["cleanup.policy"] = "delete",
            ["min.insync.replicas"] = "2",
        }),
    });

});
package main

import (
	"encoding/json"

	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/msk"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		tmpJSON0, err := json.Marshal(map[string]string{
			"retention.ms":        "604800000",
			"retention.bytes":     "-1",
			"cleanup.policy":      "delete",
			"min.insync.replicas": "2",
		})
		if err != nil {
			return err
		}
		json0 := string(tmpJSON0)
		_, err = msk.NewTopic(ctx, "example", &msk.TopicArgs{
			Name:              pulumi.String("Example"),
			ClusterArn:        pulumi.Any(exampleAwsMskCluster.Arn),
			PartitionCount:    pulumi.Int(2),
			ReplicationFactor: pulumi.Int(2),
			Configs:           pulumi.String(json0),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
  }
}

resource "aws_msk_topic" "example" {
  name               = "Example"
  cluster_arn        = exampleAwsMskCluster.arn
  partition_count    = 2
  replication_factor = 2
  configs = jsonencode({
    "retention.ms"        = "604800000"
    "retention.bytes"     = "-1"
    "cleanup.policy"      = "delete"
    "min.insync.replicas" = "2"
  })
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.msk.Topic;
import com.pulumi.aws.msk.TopicArgs;
import static com.pulumi.codegen.internal.Serialization.*;
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) {
        var example = new Topic("example", TopicArgs.builder()
            .name("Example")
            .clusterArn(exampleAwsMskCluster.arn())
            .partitionCount(2)
            .replicationFactor(2)
            .configs(serializeJson(
                jsonObject(
                    jsonProperty("retention.ms", "604800000"),
                    jsonProperty("retention.bytes", "-1"),
                    jsonProperty("cleanup.policy", "delete"),
                    jsonProperty("min.insync.replicas", "2")
                )))
            .build());

    }
}
resources:
  example:
    type: aws:msk:Topic
    properties:
      name: Example
      clusterArn: ${exampleAwsMskCluster.arn}
      partitionCount: 2
      replicationFactor: 2
      configs:
        fn::toJSON:
          retention.ms: '604800000'
          retention.bytes: '-1'
          cleanup.policy: delete
          min.insync.replicas: '2'

Import

Identity Schema

Required

  • clusterArn (String) ARN that uniquely identifies MSK Cluster.
  • name (String) Name of Topic.

Optional

  • accountId (String) AWS Account where this resource is managed.
  • region (String) Region where this resource is managed.

Using pulumi import, import Managed Streaming for Kafka Topic using the clusterArn and name. For example:

$ pulumi import aws:msk/topic:Topic example arn:aws:kafka:us-west-2:123456789012:cluster/example/279c0212-d057-4dba-9aa9-1c4e5a25bfc7-3,topicname

Constructors

Topic(String name, {TopicArgs? args, CustomResourceOptions? options})
Creates a new Topic. name The Pulumi resource name. args Arguments used to configure this Topic. The set of arguments for Topic. options Resource options controlling this resource's behavior.
Topic.reference(String urn)
Creates a typed reference to an existing Topic resource.

Properties

arn ↔ Output<String>
ARN of the Topic.
latefinal
childResources → Set<Resource>
finalinherited
clusterArn ↔ Output<String>
ARN that uniquely identifies MSK Cluster.
latefinal
completionSources ↔ Map<String, IOutputCompletionSource>
latefinalinherited
configs ↔ Output<String?>
Explicit configured Kafka configuration in JSON format for Topic.
latefinal
configsActual ↔ Output<String>
Aggregated Kafka configuration in JSON format for Topic, both explicit set values from configs and implicit set values (AWS default configuration, historically set values or manual configuration from outside Terraform).
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
name ↔ Output<String>
Name of Topic.
latefinal
partitionCount ↔ Output<int>
Number of partitions for Topic.
latefinal
region ↔ Output<String>
Region where this resource will be managed. Defaults to the Region set in the provider configuration.
latefinal
replicationFactor ↔ Output<int>
Replication factor for Topic.
latefinal
resourceTransforms → List<ResourceTransform>
Inherited/explicit async transforms.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
timeouts ↔ Output<TopicTimeouts?>
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

Static Methods

get(String name, Input<String> id, {TopicState? state, CustomResourceOptions? options}) → Topic
Gets an existing Topic resource's state with the given name and id.