1. Packages
  2. Alibaba Cloud Provider
  3. API Docs
  4. datahub
  5. Subscription
Alibaba Cloud v3.76.0 published on Tuesday, Apr 8, 2025 by Pulumi

alicloud.datahub.Subscription

Explore with Pulumi AI

The subscription is the basic unit of resource usage in Datahub Service under Publish/Subscribe model. You can manage the relationships between user and topics by using subscriptions. Refer to details.

NOTE: Available since v1.19.0.

Example Usage

Basic Usage

import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";

const config = new pulumi.Config();
const name = config.get("name") || "terraform_example";
const example = new alicloud.datahub.Project("example", {
    name: name,
    comment: "created by terraform",
});
const exampleTopic = new alicloud.datahub.Topic("example", {
    name: name,
    projectName: example.name,
    recordType: "BLOB",
    shardCount: 3,
    lifeCycle: 7,
    comment: "created by terraform",
});
const exampleSubscription = new alicloud.datahub.Subscription("example", {
    projectName: example.name,
    topicName: exampleTopic.name,
    comment: "created by terraform",
});
Copy
import pulumi
import pulumi_alicloud as alicloud

config = pulumi.Config()
name = config.get("name")
if name is None:
    name = "terraform_example"
example = alicloud.datahub.Project("example",
    name=name,
    comment="created by terraform")
example_topic = alicloud.datahub.Topic("example",
    name=name,
    project_name=example.name,
    record_type="BLOB",
    shard_count=3,
    life_cycle=7,
    comment="created by terraform")
example_subscription = alicloud.datahub.Subscription("example",
    project_name=example.name,
    topic_name=example_topic.name,
    comment="created by terraform")
Copy
package main

import (
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/datahub"
	"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 := "terraform_example"
		if param := cfg.Get("name"); param != "" {
			name = param
		}
		example, err := datahub.NewProject(ctx, "example", &datahub.ProjectArgs{
			Name:    pulumi.String(name),
			Comment: pulumi.String("created by terraform"),
		})
		if err != nil {
			return err
		}
		exampleTopic, err := datahub.NewTopic(ctx, "example", &datahub.TopicArgs{
			Name:        pulumi.String(name),
			ProjectName: example.Name,
			RecordType:  pulumi.String("BLOB"),
			ShardCount:  pulumi.Int(3),
			LifeCycle:   pulumi.Int(7),
			Comment:     pulumi.String("created by terraform"),
		})
		if err != nil {
			return err
		}
		_, err = datahub.NewSubscription(ctx, "example", &datahub.SubscriptionArgs{
			ProjectName: example.Name,
			TopicName:   exampleTopic.Name,
			Comment:     pulumi.String("created by terraform"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
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") ?? "terraform_example";
    var example = new AliCloud.Datahub.Project("example", new()
    {
        Name = name,
        Comment = "created by terraform",
    });

    var exampleTopic = new AliCloud.Datahub.Topic("example", new()
    {
        Name = name,
        ProjectName = example.Name,
        RecordType = "BLOB",
        ShardCount = 3,
        LifeCycle = 7,
        Comment = "created by terraform",
    });

    var exampleSubscription = new AliCloud.Datahub.Subscription("example", new()
    {
        ProjectName = example.Name,
        TopicName = exampleTopic.Name,
        Comment = "created by terraform",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.datahub.Project;
import com.pulumi.alicloud.datahub.ProjectArgs;
import com.pulumi.alicloud.datahub.Topic;
import com.pulumi.alicloud.datahub.TopicArgs;
import com.pulumi.alicloud.datahub.Subscription;
import com.pulumi.alicloud.datahub.SubscriptionArgs;
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("terraform_example");
        var example = new Project("example", ProjectArgs.builder()
            .name(name)
            .comment("created by terraform")
            .build());

        var exampleTopic = new Topic("exampleTopic", TopicArgs.builder()
            .name(name)
            .projectName(example.name())
            .recordType("BLOB")
            .shardCount(3)
            .lifeCycle(7)
            .comment("created by terraform")
            .build());

        var exampleSubscription = new Subscription("exampleSubscription", SubscriptionArgs.builder()
            .projectName(example.name())
            .topicName(exampleTopic.name())
            .comment("created by terraform")
            .build());

    }
}
Copy
configuration:
  name:
    type: string
    default: terraform_example
resources:
  example:
    type: alicloud:datahub:Project
    properties:
      name: ${name}
      comment: created by terraform
  exampleTopic:
    type: alicloud:datahub:Topic
    name: example
    properties:
      name: ${name}
      projectName: ${example.name}
      recordType: BLOB
      shardCount: 3
      lifeCycle: 7
      comment: created by terraform
  exampleSubscription:
    type: alicloud:datahub:Subscription
    name: example
    properties:
      projectName: ${example.name}
      topicName: ${exampleTopic.name}
      comment: created by terraform
Copy

Create Subscription Resource

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

Constructor syntax

new Subscription(name: string, args: SubscriptionArgs, opts?: CustomResourceOptions);
@overload
def Subscription(resource_name: str,
                 args: SubscriptionArgs,
                 opts: Optional[ResourceOptions] = None)

@overload
def Subscription(resource_name: str,
                 opts: Optional[ResourceOptions] = None,
                 project_name: Optional[str] = None,
                 topic_name: Optional[str] = None,
                 comment: Optional[str] = None)
func NewSubscription(ctx *Context, name string, args SubscriptionArgs, opts ...ResourceOption) (*Subscription, error)
public Subscription(string name, SubscriptionArgs args, CustomResourceOptions? opts = null)
public Subscription(String name, SubscriptionArgs args)
public Subscription(String name, SubscriptionArgs args, CustomResourceOptions options)
type: alicloud:datahub:Subscription
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. SubscriptionArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. SubscriptionArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. SubscriptionArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. SubscriptionArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. SubscriptionArgs
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 subscriptionResource = new AliCloud.Datahub.Subscription("subscriptionResource", new()
{
    ProjectName = "string",
    TopicName = "string",
    Comment = "string",
});
Copy
example, err := datahub.NewSubscription(ctx, "subscriptionResource", &datahub.SubscriptionArgs{
	ProjectName: pulumi.String("string"),
	TopicName:   pulumi.String("string"),
	Comment:     pulumi.String("string"),
})
Copy
var subscriptionResource = new Subscription("subscriptionResource", SubscriptionArgs.builder()
    .projectName("string")
    .topicName("string")
    .comment("string")
    .build());
Copy
subscription_resource = alicloud.datahub.Subscription("subscriptionResource",
    project_name="string",
    topic_name="string",
    comment="string")
Copy
const subscriptionResource = new alicloud.datahub.Subscription("subscriptionResource", {
    projectName: "string",
    topicName: "string",
    comment: "string",
});
Copy
type: alicloud:datahub:Subscription
properties:
    comment: string
    projectName: string
    topicName: string
Copy

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

ProjectName
This property is required.
Changes to this property will trigger replacement.
string
The name of the datahub project that the subscription belongs to. Its length is limited to 3-32 and only characters such as letters, digits and '_' are allowed. It is case-insensitive.
TopicName
This property is required.
Changes to this property will trigger replacement.
string
The name of the datahub topic that the subscription belongs to. Its length is limited to 1-128 and only characters such as letters, digits and '_' are allowed. It is case-insensitive.
Comment string
Comment of the datahub subscription. It cannot be longer than 255 characters.
ProjectName
This property is required.
Changes to this property will trigger replacement.
string
The name of the datahub project that the subscription belongs to. Its length is limited to 3-32 and only characters such as letters, digits and '_' are allowed. It is case-insensitive.
TopicName
This property is required.
Changes to this property will trigger replacement.
string
The name of the datahub topic that the subscription belongs to. Its length is limited to 1-128 and only characters such as letters, digits and '_' are allowed. It is case-insensitive.
Comment string
Comment of the datahub subscription. It cannot be longer than 255 characters.
projectName
This property is required.
Changes to this property will trigger replacement.
String
The name of the datahub project that the subscription belongs to. Its length is limited to 3-32 and only characters such as letters, digits and '_' are allowed. It is case-insensitive.
topicName
This property is required.
Changes to this property will trigger replacement.
String
The name of the datahub topic that the subscription belongs to. Its length is limited to 1-128 and only characters such as letters, digits and '_' are allowed. It is case-insensitive.
comment String
Comment of the datahub subscription. It cannot be longer than 255 characters.
projectName
This property is required.
Changes to this property will trigger replacement.
string
The name of the datahub project that the subscription belongs to. Its length is limited to 3-32 and only characters such as letters, digits and '_' are allowed. It is case-insensitive.
topicName
This property is required.
Changes to this property will trigger replacement.
string
The name of the datahub topic that the subscription belongs to. Its length is limited to 1-128 and only characters such as letters, digits and '_' are allowed. It is case-insensitive.
comment string
Comment of the datahub subscription. It cannot be longer than 255 characters.
project_name
This property is required.
Changes to this property will trigger replacement.
str
The name of the datahub project that the subscription belongs to. Its length is limited to 3-32 and only characters such as letters, digits and '_' are allowed. It is case-insensitive.
topic_name
This property is required.
Changes to this property will trigger replacement.
str
The name of the datahub topic that the subscription belongs to. Its length is limited to 1-128 and only characters such as letters, digits and '_' are allowed. It is case-insensitive.
comment str
Comment of the datahub subscription. It cannot be longer than 255 characters.
projectName
This property is required.
Changes to this property will trigger replacement.
String
The name of the datahub project that the subscription belongs to. Its length is limited to 3-32 and only characters such as letters, digits and '_' are allowed. It is case-insensitive.
topicName
This property is required.
Changes to this property will trigger replacement.
String
The name of the datahub topic that the subscription belongs to. Its length is limited to 1-128 and only characters such as letters, digits and '_' are allowed. It is case-insensitive.
comment String
Comment of the datahub subscription. It cannot be longer than 255 characters.

Outputs

All input properties are implicitly available as output properties. Additionally, the Subscription resource produces the following output properties:

CreateTime string
Create time of the datahub subscription. It is a human-readable string rather than 64-bits UTC.
Id string
The provider-assigned unique ID for this managed resource.
LastModifyTime string
Last modify time of the datahub subscription. It is the same as create_time at the beginning. It is also a human-readable string rather than 64-bits UTC.
SubId string
The identidy of the subscription, generate from server side.
CreateTime string
Create time of the datahub subscription. It is a human-readable string rather than 64-bits UTC.
Id string
The provider-assigned unique ID for this managed resource.
LastModifyTime string
Last modify time of the datahub subscription. It is the same as create_time at the beginning. It is also a human-readable string rather than 64-bits UTC.
SubId string
The identidy of the subscription, generate from server side.
createTime String
Create time of the datahub subscription. It is a human-readable string rather than 64-bits UTC.
id String
The provider-assigned unique ID for this managed resource.
lastModifyTime String
Last modify time of the datahub subscription. It is the same as create_time at the beginning. It is also a human-readable string rather than 64-bits UTC.
subId String
The identidy of the subscription, generate from server side.
createTime string
Create time of the datahub subscription. It is a human-readable string rather than 64-bits UTC.
id string
The provider-assigned unique ID for this managed resource.
lastModifyTime string
Last modify time of the datahub subscription. It is the same as create_time at the beginning. It is also a human-readable string rather than 64-bits UTC.
subId string
The identidy of the subscription, generate from server side.
create_time str
Create time of the datahub subscription. It is a human-readable string rather than 64-bits UTC.
id str
The provider-assigned unique ID for this managed resource.
last_modify_time str
Last modify time of the datahub subscription. It is the same as create_time at the beginning. It is also a human-readable string rather than 64-bits UTC.
sub_id str
The identidy of the subscription, generate from server side.
createTime String
Create time of the datahub subscription. It is a human-readable string rather than 64-bits UTC.
id String
The provider-assigned unique ID for this managed resource.
lastModifyTime String
Last modify time of the datahub subscription. It is the same as create_time at the beginning. It is also a human-readable string rather than 64-bits UTC.
subId String
The identidy of the subscription, generate from server side.

Look up Existing Subscription Resource

Get an existing Subscription 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?: SubscriptionState, opts?: CustomResourceOptions): Subscription
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        comment: Optional[str] = None,
        create_time: Optional[str] = None,
        last_modify_time: Optional[str] = None,
        project_name: Optional[str] = None,
        sub_id: Optional[str] = None,
        topic_name: Optional[str] = None) -> Subscription
func GetSubscription(ctx *Context, name string, id IDInput, state *SubscriptionState, opts ...ResourceOption) (*Subscription, error)
public static Subscription Get(string name, Input<string> id, SubscriptionState? state, CustomResourceOptions? opts = null)
public static Subscription get(String name, Output<String> id, SubscriptionState state, CustomResourceOptions options)
resources:  _:    type: alicloud:datahub:Subscription    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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:
Comment string
Comment of the datahub subscription. It cannot be longer than 255 characters.
CreateTime string
Create time of the datahub subscription. It is a human-readable string rather than 64-bits UTC.
LastModifyTime string
Last modify time of the datahub subscription. It is the same as create_time at the beginning. It is also a human-readable string rather than 64-bits UTC.
ProjectName Changes to this property will trigger replacement. string
The name of the datahub project that the subscription belongs to. Its length is limited to 3-32 and only characters such as letters, digits and '_' are allowed. It is case-insensitive.
SubId string
The identidy of the subscription, generate from server side.
TopicName Changes to this property will trigger replacement. string
The name of the datahub topic that the subscription belongs to. Its length is limited to 1-128 and only characters such as letters, digits and '_' are allowed. It is case-insensitive.
Comment string
Comment of the datahub subscription. It cannot be longer than 255 characters.
CreateTime string
Create time of the datahub subscription. It is a human-readable string rather than 64-bits UTC.
LastModifyTime string
Last modify time of the datahub subscription. It is the same as create_time at the beginning. It is also a human-readable string rather than 64-bits UTC.
ProjectName Changes to this property will trigger replacement. string
The name of the datahub project that the subscription belongs to. Its length is limited to 3-32 and only characters such as letters, digits and '_' are allowed. It is case-insensitive.
SubId string
The identidy of the subscription, generate from server side.
TopicName Changes to this property will trigger replacement. string
The name of the datahub topic that the subscription belongs to. Its length is limited to 1-128 and only characters such as letters, digits and '_' are allowed. It is case-insensitive.
comment String
Comment of the datahub subscription. It cannot be longer than 255 characters.
createTime String
Create time of the datahub subscription. It is a human-readable string rather than 64-bits UTC.
lastModifyTime String
Last modify time of the datahub subscription. It is the same as create_time at the beginning. It is also a human-readable string rather than 64-bits UTC.
projectName Changes to this property will trigger replacement. String
The name of the datahub project that the subscription belongs to. Its length is limited to 3-32 and only characters such as letters, digits and '_' are allowed. It is case-insensitive.
subId String
The identidy of the subscription, generate from server side.
topicName Changes to this property will trigger replacement. String
The name of the datahub topic that the subscription belongs to. Its length is limited to 1-128 and only characters such as letters, digits and '_' are allowed. It is case-insensitive.
comment string
Comment of the datahub subscription. It cannot be longer than 255 characters.
createTime string
Create time of the datahub subscription. It is a human-readable string rather than 64-bits UTC.
lastModifyTime string
Last modify time of the datahub subscription. It is the same as create_time at the beginning. It is also a human-readable string rather than 64-bits UTC.
projectName Changes to this property will trigger replacement. string
The name of the datahub project that the subscription belongs to. Its length is limited to 3-32 and only characters such as letters, digits and '_' are allowed. It is case-insensitive.
subId string
The identidy of the subscription, generate from server side.
topicName Changes to this property will trigger replacement. string
The name of the datahub topic that the subscription belongs to. Its length is limited to 1-128 and only characters such as letters, digits and '_' are allowed. It is case-insensitive.
comment str
Comment of the datahub subscription. It cannot be longer than 255 characters.
create_time str
Create time of the datahub subscription. It is a human-readable string rather than 64-bits UTC.
last_modify_time str
Last modify time of the datahub subscription. It is the same as create_time at the beginning. It is also a human-readable string rather than 64-bits UTC.
project_name Changes to this property will trigger replacement. str
The name of the datahub project that the subscription belongs to. Its length is limited to 3-32 and only characters such as letters, digits and '_' are allowed. It is case-insensitive.
sub_id str
The identidy of the subscription, generate from server side.
topic_name Changes to this property will trigger replacement. str
The name of the datahub topic that the subscription belongs to. Its length is limited to 1-128 and only characters such as letters, digits and '_' are allowed. It is case-insensitive.
comment String
Comment of the datahub subscription. It cannot be longer than 255 characters.
createTime String
Create time of the datahub subscription. It is a human-readable string rather than 64-bits UTC.
lastModifyTime String
Last modify time of the datahub subscription. It is the same as create_time at the beginning. It is also a human-readable string rather than 64-bits UTC.
projectName Changes to this property will trigger replacement. String
The name of the datahub project that the subscription belongs to. Its length is limited to 3-32 and only characters such as letters, digits and '_' are allowed. It is case-insensitive.
subId String
The identidy of the subscription, generate from server side.
topicName Changes to this property will trigger replacement. String
The name of the datahub topic that the subscription belongs to. Its length is limited to 1-128 and only characters such as letters, digits and '_' are allowed. It is case-insensitive.

Import

Datahub subscription can be imported using the ID, e.g.

$ pulumi import alicloud:datahub/subscription:Subscription example tf_datahub_project:tf_datahub_topic:1539073399567UgCzY
Copy

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.