ALIYUN::KAFKA::Topic类型用于创建Topic。

语法

{
  "Type": "ALIYUN::KAFKA::Topic",
  "Properties": {
    "InstanceId": String,
    "Topic": String,
    "Remark": String,
    "PartitionNum": Integer
  }
}

属性

属性名称 类型 必须 允许更新 描述 约束
InstanceId String 实例ID
Topic String Topic名称 长度为3~64个字符(多于64个字符将被自动截取),可包含字母、数字、下划线(_)和短横线(-)。
说明 Topic名称一旦创建,将无法修改。
Remark String Topic备注信息 长度为3~64个字符,可包含字母、数字、下划线(_)、短横线(-)。
PartitionNum Integer Topic分区数 取值:1 ~ 48。

建议分区数取值为6的倍数,减少数据倾斜风险。

返回值

Fn::GetAtt

  • InstanceId:实例ID。
  • Topic:Topic的名称。

示例

JSON格式

{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Resources": {
    "Topic": {
      "Type": "ALIYUN::KAFKA::Topic",
      "Properties": {
        "InstanceId": {
          "Ref": "InstanceId"
        },
        "Topic": {
          "Ref": "Topic"
        },
        "Remark": {
          "Ref": "Remark"
        },
        "PartitionNum": {
          "Ref": "PartitionNum"
        }
      }
    }
  },
  "Parameters": {
    "InstanceId": {
      "Type": "String",
      "Description": "The ID of the Message Queue for Apache Kafka instance where the topic is located.\nYou can call the GetInstanceList operation to query instances."
    },
    "Topic": {
      "Type": "String",
      "Description": "The name of the topic. The value of this parameter must meet the following requirements:\nThe name can only contain letters, digits, hyphens (-), and underscores (_).\nThe name must be 3 to 64 characters in length, and will be automatically truncated\nif it contains more characters.\nThe name cannot be modified after being created."
    },
    "Remark": {
      "Type": "String",
      "Description": "The description of the topic. The value of this parameter must meet the following\nrequirements:\nThe value can only contain letters, digits, hyphens (-), and underscores (_).\nThe value must be 3 to 64 characters in length."
    },
    "PartitionNum": {
      "Type": "Number",
      "Description": "The number of partitions in the topic. Valid values:\n1 to 48\nWe recommend that you set the number of partitions to a multiple of 6 to reduce the\nrisk of data skew.Note:For special requirements,submit a ticket."
    }
  },
  "Outputs": {
    "InstanceId": {
      "Description": "The ID of the Message Queue for Apache Kafka instance where the topic is located.\nYou can call the GetInstanceList operation to query instances.",
      "Value": {
        "Fn::GetAtt": [
          "Topic",
          "InstanceId"
        ]
      }
    },
    "Topic": {
      "Description": "Topic name.",
      "Value": {
        "Fn::GetAtt": [
          "Topic",
          "Topic"
        ]
      }
    }
  }
}

YAML格式

ROSTemplateFormatVersion: '2015-09-01'
Resources:
  Topic:
    Type: 'ALIYUN::KAFKA::Topic'
    Properties:
      InstanceId:
        Ref: InstanceId
      Topic:
        Ref: Topic
      Remark:
        Ref: Remark
      PartitionNum:
        Ref: PartitionNum
Parameters:
  InstanceId:
    Type: String
    Description: >-
      The ID of the Message Queue for Apache Kafka instance where the topic is
      located.

      You can call the GetInstanceList operation to query instances.
  Topic:
    Type: String
    Description: >-
      The name of the topic. The value of this parameter must meet the following
      requirements:

      The name can only contain letters, digits, hyphens (-), and underscores
      (_).

      The name must be 3 to 64 characters in length, and will be automatically
      truncated

      if it contains more characters.

      The name cannot be modified after being created.
  Remark:
    Type: String
    Description: >-
      The description of the topic. The value of this parameter must meet the
      following

      requirements:

      The value can only contain letters, digits, hyphens (-), and underscores
      (_).

      The value must be 3 to 64 characters in length.
  PartitionNum:
    Type: Number
    Description: >-
      The number of partitions in the topic. Valid values:

      1 to 48

      We recommend that you set the number of partitions to a multiple of 6 to
      reduce the

      risk of data skew.Note:For special requirements,submit a ticket.
Outputs:
  InstanceId:
    Description: >-
      The ID of the Message Queue for Apache Kafka instance where the topic is
      located.

      You can call the GetInstanceList operation to query instances.
    Value:
      'Fn::GetAtt':
        - Topic
        - InstanceId
  Topic:
    Description: Topic name.
    Value:
      'Fn::GetAtt':
        - Topic
        - Topic