published on Saturday, Apr 11, 2026 by Pulumi
published on Saturday, Apr 11, 2026 by Pulumi
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",
}))
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]interface{}{
"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(pulumi.String(json0)),
})
if err != nil {
return err
}
return nil
})
}
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 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.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 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'
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_arn: Optional[str] = None,
partition_count: Optional[int] = None,
replication_factor: Optional[int] = None,
configs: Optional[str] = None,
name: Optional[str] = None,
region: Optional[str] = None,
timeouts: Optional[TopicTimeoutsArgs] = None)func NewTopic(ctx *Context, name string, args TopicArgs, opts ...ResourceOption) (*Topic, error)public Topic(string name, TopicArgs args, CustomResourceOptions? opts = null)type: aws:msk: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 Aws.Msk.Topic("topicResource", new()
{
ClusterArn = "string",
PartitionCount = 0,
ReplicationFactor = 0,
Configs = "string",
Name = "string",
Region = "string",
Timeouts = new Aws.Msk.Inputs.TopicTimeoutsArgs
{
Create = "string",
Delete = "string",
Update = "string",
},
});
example, err := msk.NewTopic(ctx, "topicResource", &msk.TopicArgs{
ClusterArn: pulumi.String("string"),
PartitionCount: pulumi.Int(0),
ReplicationFactor: pulumi.Int(0),
Configs: pulumi.String("string"),
Name: pulumi.String("string"),
Region: pulumi.String("string"),
Timeouts: &msk.TopicTimeoutsArgs{
Create: pulumi.String("string"),
Delete: pulumi.String("string"),
Update: pulumi.String("string"),
},
})
var topicResource = new com.pulumi.aws.msk.Topic("topicResource", com.pulumi.aws.msk.TopicArgs.builder()
.clusterArn("string")
.partitionCount(0)
.replicationFactor(0)
.configs("string")
.name("string")
.region("string")
.timeouts(TopicTimeoutsArgs.builder()
.create("string")
.delete("string")
.update("string")
.build())
.build());
topic_resource = aws.msk.Topic("topicResource",
cluster_arn="string",
partition_count=0,
replication_factor=0,
configs="string",
name="string",
region="string",
timeouts={
"create": "string",
"delete": "string",
"update": "string",
})
const topicResource = new aws.msk.Topic("topicResource", {
clusterArn: "string",
partitionCount: 0,
replicationFactor: 0,
configs: "string",
name: "string",
region: "string",
timeouts: {
create: "string",
"delete": "string",
update: "string",
},
});
type: aws:msk:Topic
properties:
clusterArn: string
configs: string
name: string
partitionCount: 0
region: string
replicationFactor: 0
timeouts:
create: string
delete: string
update: string
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
Arn string - Amazon Resource Name (ARN) that uniquely identifies MSK Cluster.
- Partition
Count int - Number of partitions for Topic.
- Replication
Factor int Replication factor for Topic.
The following arguments are optional:
- Configs string
- Explicit configured Kafka configuration in JSON format for Topic.
- Name string
- Name of Topic.
- Region string
- Region where this resource will be managed. Defaults to the Region set in the provider configuration.
- Timeouts
Topic
Timeouts
- Cluster
Arn string - Amazon Resource Name (ARN) that uniquely identifies MSK Cluster.
- Partition
Count int - Number of partitions for Topic.
- Replication
Factor int Replication factor for Topic.
The following arguments are optional:
- Configs string
- Explicit configured Kafka configuration in JSON format for Topic.
- Name string
- Name of Topic.
- Region string
- Region where this resource will be managed. Defaults to the Region set in the provider configuration.
- Timeouts
Topic
Timeouts Args
- cluster
Arn String - Amazon Resource Name (ARN) that uniquely identifies MSK Cluster.
- partition
Count Integer - Number of partitions for Topic.
- replication
Factor Integer Replication factor for Topic.
The following arguments are optional:
- configs String
- Explicit configured Kafka configuration in JSON format for Topic.
- name String
- Name of Topic.
- region String
- Region where this resource will be managed. Defaults to the Region set in the provider configuration.
- timeouts
Topic
Timeouts
- cluster
Arn string - Amazon Resource Name (ARN) that uniquely identifies MSK Cluster.
- partition
Count number - Number of partitions for Topic.
- replication
Factor number Replication factor for Topic.
The following arguments are optional:
- configs string
- Explicit configured Kafka configuration in JSON format for Topic.
- name string
- Name of Topic.
- region string
- Region where this resource will be managed. Defaults to the Region set in the provider configuration.
- timeouts
Topic
Timeouts
- cluster_
arn str - Amazon Resource Name (ARN) that uniquely identifies MSK Cluster.
- partition_
count int - Number of partitions for Topic.
- replication_
factor int Replication factor for Topic.
The following arguments are optional:
- configs str
- Explicit configured Kafka configuration in JSON format for Topic.
- name str
- Name of Topic.
- region str
- Region where this resource will be managed. Defaults to the Region set in the provider configuration.
- timeouts
Topic
Timeouts Args
- cluster
Arn String - Amazon Resource Name (ARN) that uniquely identifies MSK Cluster.
- partition
Count Number - Number of partitions for Topic.
- replication
Factor Number Replication factor for Topic.
The following arguments are optional:
- configs String
- Explicit configured Kafka configuration in JSON format for Topic.
- name String
- Name of Topic.
- region String
- Region where this resource will be managed. Defaults to the Region set in the provider configuration.
- timeouts Property Map
Outputs
All input properties are implicitly available as output properties. Additionally, the Topic resource produces the following output properties:
- Arn string
- ARN of the Topic.
- Configs
Actual string - Aggregated Kafka configuration in JSON format for Topic, both explicit set values from
configsand implicit set values (AWS default configuration, historically set values or manual configuration from outside Terraform). - Id string
- The provider-assigned unique ID for this managed resource.
- Arn string
- ARN of the Topic.
- Configs
Actual string - Aggregated Kafka configuration in JSON format for Topic, both explicit set values from
configsand implicit set values (AWS default configuration, historically set values or manual configuration from outside Terraform). - Id string
- The provider-assigned unique ID for this managed resource.
- arn String
- ARN of the Topic.
- configs
Actual String - Aggregated Kafka configuration in JSON format for Topic, both explicit set values from
configsand implicit set values (AWS default configuration, historically set values or manual configuration from outside Terraform). - id String
- The provider-assigned unique ID for this managed resource.
- arn string
- ARN of the Topic.
- configs
Actual string - Aggregated Kafka configuration in JSON format for Topic, both explicit set values from
configsand implicit set values (AWS default configuration, historically set values or manual configuration from outside Terraform). - id string
- The provider-assigned unique ID for this managed resource.
- arn str
- ARN of the Topic.
- configs_
actual str - Aggregated Kafka configuration in JSON format for Topic, both explicit set values from
configsand implicit set values (AWS default configuration, historically set values or manual configuration from outside Terraform). - id str
- The provider-assigned unique ID for this managed resource.
- arn String
- ARN of the Topic.
- configs
Actual String - Aggregated Kafka configuration in JSON format for Topic, both explicit set values from
configsand implicit set values (AWS default configuration, historically set values or manual configuration from outside Terraform). - 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,
arn: Optional[str] = None,
cluster_arn: Optional[str] = None,
configs: Optional[str] = None,
configs_actual: Optional[str] = None,
name: Optional[str] = None,
partition_count: Optional[int] = None,
region: Optional[str] = None,
replication_factor: Optional[int] = None,
timeouts: Optional[TopicTimeoutsArgs] = None) -> Topicfunc 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: aws:msk: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.
- Arn string
- ARN of the Topic.
- Cluster
Arn string - Amazon Resource Name (ARN) that uniquely identifies MSK Cluster.
- Configs string
- Explicit configured Kafka configuration in JSON format for Topic.
- Configs
Actual string - Aggregated Kafka configuration in JSON format for Topic, both explicit set values from
configsand implicit set values (AWS default configuration, historically set values or manual configuration from outside Terraform). - Name string
- Name of Topic.
- Partition
Count int - Number of partitions for Topic.
- Region string
- Region where this resource will be managed. Defaults to the Region set in the provider configuration.
- Replication
Factor int Replication factor for Topic.
The following arguments are optional:
- Timeouts
Topic
Timeouts
- Arn string
- ARN of the Topic.
- Cluster
Arn string - Amazon Resource Name (ARN) that uniquely identifies MSK Cluster.
- Configs string
- Explicit configured Kafka configuration in JSON format for Topic.
- Configs
Actual string - Aggregated Kafka configuration in JSON format for Topic, both explicit set values from
configsand implicit set values (AWS default configuration, historically set values or manual configuration from outside Terraform). - Name string
- Name of Topic.
- Partition
Count int - Number of partitions for Topic.
- Region string
- Region where this resource will be managed. Defaults to the Region set in the provider configuration.
- Replication
Factor int Replication factor for Topic.
The following arguments are optional:
- Timeouts
Topic
Timeouts Args
- arn String
- ARN of the Topic.
- cluster
Arn String - Amazon Resource Name (ARN) that uniquely identifies MSK Cluster.
- configs String
- Explicit configured Kafka configuration in JSON format for Topic.
- configs
Actual String - Aggregated Kafka configuration in JSON format for Topic, both explicit set values from
configsand implicit set values (AWS default configuration, historically set values or manual configuration from outside Terraform). - name String
- Name of Topic.
- partition
Count Integer - Number of partitions for Topic.
- region String
- Region where this resource will be managed. Defaults to the Region set in the provider configuration.
- replication
Factor Integer Replication factor for Topic.
The following arguments are optional:
- timeouts
Topic
Timeouts
- arn string
- ARN of the Topic.
- cluster
Arn string - Amazon Resource Name (ARN) that uniquely identifies MSK Cluster.
- configs string
- Explicit configured Kafka configuration in JSON format for Topic.
- configs
Actual string - Aggregated Kafka configuration in JSON format for Topic, both explicit set values from
configsand implicit set values (AWS default configuration, historically set values or manual configuration from outside Terraform). - name string
- Name of Topic.
- partition
Count number - Number of partitions for Topic.
- region string
- Region where this resource will be managed. Defaults to the Region set in the provider configuration.
- replication
Factor number Replication factor for Topic.
The following arguments are optional:
- timeouts
Topic
Timeouts
- arn str
- ARN of the Topic.
- cluster_
arn str - Amazon Resource Name (ARN) that uniquely identifies MSK Cluster.
- configs str
- Explicit configured Kafka configuration in JSON format for Topic.
- configs_
actual str - Aggregated Kafka configuration in JSON format for Topic, both explicit set values from
configsand implicit set values (AWS default configuration, historically set values or manual configuration from outside Terraform). - name str
- Name of Topic.
- partition_
count int - Number of partitions for Topic.
- region str
- Region where this resource will be managed. Defaults to the Region set in the provider configuration.
- replication_
factor int Replication factor for Topic.
The following arguments are optional:
- timeouts
Topic
Timeouts Args
- arn String
- ARN of the Topic.
- cluster
Arn String - Amazon Resource Name (ARN) that uniquely identifies MSK Cluster.
- configs String
- Explicit configured Kafka configuration in JSON format for Topic.
- configs
Actual String - Aggregated Kafka configuration in JSON format for Topic, both explicit set values from
configsand implicit set values (AWS default configuration, historically set values or manual configuration from outside Terraform). - name String
- Name of Topic.
- partition
Count Number - Number of partitions for Topic.
- region String
- Region where this resource will be managed. Defaults to the Region set in the provider configuration.
- replication
Factor Number Replication factor for Topic.
The following arguments are optional:
- timeouts Property Map
Supporting Types
TopicTimeouts, TopicTimeoutsArgs
- Create string
- A string that can be parsed as a duration consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).
- Delete string
- A string that can be parsed as a duration consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours). Setting a timeout for a Delete operation is only applicable if changes are saved into state before the destroy operation occurs.
- Update string
- A string that can be parsed as a duration consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).
- Create string
- A string that can be parsed as a duration consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).
- Delete string
- A string that can be parsed as a duration consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours). Setting a timeout for a Delete operation is only applicable if changes are saved into state before the destroy operation occurs.
- Update string
- A string that can be parsed as a duration consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).
- create String
- A string that can be parsed as a duration consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).
- delete String
- A string that can be parsed as a duration consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours). Setting a timeout for a Delete operation is only applicable if changes are saved into state before the destroy operation occurs.
- update String
- A string that can be parsed as a duration consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).
- create string
- A string that can be parsed as a duration consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).
- delete string
- A string that can be parsed as a duration consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours). Setting a timeout for a Delete operation is only applicable if changes are saved into state before the destroy operation occurs.
- update string
- A string that can be parsed as a duration consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).
- create str
- A string that can be parsed as a duration consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).
- delete str
- A string that can be parsed as a duration consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours). Setting a timeout for a Delete operation is only applicable if changes are saved into state before the destroy operation occurs.
- update str
- A string that can be parsed as a duration consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).
- create String
- A string that can be parsed as a duration consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).
- delete String
- A string that can be parsed as a duration consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours). Setting a timeout for a Delete operation is only applicable if changes are saved into state before the destroy operation occurs.
- update String
- A string that can be parsed as a duration consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).
Import
Identity Schema
Required
clusterArn(String) Amazon Resource Name (ARN) that uniquely identifies MSK Cluster.name(String) Name of Topic.
Optional
accountId(String) AWS Account 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
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- AWS Classic pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
awsTerraform Provider.
published on Saturday, Apr 11, 2026 by Pulumi
