alicloud.rocketmq.Topic
Explore with Pulumi AI
Provides an ONS topic resource.
For more information about how to use it, see RocketMQ Topic Management API.
NOTE: Available in 1.53.0+
Example Usage
Basic Usage
import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";
import * as random from "@pulumi/random";
const config = new pulumi.Config();
const name = config.get("name") || "onsInstanceName";
const topic = config.get("topic") || "onsTopicName";
const _default = new random.index.Integer("default", {
min: 10000,
max: 99999,
});
const defaultInstance = new alicloud.rocketmq.Instance("default", {
instanceName: `${name}-${_default.result}`,
remark: "default_ons_instance_remark",
});
const defaultTopic = new alicloud.rocketmq.Topic("default", {
topicName: topic,
instanceId: defaultInstance.id,
messageType: 0,
remark: "dafault_ons_topic_remark",
});
import pulumi
import pulumi_alicloud as alicloud
import pulumi_random as random
config = pulumi.Config()
name = config.get("name")
if name is None:
name = "onsInstanceName"
topic = config.get("topic")
if topic is None:
topic = "onsTopicName"
default = random.index.Integer("default",
min=10000,
max=99999)
default_instance = alicloud.rocketmq.Instance("default",
instance_name=f"{name}-{default['result']}",
remark="default_ons_instance_remark")
default_topic = alicloud.rocketmq.Topic("default",
topic_name=topic,
instance_id=default_instance.id,
message_type=0,
remark="dafault_ons_topic_remark")
package main
import (
"fmt"
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/rocketmq"
"github.com/pulumi/pulumi-random/sdk/v4/go/random"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
cfg := config.New(ctx, "")
name := "onsInstanceName"
if param := cfg.Get("name"); param != "" {
name = param
}
topic := "onsTopicName"
if param := cfg.Get("topic"); param != "" {
topic = param
}
_, err := random.NewInteger(ctx, "default", &random.IntegerArgs{
Min: 10000,
Max: 99999,
})
if err != nil {
return err
}
defaultInstance, err := rocketmq.NewInstance(ctx, "default", &rocketmq.InstanceArgs{
InstanceName: pulumi.Sprintf("%v-%v", name, _default.Result),
Remark: pulumi.String("default_ons_instance_remark"),
})
if err != nil {
return err
}
_, err = rocketmq.NewTopic(ctx, "default", &rocketmq.TopicArgs{
TopicName: pulumi.String(topic),
InstanceId: defaultInstance.ID(),
MessageType: pulumi.Int(0),
Remark: pulumi.String("dafault_ons_topic_remark"),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;
using Random = Pulumi.Random;
return await Deployment.RunAsync(() =>
{
var config = new Config();
var name = config.Get("name") ?? "onsInstanceName";
var topic = config.Get("topic") ?? "onsTopicName";
var @default = new Random.Index.Integer("default", new()
{
Min = 10000,
Max = 99999,
});
var defaultInstance = new AliCloud.RocketMQ.Instance("default", new()
{
InstanceName = $"{name}-{@default.Result}",
Remark = "default_ons_instance_remark",
});
var defaultTopic = new AliCloud.RocketMQ.Topic("default", new()
{
TopicName = topic,
InstanceId = defaultInstance.Id,
MessageType = 0,
Remark = "dafault_ons_topic_remark",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.random.integer;
import com.pulumi.random.IntegerArgs;
import com.pulumi.alicloud.rocketmq.Instance;
import com.pulumi.alicloud.rocketmq.InstanceArgs;
import com.pulumi.alicloud.rocketmq.Topic;
import com.pulumi.alicloud.rocketmq.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) {
final var config = ctx.config();
final var name = config.get("name").orElse("onsInstanceName");
final var topic = config.get("topic").orElse("onsTopicName");
var default_ = new Integer("default", IntegerArgs.builder()
.min(10000)
.max(99999)
.build());
var defaultInstance = new Instance("defaultInstance", InstanceArgs.builder()
.instanceName(String.format("%s-%s", name,default_.result()))
.remark("default_ons_instance_remark")
.build());
var defaultTopic = new Topic("defaultTopic", TopicArgs.builder()
.topicName(topic)
.instanceId(defaultInstance.id())
.messageType(0)
.remark("dafault_ons_topic_remark")
.build());
}
}
configuration:
name:
type: string
default: onsInstanceName
topic:
type: string
default: onsTopicName
resources:
default:
type: random:integer
properties:
min: 10000
max: 99999
defaultInstance:
type: alicloud:rocketmq:Instance
name: default
properties:
instanceName: ${name}-${default.result}
remark: default_ons_instance_remark
defaultTopic:
type: alicloud:rocketmq:Topic
name: default
properties:
topicName: ${topic}
instanceId: ${defaultInstance.id}
messageType: 0
remark: dafault_ons_topic_remark
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,
instance_id: Optional[str] = None,
message_type: Optional[int] = None,
perm: Optional[int] = None,
remark: Optional[str] = None,
tags: Optional[Mapping[str, str]] = None,
topic: Optional[str] = None,
topic_name: Optional[str] = None)
func NewTopic(ctx *Context, name string, args TopicArgs, opts ...ResourceOption) (*Topic, error)
public Topic(string name, TopicArgs args, CustomResourceOptions? opts = null)
type: alicloud:rocketmq: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 exampletopicResourceResourceFromRocketmqtopic = new AliCloud.RocketMQ.Topic("exampletopicResourceResourceFromRocketmqtopic", new()
{
InstanceId = "string",
MessageType = 0,
Remark = "string",
Tags =
{
{ "string", "string" },
},
TopicName = "string",
});
example, err := rocketmq.NewTopic(ctx, "exampletopicResourceResourceFromRocketmqtopic", &rocketmq.TopicArgs{
InstanceId: pulumi.String("string"),
MessageType: pulumi.Int(0),
Remark: pulumi.String("string"),
Tags: pulumi.StringMap{
"string": pulumi.String("string"),
},
TopicName: pulumi.String("string"),
})
var exampletopicResourceResourceFromRocketmqtopic = new Topic("exampletopicResourceResourceFromRocketmqtopic", TopicArgs.builder()
.instanceId("string")
.messageType(0)
.remark("string")
.tags(Map.of("string", "string"))
.topicName("string")
.build());
exampletopic_resource_resource_from_rocketmqtopic = alicloud.rocketmq.Topic("exampletopicResourceResourceFromRocketmqtopic",
instance_id="string",
message_type=0,
remark="string",
tags={
"string": "string",
},
topic_name="string")
const exampletopicResourceResourceFromRocketmqtopic = new alicloud.rocketmq.Topic("exampletopicResourceResourceFromRocketmqtopic", {
instanceId: "string",
messageType: 0,
remark: "string",
tags: {
string: "string",
},
topicName: "string",
});
type: alicloud:rocketmq:Topic
properties:
instanceId: string
messageType: 0
remark: string
tags:
string: string
topicName: 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:
- Instance
Id string - ID of the ONS Instance that owns the topics.
- Message
Type int - The type of the message. Read Ons Topic Create for further details.
- Perm int
- This attribute has been deprecated.
- Remark string
- This attribute is a concise description of topic. The length cannot exceed 128.
- Dictionary<string, string>
A mapping of tags to assign to the resource.
- Key: It can be up to 64 characters in length. It cannot begin with "aliyun", "acs:", "http://", or "https://". It cannot be a null string.
- Value: It can be up to 128 characters in length. It cannot begin with "aliyun", "acs:", "http://", or "https://". It can be a null string.
NOTE: At least one of
topic_name
andtopic
should be set.- Topic
Deprecated string - Replaced by
topic_name
after version 1.97.0. - Topic
Name string - Name of the topic. Two topics on a single instance cannot have the same name and the name cannot start with 'GID' or 'CID'. The length cannot exceed 64 characters.
- Instance
Id string - ID of the ONS Instance that owns the topics.
- Message
Type int - The type of the message. Read Ons Topic Create for further details.
- Perm int
- This attribute has been deprecated.
- Remark string
- This attribute is a concise description of topic. The length cannot exceed 128.
- map[string]string
A mapping of tags to assign to the resource.
- Key: It can be up to 64 characters in length. It cannot begin with "aliyun", "acs:", "http://", or "https://". It cannot be a null string.
- Value: It can be up to 128 characters in length. It cannot begin with "aliyun", "acs:", "http://", or "https://". It can be a null string.
NOTE: At least one of
topic_name
andtopic
should be set.- Topic string
- Replaced by
topic_name
after version 1.97.0. - Topic
Name string - Name of the topic. Two topics on a single instance cannot have the same name and the name cannot start with 'GID' or 'CID'. The length cannot exceed 64 characters.
- instance
Id String - ID of the ONS Instance that owns the topics.
- message
Type Integer - The type of the message. Read Ons Topic Create for further details.
- perm Integer
- This attribute has been deprecated.
- remark String
- This attribute is a concise description of topic. The length cannot exceed 128.
- Map<String,String>
A mapping of tags to assign to the resource.
- Key: It can be up to 64 characters in length. It cannot begin with "aliyun", "acs:", "http://", or "https://". It cannot be a null string.
- Value: It can be up to 128 characters in length. It cannot begin with "aliyun", "acs:", "http://", or "https://". It can be a null string.
NOTE: At least one of
topic_name
andtopic
should be set.- topic String
- Replaced by
topic_name
after version 1.97.0. - topic
Name String - Name of the topic. Two topics on a single instance cannot have the same name and the name cannot start with 'GID' or 'CID'. The length cannot exceed 64 characters.
- instance
Id string - ID of the ONS Instance that owns the topics.
- message
Type number - The type of the message. Read Ons Topic Create for further details.
- perm number
- This attribute has been deprecated.
- remark string
- This attribute is a concise description of topic. The length cannot exceed 128.
- {[key: string]: string}
A mapping of tags to assign to the resource.
- Key: It can be up to 64 characters in length. It cannot begin with "aliyun", "acs:", "http://", or "https://". It cannot be a null string.
- Value: It can be up to 128 characters in length. It cannot begin with "aliyun", "acs:", "http://", or "https://". It can be a null string.
NOTE: At least one of
topic_name
andtopic
should be set.- topic string
- Replaced by
topic_name
after version 1.97.0. - topic
Name string - Name of the topic. Two topics on a single instance cannot have the same name and the name cannot start with 'GID' or 'CID'. The length cannot exceed 64 characters.
- instance_
id str - ID of the ONS Instance that owns the topics.
- message_
type int - The type of the message. Read Ons Topic Create for further details.
- perm int
- This attribute has been deprecated.
- remark str
- This attribute is a concise description of topic. The length cannot exceed 128.
- Mapping[str, str]
A mapping of tags to assign to the resource.
- Key: It can be up to 64 characters in length. It cannot begin with "aliyun", "acs:", "http://", or "https://". It cannot be a null string.
- Value: It can be up to 128 characters in length. It cannot begin with "aliyun", "acs:", "http://", or "https://". It can be a null string.
NOTE: At least one of
topic_name
andtopic
should be set.- topic str
- Replaced by
topic_name
after version 1.97.0. - topic_
name str - Name of the topic. Two topics on a single instance cannot have the same name and the name cannot start with 'GID' or 'CID'. The length cannot exceed 64 characters.
- instance
Id String - ID of the ONS Instance that owns the topics.
- message
Type Number - The type of the message. Read Ons Topic Create for further details.
- perm Number
- This attribute has been deprecated.
- remark String
- This attribute is a concise description of topic. The length cannot exceed 128.
- Map<String>
A mapping of tags to assign to the resource.
- Key: It can be up to 64 characters in length. It cannot begin with "aliyun", "acs:", "http://", or "https://". It cannot be a null string.
- Value: It can be up to 128 characters in length. It cannot begin with "aliyun", "acs:", "http://", or "https://". It can be a null string.
NOTE: At least one of
topic_name
andtopic
should be set.- topic String
- Replaced by
topic_name
after version 1.97.0. - topic
Name String - Name of the topic. Two topics on a single instance cannot have the same name and the name cannot start with 'GID' or 'CID'. The length cannot exceed 64 characters.
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,
instance_id: Optional[str] = None,
message_type: Optional[int] = None,
perm: Optional[int] = None,
remark: Optional[str] = None,
tags: Optional[Mapping[str, str]] = None,
topic: Optional[str] = None,
topic_name: Optional[str] = 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)
Resource lookup is not supported in YAML
- 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.
- Instance
Id string - ID of the ONS Instance that owns the topics.
- Message
Type int - The type of the message. Read Ons Topic Create for further details.
- Perm int
- This attribute has been deprecated.
- Remark string
- This attribute is a concise description of topic. The length cannot exceed 128.
- Dictionary<string, string>
A mapping of tags to assign to the resource.
- Key: It can be up to 64 characters in length. It cannot begin with "aliyun", "acs:", "http://", or "https://". It cannot be a null string.
- Value: It can be up to 128 characters in length. It cannot begin with "aliyun", "acs:", "http://", or "https://". It can be a null string.
NOTE: At least one of
topic_name
andtopic
should be set.- Topic
Deprecated string - Replaced by
topic_name
after version 1.97.0. - Topic
Name string - Name of the topic. Two topics on a single instance cannot have the same name and the name cannot start with 'GID' or 'CID'. The length cannot exceed 64 characters.
- Instance
Id string - ID of the ONS Instance that owns the topics.
- Message
Type int - The type of the message. Read Ons Topic Create for further details.
- Perm int
- This attribute has been deprecated.
- Remark string
- This attribute is a concise description of topic. The length cannot exceed 128.
- map[string]string
A mapping of tags to assign to the resource.
- Key: It can be up to 64 characters in length. It cannot begin with "aliyun", "acs:", "http://", or "https://". It cannot be a null string.
- Value: It can be up to 128 characters in length. It cannot begin with "aliyun", "acs:", "http://", or "https://". It can be a null string.
NOTE: At least one of
topic_name
andtopic
should be set.- Topic string
- Replaced by
topic_name
after version 1.97.0. - Topic
Name string - Name of the topic. Two topics on a single instance cannot have the same name and the name cannot start with 'GID' or 'CID'. The length cannot exceed 64 characters.
- instance
Id String - ID of the ONS Instance that owns the topics.
- message
Type Integer - The type of the message. Read Ons Topic Create for further details.
- perm Integer
- This attribute has been deprecated.
- remark String
- This attribute is a concise description of topic. The length cannot exceed 128.
- Map<String,String>
A mapping of tags to assign to the resource.
- Key: It can be up to 64 characters in length. It cannot begin with "aliyun", "acs:", "http://", or "https://". It cannot be a null string.
- Value: It can be up to 128 characters in length. It cannot begin with "aliyun", "acs:", "http://", or "https://". It can be a null string.
NOTE: At least one of
topic_name
andtopic
should be set.- topic String
- Replaced by
topic_name
after version 1.97.0. - topic
Name String - Name of the topic. Two topics on a single instance cannot have the same name and the name cannot start with 'GID' or 'CID'. The length cannot exceed 64 characters.
- instance
Id string - ID of the ONS Instance that owns the topics.
- message
Type number - The type of the message. Read Ons Topic Create for further details.
- perm number
- This attribute has been deprecated.
- remark string
- This attribute is a concise description of topic. The length cannot exceed 128.
- {[key: string]: string}
A mapping of tags to assign to the resource.
- Key: It can be up to 64 characters in length. It cannot begin with "aliyun", "acs:", "http://", or "https://". It cannot be a null string.
- Value: It can be up to 128 characters in length. It cannot begin with "aliyun", "acs:", "http://", or "https://". It can be a null string.
NOTE: At least one of
topic_name
andtopic
should be set.- topic string
- Replaced by
topic_name
after version 1.97.0. - topic
Name string - Name of the topic. Two topics on a single instance cannot have the same name and the name cannot start with 'GID' or 'CID'. The length cannot exceed 64 characters.
- instance_
id str - ID of the ONS Instance that owns the topics.
- message_
type int - The type of the message. Read Ons Topic Create for further details.
- perm int
- This attribute has been deprecated.
- remark str
- This attribute is a concise description of topic. The length cannot exceed 128.
- Mapping[str, str]
A mapping of tags to assign to the resource.
- Key: It can be up to 64 characters in length. It cannot begin with "aliyun", "acs:", "http://", or "https://". It cannot be a null string.
- Value: It can be up to 128 characters in length. It cannot begin with "aliyun", "acs:", "http://", or "https://". It can be a null string.
NOTE: At least one of
topic_name
andtopic
should be set.- topic str
- Replaced by
topic_name
after version 1.97.0. - topic_
name str - Name of the topic. Two topics on a single instance cannot have the same name and the name cannot start with 'GID' or 'CID'. The length cannot exceed 64 characters.
- instance
Id String - ID of the ONS Instance that owns the topics.
- message
Type Number - The type of the message. Read Ons Topic Create for further details.
- perm Number
- This attribute has been deprecated.
- remark String
- This attribute is a concise description of topic. The length cannot exceed 128.
- Map<String>
A mapping of tags to assign to the resource.
- Key: It can be up to 64 characters in length. It cannot begin with "aliyun", "acs:", "http://", or "https://". It cannot be a null string.
- Value: It can be up to 128 characters in length. It cannot begin with "aliyun", "acs:", "http://", or "https://". It can be a null string.
NOTE: At least one of
topic_name
andtopic
should be set.- topic String
- Replaced by
topic_name
after version 1.97.0. - topic
Name String - Name of the topic. Two topics on a single instance cannot have the same name and the name cannot start with 'GID' or 'CID'. The length cannot exceed 64 characters.
Import
ONS TOPIC can be imported using the id, e.g.
$ pulumi import alicloud:rocketmq/topic:Topic topic MQ_INST_1234567890_Baso1234567:onsTopicDemo
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- Alibaba Cloud pulumi/pulumi-alicloud
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
alicloud
Terraform Provider.