1. Packages
  2. Tencentcloud Provider
  3. API Docs
  4. MqttTopic
tencentcloud 1.81.189 published on Wednesday, Apr 30, 2025 by tencentcloudstack

tencentcloud.MqttTopic

Explore with Pulumi AI

tencentcloud logo
tencentcloud 1.81.189 published on Wednesday, Apr 30, 2025 by tencentcloudstack

    Provides a resource to create a MQTT topic

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as tencentcloud from "@pulumi/tencentcloud";
    
    const config = new pulumi.Config();
    const availabilityZone = config.get("availabilityZone") || "ap-guangzhou-6";
    // create vpc
    const vpc = new tencentcloud.Vpc("vpc", {cidrBlock: "10.0.0.0/16"});
    // create subnet
    const subnet = new tencentcloud.Subnet("subnet", {
        vpcId: vpc.vpcId,
        availabilityZone: availabilityZone,
        cidrBlock: "10.0.1.0/24",
        isMulticast: false,
    });
    // create mqtt instance
    const exampleMqttInstance = new tencentcloud.MqttInstance("exampleMqttInstance", {
        instanceType: "BASIC",
        skuCode: "basic_2k",
        remark: "remarks.",
        vpcList: {
            vpcId: vpc.vpcId,
            subnetId: subnet.subnetId,
        },
        payMode: 0,
        tags: {
            createBy: "Terraform",
        },
    });
    // create topic
    const exampleMqttTopic = new tencentcloud.MqttTopic("exampleMqttTopic", {
        instanceId: exampleMqttInstance.mqttInstanceId,
        topic: "tf-example",
        remark: "Remark.",
    });
    
    import pulumi
    import pulumi_tencentcloud as tencentcloud
    
    config = pulumi.Config()
    availability_zone = config.get("availabilityZone")
    if availability_zone is None:
        availability_zone = "ap-guangzhou-6"
    # create vpc
    vpc = tencentcloud.Vpc("vpc", cidr_block="10.0.0.0/16")
    # create subnet
    subnet = tencentcloud.Subnet("subnet",
        vpc_id=vpc.vpc_id,
        availability_zone=availability_zone,
        cidr_block="10.0.1.0/24",
        is_multicast=False)
    # create mqtt instance
    example_mqtt_instance = tencentcloud.MqttInstance("exampleMqttInstance",
        instance_type="BASIC",
        sku_code="basic_2k",
        remark="remarks.",
        vpc_list={
            "vpc_id": vpc.vpc_id,
            "subnet_id": subnet.subnet_id,
        },
        pay_mode=0,
        tags={
            "createBy": "Terraform",
        })
    # create topic
    example_mqtt_topic = tencentcloud.MqttTopic("exampleMqttTopic",
        instance_id=example_mqtt_instance.mqtt_instance_id,
        topic="tf-example",
        remark="Remark.")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/tencentcloud/tencentcloud"
    	"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, "")
    		availabilityZone := "ap-guangzhou-6"
    		if param := cfg.Get("availabilityZone"); param != "" {
    			availabilityZone = param
    		}
    		// create vpc
    		vpc, err := tencentcloud.NewVpc(ctx, "vpc", &tencentcloud.VpcArgs{
    			CidrBlock: pulumi.String("10.0.0.0/16"),
    		})
    		if err != nil {
    			return err
    		}
    		// create subnet
    		subnet, err := tencentcloud.NewSubnet(ctx, "subnet", &tencentcloud.SubnetArgs{
    			VpcId:            vpc.VpcId,
    			AvailabilityZone: pulumi.String(availabilityZone),
    			CidrBlock:        pulumi.String("10.0.1.0/24"),
    			IsMulticast:      pulumi.Bool(false),
    		})
    		if err != nil {
    			return err
    		}
    		// create mqtt instance
    		exampleMqttInstance, err := tencentcloud.NewMqttInstance(ctx, "exampleMqttInstance", &tencentcloud.MqttInstanceArgs{
    			InstanceType: pulumi.String("BASIC"),
    			SkuCode:      pulumi.String("basic_2k"),
    			Remark:       pulumi.String("remarks."),
    			VpcList: &tencentcloud.MqttInstanceVpcListArgs{
    				VpcId:    vpc.VpcId,
    				SubnetId: subnet.SubnetId,
    			},
    			PayMode: pulumi.Float64(0),
    			Tags: pulumi.StringMap{
    				"createBy": pulumi.String("Terraform"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		// create topic
    		_, err = tencentcloud.NewMqttTopic(ctx, "exampleMqttTopic", &tencentcloud.MqttTopicArgs{
    			InstanceId: exampleMqttInstance.MqttInstanceId,
    			Topic:      pulumi.String("tf-example"),
    			Remark:     pulumi.String("Remark."),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Tencentcloud = Pulumi.Tencentcloud;
    
    return await Deployment.RunAsync(() => 
    {
        var config = new Config();
        var availabilityZone = config.Get("availabilityZone") ?? "ap-guangzhou-6";
        // create vpc
        var vpc = new Tencentcloud.Vpc("vpc", new()
        {
            CidrBlock = "10.0.0.0/16",
        });
    
        // create subnet
        var subnet = new Tencentcloud.Subnet("subnet", new()
        {
            VpcId = vpc.VpcId,
            AvailabilityZone = availabilityZone,
            CidrBlock = "10.0.1.0/24",
            IsMulticast = false,
        });
    
        // create mqtt instance
        var exampleMqttInstance = new Tencentcloud.MqttInstance("exampleMqttInstance", new()
        {
            InstanceType = "BASIC",
            SkuCode = "basic_2k",
            Remark = "remarks.",
            VpcList = new Tencentcloud.Inputs.MqttInstanceVpcListArgs
            {
                VpcId = vpc.VpcId,
                SubnetId = subnet.SubnetId,
            },
            PayMode = 0,
            Tags = 
            {
                { "createBy", "Terraform" },
            },
        });
    
        // create topic
        var exampleMqttTopic = new Tencentcloud.MqttTopic("exampleMqttTopic", new()
        {
            InstanceId = exampleMqttInstance.MqttInstanceId,
            Topic = "tf-example",
            Remark = "Remark.",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.tencentcloud.Vpc;
    import com.pulumi.tencentcloud.VpcArgs;
    import com.pulumi.tencentcloud.Subnet;
    import com.pulumi.tencentcloud.SubnetArgs;
    import com.pulumi.tencentcloud.MqttInstance;
    import com.pulumi.tencentcloud.MqttInstanceArgs;
    import com.pulumi.tencentcloud.inputs.MqttInstanceVpcListArgs;
    import com.pulumi.tencentcloud.MqttTopic;
    import com.pulumi.tencentcloud.MqttTopicArgs;
    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 availabilityZone = config.get("availabilityZone").orElse("ap-guangzhou-6");
            // create vpc
            var vpc = new Vpc("vpc", VpcArgs.builder()
                .cidrBlock("10.0.0.0/16")
                .build());
    
            // create subnet
            var subnet = new Subnet("subnet", SubnetArgs.builder()
                .vpcId(vpc.vpcId())
                .availabilityZone(availabilityZone)
                .cidrBlock("10.0.1.0/24")
                .isMulticast(false)
                .build());
    
            // create mqtt instance
            var exampleMqttInstance = new MqttInstance("exampleMqttInstance", MqttInstanceArgs.builder()
                .instanceType("BASIC")
                .skuCode("basic_2k")
                .remark("remarks.")
                .vpcList(MqttInstanceVpcListArgs.builder()
                    .vpcId(vpc.vpcId())
                    .subnetId(subnet.subnetId())
                    .build())
                .payMode(0)
                .tags(Map.of("createBy", "Terraform"))
                .build());
    
            // create topic
            var exampleMqttTopic = new MqttTopic("exampleMqttTopic", MqttTopicArgs.builder()
                .instanceId(exampleMqttInstance.mqttInstanceId())
                .topic("tf-example")
                .remark("Remark.")
                .build());
    
        }
    }
    
    configuration:
      availabilityZone:
        type: string
        default: ap-guangzhou-6
    resources:
      # create vpc
      vpc:
        type: tencentcloud:Vpc
        properties:
          cidrBlock: 10.0.0.0/16
      # create subnet
      subnet:
        type: tencentcloud:Subnet
        properties:
          vpcId: ${vpc.vpcId}
          availabilityZone: ${availabilityZone}
          cidrBlock: 10.0.1.0/24
          isMulticast: false
      # create mqtt instance
      exampleMqttInstance:
        type: tencentcloud:MqttInstance
        properties:
          instanceType: BASIC
          skuCode: basic_2k
          remark: remarks.
          vpcList:
            vpcId: ${vpc.vpcId}
            subnetId: ${subnet.subnetId}
          payMode: 0
          tags:
            createBy: Terraform
      # create topic
      exampleMqttTopic:
        type: tencentcloud:MqttTopic
        properties:
          instanceId: ${exampleMqttInstance.mqttInstanceId}
          topic: tf-example
          remark: Remark.
    

    Create MqttTopic Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new MqttTopic(name: string, args: MqttTopicArgs, opts?: CustomResourceOptions);
    @overload
    def MqttTopic(resource_name: str,
                  args: MqttTopicArgs,
                  opts: Optional[ResourceOptions] = None)
    
    @overload
    def MqttTopic(resource_name: str,
                  opts: Optional[ResourceOptions] = None,
                  instance_id: Optional[str] = None,
                  topic: Optional[str] = None,
                  mqtt_topic_id: Optional[str] = None,
                  remark: Optional[str] = None)
    func NewMqttTopic(ctx *Context, name string, args MqttTopicArgs, opts ...ResourceOption) (*MqttTopic, error)
    public MqttTopic(string name, MqttTopicArgs args, CustomResourceOptions? opts = null)
    public MqttTopic(String name, MqttTopicArgs args)
    public MqttTopic(String name, MqttTopicArgs args, CustomResourceOptions options)
    
    type: tencentcloud:MqttTopic
    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 MqttTopicArgs
    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 MqttTopicArgs
    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 MqttTopicArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args MqttTopicArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args MqttTopicArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    MqttTopic 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 MqttTopic resource accepts the following input properties:

    InstanceId string
    MQTT instance ID.
    Topic string
    Topic.
    MqttTopicId string
    ID of the resource.
    Remark string
    Remarks.
    InstanceId string
    MQTT instance ID.
    Topic string
    Topic.
    MqttTopicId string
    ID of the resource.
    Remark string
    Remarks.
    instanceId String
    MQTT instance ID.
    topic String
    Topic.
    mqttTopicId String
    ID of the resource.
    remark String
    Remarks.
    instanceId string
    MQTT instance ID.
    topic string
    Topic.
    mqttTopicId string
    ID of the resource.
    remark string
    Remarks.
    instance_id str
    MQTT instance ID.
    topic str
    Topic.
    mqtt_topic_id str
    ID of the resource.
    remark str
    Remarks.
    instanceId String
    MQTT instance ID.
    topic String
    Topic.
    mqttTopicId String
    ID of the resource.
    remark String
    Remarks.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the MqttTopic 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 MqttTopic Resource

    Get an existing MqttTopic 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?: MqttTopicState, opts?: CustomResourceOptions): MqttTopic
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            instance_id: Optional[str] = None,
            mqtt_topic_id: Optional[str] = None,
            remark: Optional[str] = None,
            topic: Optional[str] = None) -> MqttTopic
    func GetMqttTopic(ctx *Context, name string, id IDInput, state *MqttTopicState, opts ...ResourceOption) (*MqttTopic, error)
    public static MqttTopic Get(string name, Input<string> id, MqttTopicState? state, CustomResourceOptions? opts = null)
    public static MqttTopic get(String name, Output<String> id, MqttTopicState state, CustomResourceOptions options)
    resources:  _:    type: tencentcloud:MqttTopic    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.
    The following state arguments are supported:
    InstanceId string
    MQTT instance ID.
    MqttTopicId string
    ID of the resource.
    Remark string
    Remarks.
    Topic string
    Topic.
    InstanceId string
    MQTT instance ID.
    MqttTopicId string
    ID of the resource.
    Remark string
    Remarks.
    Topic string
    Topic.
    instanceId String
    MQTT instance ID.
    mqttTopicId String
    ID of the resource.
    remark String
    Remarks.
    topic String
    Topic.
    instanceId string
    MQTT instance ID.
    mqttTopicId string
    ID of the resource.
    remark string
    Remarks.
    topic string
    Topic.
    instance_id str
    MQTT instance ID.
    mqtt_topic_id str
    ID of the resource.
    remark str
    Remarks.
    topic str
    Topic.
    instanceId String
    MQTT instance ID.
    mqttTopicId String
    ID of the resource.
    remark String
    Remarks.
    topic String
    Topic.

    Import

    MQTT topic can be imported using the id, e.g.

    $ pulumi import tencentcloud:index/mqttTopic:MqttTopic example mqtt-emb2v5wk#tf-example
    

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    tencentcloud tencentcloudstack/terraform-provider-tencentcloud
    License
    Notes
    This Pulumi package is based on the tencentcloud Terraform Provider.
    tencentcloud logo
    tencentcloud 1.81.189 published on Wednesday, Apr 30, 2025 by tencentcloudstack