Alibaba Cloud v3.57.1 published on Wednesday, Jun 26, 2024 by Pulumi
alicloud.rocketmq.getTopics
Explore with Pulumi AI
This data source provides a list of ONS Topics in an Alibaba Cloud account according to the specified filters.
NOTE: Available in 1.53.0+
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";
const config = new pulumi.Config();
const name = config.get("name") || "onsInstanceName";
const topic = config.get("topic") || "onsTopicDatasourceName";
const _default = new alicloud.rocketmq.Instance("default", {
instanceName: name,
remark: "default_ons_instance_remark",
});
const defaultTopic = new alicloud.rocketmq.Topic("default", {
topicName: topic,
instanceId: _default.id,
messageType: 0,
remark: "dafault_ons_topic_remark",
});
const topicsDs = alicloud.rocketmq.getTopicsOutput({
instanceId: defaultTopic.instanceId,
nameRegex: topic,
outputFile: "topics.txt",
});
export const firstTopicName = topicsDs.apply(topicsDs => topicsDs.topics?.[0]?.topicName);
import pulumi
import pulumi_alicloud as alicloud
config = pulumi.Config()
name = config.get("name")
if name is None:
name = "onsInstanceName"
topic = config.get("topic")
if topic is None:
topic = "onsTopicDatasourceName"
default = alicloud.rocketmq.Instance("default",
instance_name=name,
remark="default_ons_instance_remark")
default_topic = alicloud.rocketmq.Topic("default",
topic_name=topic,
instance_id=default.id,
message_type=0,
remark="dafault_ons_topic_remark")
topics_ds = alicloud.rocketmq.get_topics_output(instance_id=default_topic.instance_id,
name_regex=topic,
output_file="topics.txt")
pulumi.export("firstTopicName", topics_ds.topics[0].topic_name)
package main
import (
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/rocketmq"
"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 := "onsTopicDatasourceName"
if param := cfg.Get("topic"); param != "" {
topic = param
}
_, err := rocketmq.NewInstance(ctx, "default", &rocketmq.InstanceArgs{
InstanceName: pulumi.String(name),
Remark: pulumi.String("default_ons_instance_remark"),
})
if err != nil {
return err
}
defaultTopic, err := rocketmq.NewTopic(ctx, "default", &rocketmq.TopicArgs{
TopicName: pulumi.String(topic),
InstanceId: _default.ID(),
MessageType: pulumi.Int(0),
Remark: pulumi.String("dafault_ons_topic_remark"),
})
if err != nil {
return err
}
topicsDs := rocketmq.GetTopicsOutput(ctx, rocketmq.GetTopicsOutputArgs{
InstanceId: defaultTopic.InstanceId,
NameRegex: pulumi.String(topic),
OutputFile: pulumi.String("topics.txt"),
}, nil)
ctx.Export("firstTopicName", topicsDs.ApplyT(func(topicsDs rocketmq.GetTopicsResult) (*string, error) {
return &topicsDs.Topics[0].TopicName, nil
}).(pulumi.StringPtrOutput))
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;
return await Deployment.RunAsync(() =>
{
var config = new Config();
var name = config.Get("name") ?? "onsInstanceName";
var topic = config.Get("topic") ?? "onsTopicDatasourceName";
var @default = new AliCloud.RocketMQ.Instance("default", new()
{
InstanceName = name,
Remark = "default_ons_instance_remark",
});
var defaultTopic = new AliCloud.RocketMQ.Topic("default", new()
{
TopicName = topic,
InstanceId = @default.Id,
MessageType = 0,
Remark = "dafault_ons_topic_remark",
});
var topicsDs = AliCloud.RocketMQ.GetTopics.Invoke(new()
{
InstanceId = defaultTopic.InstanceId,
NameRegex = topic,
OutputFile = "topics.txt",
});
return new Dictionary<string, object?>
{
["firstTopicName"] = topicsDs.Apply(getTopicsResult => getTopicsResult.Topics[0]?.TopicName),
};
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
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 com.pulumi.alicloud.rocketmq.RocketmqFunctions;
import com.pulumi.alicloud.rocketmq.inputs.GetTopicsArgs;
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("onsTopicDatasourceName");
var default_ = new Instance("default", InstanceArgs.builder()
.instanceName(name)
.remark("default_ons_instance_remark")
.build());
var defaultTopic = new Topic("defaultTopic", TopicArgs.builder()
.topicName(topic)
.instanceId(default_.id())
.messageType(0)
.remark("dafault_ons_topic_remark")
.build());
final var topicsDs = RocketmqFunctions.getTopics(GetTopicsArgs.builder()
.instanceId(defaultTopic.instanceId())
.nameRegex(topic)
.outputFile("topics.txt")
.build());
ctx.export("firstTopicName", topicsDs.applyValue(getTopicsResult -> getTopicsResult).applyValue(topicsDs -> topicsDs.applyValue(getTopicsResult -> getTopicsResult.topics()[0].topicName())));
}
}
configuration:
name:
type: string
default: onsInstanceName
topic:
type: string
default: onsTopicDatasourceName
resources:
default:
type: alicloud:rocketmq:Instance
properties:
instanceName: ${name}
remark: default_ons_instance_remark
defaultTopic:
type: alicloud:rocketmq:Topic
name: default
properties:
topicName: ${topic}
instanceId: ${default.id}
messageType: 0
remark: dafault_ons_topic_remark
variables:
topicsDs:
fn::invoke:
Function: alicloud:rocketmq:getTopics
Arguments:
instanceId: ${defaultTopic.instanceId}
nameRegex: ${topic}
outputFile: topics.txt
outputs:
firstTopicName: ${topicsDs.topics[0].topicName}
Using getTopics
Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.
function getTopics(args: GetTopicsArgs, opts?: InvokeOptions): Promise<GetTopicsResult>
function getTopicsOutput(args: GetTopicsOutputArgs, opts?: InvokeOptions): Output<GetTopicsResult>
def get_topics(enable_details: Optional[bool] = None,
ids: Optional[Sequence[str]] = None,
instance_id: Optional[str] = None,
name_regex: Optional[str] = None,
output_file: Optional[str] = None,
tags: Optional[Mapping[str, Any]] = None,
opts: Optional[InvokeOptions] = None) -> GetTopicsResult
def get_topics_output(enable_details: Optional[pulumi.Input[bool]] = None,
ids: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
instance_id: Optional[pulumi.Input[str]] = None,
name_regex: Optional[pulumi.Input[str]] = None,
output_file: Optional[pulumi.Input[str]] = None,
tags: Optional[pulumi.Input[Mapping[str, Any]]] = None,
opts: Optional[InvokeOptions] = None) -> Output[GetTopicsResult]
func GetTopics(ctx *Context, args *GetTopicsArgs, opts ...InvokeOption) (*GetTopicsResult, error)
func GetTopicsOutput(ctx *Context, args *GetTopicsOutputArgs, opts ...InvokeOption) GetTopicsResultOutput
> Note: This function is named GetTopics
in the Go SDK.
public static class GetTopics
{
public static Task<GetTopicsResult> InvokeAsync(GetTopicsArgs args, InvokeOptions? opts = null)
public static Output<GetTopicsResult> Invoke(GetTopicsInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetTopicsResult> getTopics(GetTopicsArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
fn::invoke:
function: alicloud:rocketmq/getTopics:getTopics
arguments:
# arguments dictionary
The following arguments are supported:
- Instance
Id string - ID of the ONS Instance that owns the topics.
- Enable
Details bool - Ids List<string>
- A list of topic IDs to filter results.
- Name
Regex string - A regex string to filter results by the topic name.
- Output
File string - File name where to save data source results (after running
pulumi preview
). - Dictionary<string, object>
- A map of tags assigned to the Ons instance.
- Instance
Id string - ID of the ONS Instance that owns the topics.
- Enable
Details bool - Ids []string
- A list of topic IDs to filter results.
- Name
Regex string - A regex string to filter results by the topic name.
- Output
File string - File name where to save data source results (after running
pulumi preview
). - map[string]interface{}
- A map of tags assigned to the Ons instance.
- instance
Id String - ID of the ONS Instance that owns the topics.
- enable
Details Boolean - ids List<String>
- A list of topic IDs to filter results.
- name
Regex String - A regex string to filter results by the topic name.
- output
File String - File name where to save data source results (after running
pulumi preview
). - Map<String,Object>
- A map of tags assigned to the Ons instance.
- instance
Id string - ID of the ONS Instance that owns the topics.
- enable
Details boolean - ids string[]
- A list of topic IDs to filter results.
- name
Regex string - A regex string to filter results by the topic name.
- output
File string - File name where to save data source results (after running
pulumi preview
). - {[key: string]: any}
- A map of tags assigned to the Ons instance.
- instance_
id str - ID of the ONS Instance that owns the topics.
- enable_
details bool - ids Sequence[str]
- A list of topic IDs to filter results.
- name_
regex str - A regex string to filter results by the topic name.
- output_
file str - File name where to save data source results (after running
pulumi preview
). - Mapping[str, Any]
- A map of tags assigned to the Ons instance.
- instance
Id String - ID of the ONS Instance that owns the topics.
- enable
Details Boolean - ids List<String>
- A list of topic IDs to filter results.
- name
Regex String - A regex string to filter results by the topic name.
- output
File String - File name where to save data source results (after running
pulumi preview
). - Map<Any>
- A map of tags assigned to the Ons instance.
getTopics Result
The following output properties are available:
- Id string
- The provider-assigned unique ID for this managed resource.
- Ids List<string>
- Instance
Id string - Names List<string>
- A list of topic names.
- Topics
List<Pulumi.
Ali Cloud. Rocket MQ. Outputs. Get Topics Topic> - A list of topics. Each element contains the following attributes:
- Enable
Details bool - Name
Regex string - Output
File string - Dictionary<string, object>
- A map of tags assigned to the Ons instance.
- Id string
- The provider-assigned unique ID for this managed resource.
- Ids []string
- Instance
Id string - Names []string
- A list of topic names.
- Topics
[]Get
Topics Topic - A list of topics. Each element contains the following attributes:
- Enable
Details bool - Name
Regex string - Output
File string - map[string]interface{}
- A map of tags assigned to the Ons instance.
- id String
- The provider-assigned unique ID for this managed resource.
- ids List<String>
- instance
Id String - names List<String>
- A list of topic names.
- topics
List<Get
Topics Topic> - A list of topics. Each element contains the following attributes:
- enable
Details Boolean - name
Regex String - output
File String - Map<String,Object>
- A map of tags assigned to the Ons instance.
- id string
- The provider-assigned unique ID for this managed resource.
- ids string[]
- instance
Id string - names string[]
- A list of topic names.
- topics
Get
Topics Topic[] - A list of topics. Each element contains the following attributes:
- enable
Details boolean - name
Regex string - output
File string - {[key: string]: any}
- A map of tags assigned to the Ons instance.
- id str
- The provider-assigned unique ID for this managed resource.
- ids Sequence[str]
- instance_
id str - names Sequence[str]
- A list of topic names.
- topics
Sequence[Get
Topics Topic] - A list of topics. Each element contains the following attributes:
- enable_
details bool - name_
regex str - output_
file str - Mapping[str, Any]
- A map of tags assigned to the Ons instance.
- id String
- The provider-assigned unique ID for this managed resource.
- ids List<String>
- instance
Id String - names List<String>
- A list of topic names.
- topics List<Property Map>
- A list of topics. Each element contains the following attributes:
- enable
Details Boolean - name
Regex String - output
File String - Map<Any>
- A map of tags assigned to the Ons instance.
Supporting Types
GetTopicsTopic
- Id string
- The id of the topic.
- Independent
Naming bool - Indicates whether namespaces are available. Read Fields in PublishInfoDo for further details.
- Instance
Id string - ID of the ONS Instance that owns the topics.
- Message
Type int - The type of the message. Read Fields in PublishInfoDo for further details.
- Owner string
- The ID of the topic owner, which is the Alibaba Cloud UID.
- Perm int
- This attribute is used to set the read-write mode for the topic.
- Relation int
- The relation ID. Read Fields in PublishInfoDo for further details.
- Relation
Name string - The name of the relation, for example, owner, publishable, subscribable, and publishable and subscribable.
- Remark string
- Remark of the topic.
- Dictionary<string, object>
- A map of tags assigned to the Ons instance.
- Topic string
- The name of the topic.
- Topic
Name string - The name of the topic.
- Id string
- The id of the topic.
- Independent
Naming bool - Indicates whether namespaces are available. Read Fields in PublishInfoDo for further details.
- Instance
Id string - ID of the ONS Instance that owns the topics.
- Message
Type int - The type of the message. Read Fields in PublishInfoDo for further details.
- Owner string
- The ID of the topic owner, which is the Alibaba Cloud UID.
- Perm int
- This attribute is used to set the read-write mode for the topic.
- Relation int
- The relation ID. Read Fields in PublishInfoDo for further details.
- Relation
Name string - The name of the relation, for example, owner, publishable, subscribable, and publishable and subscribable.
- Remark string
- Remark of the topic.
- map[string]interface{}
- A map of tags assigned to the Ons instance.
- Topic string
- The name of the topic.
- Topic
Name string - The name of the topic.
- id String
- The id of the topic.
- independent
Naming Boolean - Indicates whether namespaces are available. Read Fields in PublishInfoDo for further details.
- instance
Id String - ID of the ONS Instance that owns the topics.
- message
Type Integer - The type of the message. Read Fields in PublishInfoDo for further details.
- owner String
- The ID of the topic owner, which is the Alibaba Cloud UID.
- perm Integer
- This attribute is used to set the read-write mode for the topic.
- relation Integer
- The relation ID. Read Fields in PublishInfoDo for further details.
- relation
Name String - The name of the relation, for example, owner, publishable, subscribable, and publishable and subscribable.
- remark String
- Remark of the topic.
- Map<String,Object>
- A map of tags assigned to the Ons instance.
- topic String
- The name of the topic.
- topic
Name String - The name of the topic.
- id string
- The id of the topic.
- independent
Naming boolean - Indicates whether namespaces are available. Read Fields in PublishInfoDo for further details.
- instance
Id string - ID of the ONS Instance that owns the topics.
- message
Type number - The type of the message. Read Fields in PublishInfoDo for further details.
- owner string
- The ID of the topic owner, which is the Alibaba Cloud UID.
- perm number
- This attribute is used to set the read-write mode for the topic.
- relation number
- The relation ID. Read Fields in PublishInfoDo for further details.
- relation
Name string - The name of the relation, for example, owner, publishable, subscribable, and publishable and subscribable.
- remark string
- Remark of the topic.
- {[key: string]: any}
- A map of tags assigned to the Ons instance.
- topic string
- The name of the topic.
- topic
Name string - The name of the topic.
- id str
- The id of the topic.
- independent_
naming bool - Indicates whether namespaces are available. Read Fields in PublishInfoDo for further details.
- instance_
id str - ID of the ONS Instance that owns the topics.
- message_
type int - The type of the message. Read Fields in PublishInfoDo for further details.
- owner str
- The ID of the topic owner, which is the Alibaba Cloud UID.
- perm int
- This attribute is used to set the read-write mode for the topic.
- relation int
- The relation ID. Read Fields in PublishInfoDo for further details.
- relation_
name str - The name of the relation, for example, owner, publishable, subscribable, and publishable and subscribable.
- remark str
- Remark of the topic.
- Mapping[str, Any]
- A map of tags assigned to the Ons instance.
- topic str
- The name of the topic.
- topic_
name str - The name of the topic.
- id String
- The id of the topic.
- independent
Naming Boolean - Indicates whether namespaces are available. Read Fields in PublishInfoDo for further details.
- instance
Id String - ID of the ONS Instance that owns the topics.
- message
Type Number - The type of the message. Read Fields in PublishInfoDo for further details.
- owner String
- The ID of the topic owner, which is the Alibaba Cloud UID.
- perm Number
- This attribute is used to set the read-write mode for the topic.
- relation Number
- The relation ID. Read Fields in PublishInfoDo for further details.
- relation
Name String - The name of the relation, for example, owner, publishable, subscribable, and publishable and subscribable.
- remark String
- Remark of the topic.
- Map<Any>
- A map of tags assigned to the Ons instance.
- topic String
- The name of the topic.
- topic
Name String - The name of the topic.
Package Details
- Repository
- Alibaba Cloud pulumi/pulumi-alicloud
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
alicloud
Terraform Provider.