1. Packages
  2. Alibaba Cloud
  3. API Docs
  4. rocketmq
  5. getTopics
Alibaba Cloud v3.44.0 published on Thursday, Sep 28, 2023 by Pulumi

alicloud.rocketmq.getTopics

Explore with Pulumi AI

alicloud logo
Alibaba Cloud v3.44.0 published on Thursday, Sep 28, 2023 by Pulumi

    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

    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 defaultInstance = new AliCloud.RocketMQ.Instance("defaultInstance", new()
        {
            InstanceName = name,
            Remark = "default_ons_instance_remark",
        });
    
        var defaultTopic = new AliCloud.RocketMQ.Topic("defaultTopic", new()
        {
            TopicName = topic,
            InstanceId = defaultInstance.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 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
    		}
    		defaultInstance, err := rocketmq.NewInstance(ctx, "defaultInstance", &rocketmq.InstanceArgs{
    			InstanceName: pulumi.String(name),
    			Remark:       pulumi.String("default_ons_instance_remark"),
    		})
    		if err != nil {
    			return err
    		}
    		defaultTopic, err := rocketmq.NewTopic(ctx, "defaultTopic", &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
    		}
    		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
    	})
    }
    
    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 defaultInstance = new Instance("defaultInstance", InstanceArgs.builder()        
                .instanceName(name)
                .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());
    
            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())));
        }
    }
    
    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_instance = alicloud.rocketmq.Instance("defaultInstance",
        instance_name=name,
        remark="default_ons_instance_remark")
    default_topic = alicloud.rocketmq.Topic("defaultTopic",
        topic_name=topic,
        instance_id=default_instance.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)
    
    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 defaultInstance = new alicloud.rocketmq.Instance("defaultInstance", {
        instanceName: name,
        remark: "default_ons_instance_remark",
    });
    const defaultTopic = new alicloud.rocketmq.Topic("defaultTopic", {
        topicName: topic,
        instanceId: defaultInstance.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);
    
    configuration:
      name:
        type: string
        default: onsInstanceName
      topic:
        type: string
        default: onsTopicDatasourceName
    resources:
      defaultInstance:
        type: alicloud:rocketmq:Instance
        properties:
          instanceName: ${name}
          remark: default_ons_instance_remark
      defaultTopic:
        type: alicloud:rocketmq:Topic
        properties:
          topicName: ${topic}
          instanceId: ${defaultInstance.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:

    InstanceId string

    ID of the ONS Instance that owns the topics.

    EnableDetails bool
    Ids List<string>

    A list of topic IDs to filter results.

    NameRegex string

    A regex string to filter results by the topic name.

    OutputFile string

    File name where to save data source results (after running pulumi preview).

    Tags Dictionary<string, object>

    A map of tags assigned to the Ons instance.

    InstanceId string

    ID of the ONS Instance that owns the topics.

    EnableDetails bool
    Ids []string

    A list of topic IDs to filter results.

    NameRegex string

    A regex string to filter results by the topic name.

    OutputFile string

    File name where to save data source results (after running pulumi preview).

    Tags map[string]interface{}

    A map of tags assigned to the Ons instance.

    instanceId String

    ID of the ONS Instance that owns the topics.

    enableDetails Boolean
    ids List<String>

    A list of topic IDs to filter results.

    nameRegex String

    A regex string to filter results by the topic name.

    outputFile String

    File name where to save data source results (after running pulumi preview).

    tags Map<String,Object>

    A map of tags assigned to the Ons instance.

    instanceId string

    ID of the ONS Instance that owns the topics.

    enableDetails boolean
    ids string[]

    A list of topic IDs to filter results.

    nameRegex string

    A regex string to filter results by the topic name.

    outputFile string

    File name where to save data source results (after running pulumi preview).

    tags {[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).

    tags Mapping[str, Any]

    A map of tags assigned to the Ons instance.

    instanceId String

    ID of the ONS Instance that owns the topics.

    enableDetails Boolean
    ids List<String>

    A list of topic IDs to filter results.

    nameRegex String

    A regex string to filter results by the topic name.

    outputFile String

    File name where to save data source results (after running pulumi preview).

    tags 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>
    InstanceId string
    Names List<string>

    A list of topic names.

    Topics List<Pulumi.AliCloud.RocketMQ.Outputs.GetTopicsTopic>

    A list of topics. Each element contains the following attributes:

    EnableDetails bool
    NameRegex string
    OutputFile string
    Tags 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
    InstanceId string
    Names []string

    A list of topic names.

    Topics []GetTopicsTopic

    A list of topics. Each element contains the following attributes:

    EnableDetails bool
    NameRegex string
    OutputFile string
    Tags 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>
    instanceId String
    names List<String>

    A list of topic names.

    topics List<GetTopicsTopic>

    A list of topics. Each element contains the following attributes:

    enableDetails Boolean
    nameRegex String
    outputFile String
    tags 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[]
    instanceId string
    names string[]

    A list of topic names.

    topics GetTopicsTopic[]

    A list of topics. Each element contains the following attributes:

    enableDetails boolean
    nameRegex string
    outputFile string
    tags {[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[GetTopicsTopic]

    A list of topics. Each element contains the following attributes:

    enable_details bool
    name_regex str
    output_file str
    tags 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>
    instanceId String
    names List<String>

    A list of topic names.

    topics List<Property Map>

    A list of topics. Each element contains the following attributes:

    enableDetails Boolean
    nameRegex String
    outputFile String
    tags Map<Any>

    A map of tags assigned to the Ons instance.

    Supporting Types

    GetTopicsTopic

    Id string

    The id of the topic.

    IndependentNaming bool

    Indicates whether namespaces are available. Read Fields in PublishInfoDo for further details.

    InstanceId string

    ID of the ONS Instance that owns the topics.

    MessageType 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.

    RelationName string

    The name of the relation, for example, owner, publishable, subscribable, and publishable and subscribable.

    Remark string

    Remark of the topic.

    Tags Dictionary<string, object>

    A map of tags assigned to the Ons instance.

    Topic string

    The name of the topic.

    TopicName string

    The name of the topic.

    Id string

    The id of the topic.

    IndependentNaming bool

    Indicates whether namespaces are available. Read Fields in PublishInfoDo for further details.

    InstanceId string

    ID of the ONS Instance that owns the topics.

    MessageType 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.

    RelationName string

    The name of the relation, for example, owner, publishable, subscribable, and publishable and subscribable.

    Remark string

    Remark of the topic.

    Tags map[string]interface{}

    A map of tags assigned to the Ons instance.

    Topic string

    The name of the topic.

    TopicName string

    The name of the topic.

    id String

    The id of the topic.

    independentNaming Boolean

    Indicates whether namespaces are available. Read Fields in PublishInfoDo for further details.

    instanceId String

    ID of the ONS Instance that owns the topics.

    messageType 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.

    relationName String

    The name of the relation, for example, owner, publishable, subscribable, and publishable and subscribable.

    remark String

    Remark of the topic.

    tags Map<String,Object>

    A map of tags assigned to the Ons instance.

    topic String

    The name of the topic.

    topicName String

    The name of the topic.

    id string

    The id of the topic.

    independentNaming boolean

    Indicates whether namespaces are available. Read Fields in PublishInfoDo for further details.

    instanceId string

    ID of the ONS Instance that owns the topics.

    messageType 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.

    relationName string

    The name of the relation, for example, owner, publishable, subscribable, and publishable and subscribable.

    remark string

    Remark of the topic.

    tags {[key: string]: any}

    A map of tags assigned to the Ons instance.

    topic string

    The name of the topic.

    topicName 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.

    tags 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.

    independentNaming Boolean

    Indicates whether namespaces are available. Read Fields in PublishInfoDo for further details.

    instanceId String

    ID of the ONS Instance that owns the topics.

    messageType 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.

    relationName String

    The name of the relation, for example, owner, publishable, subscribable, and publishable and subscribable.

    remark String

    Remark of the topic.

    tags Map<Any>

    A map of tags assigned to the Ons instance.

    topic String

    The name of the topic.

    topicName 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.

    alicloud logo
    Alibaba Cloud v3.44.0 published on Thursday, Sep 28, 2023 by Pulumi