ALIYUN::KAFKA::Topic类型用于创建Topic。
语法
{
  "Type": "ALIYUN::KAFKA::Topic",
  "Properties": {
    "InstanceId": String,
    "Topic": String,
    "Remark": String,
    "PartitionNum": Integer,
    "ReplicationFactor": Integer,
    "LocalTopic": Boolean,
    "CompactTopic": Boolean,
    "Config": Map,
    "MinInsyncReplicas": Integer,
    "Tags": List
  }
}属性
| 属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 | 
| InstanceId | String | 是 | 否 | 实例ID。 | 无 | 
| Topic | String | 是 | 否 | Topic的名称。 | 长度为3~64个字符,可包含英文字母、数字、下划线(_)和短划线(-)。 说明  Topic名称一旦创建,将无法修改。 | 
| Remark | String | 是 | 否 | Topic的备注信息。 | 长度为3~64个字符,可包含英文字母、数字、下划线(_)和短划线(-)。 | 
| PartitionNum | Integer | 否 | 否 | Topic的分区数。 | 取值范围:1~48。 建议分区数取值为6的倍数,减少数据倾斜风险。 | 
| ReplicationFactor | Integer | 否 | 否 | Topic的副本数。 | 当LocalTopic取值为true时,该参数有效。 取值范围:1~3。 说明  副本数为1时,有数据丢失的风险,请谨慎设置。 | 
| LocalTopic | Boolean | 否 | 否 | Topic的存储引擎。 | 取值: 
 | 
| CompactTopic | Boolean | 否 | 否 | 日志清理策略。 | 当LocalTopic取值为true时,该参数有效。 取值: 
 | 
| Config | Map | 否 | 否 | 补充配置。 | 当LocalTopic取值为true时,该参数有效。 取值示例: | 
| MinInsyncReplicas | Integer | 否 | 否 | 最小ISR同步副本数。 | 当LocalTopic取值为true时,该参数有效。 取值范围:1~3,取值需小于Topic副本数。 | 
| Tags | List | 否 | 是 | 标签。 | 更多信息,请参见Tags属性。 | 
Tags语法
"Tags": [
  {
    "Key": String,
    "Value": String
  }
]  Tags属性
| 属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 | 
| Key | String | 是 | 否 | 标签键。 | 长度为1~128个字符,不能以 | 
| Value | String | 否 | 否 | 标签值。 | 长度为1~128个字符,不能以 | 
返回值
Fn::GetAtt
- InstanceId:实例ID。 
- Topic:Topic的名称。 
- Arn:阿里云资源名称。 
示例
ROSTemplateFormatVersion: '2015-09-01'
Description: Test create Kafka Topic
Parameters:
  InstanceId:
    Type: String
    Description: Kafka Instance Id
    Default: alikafka_****
  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.
    Default: myTopic
  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.
    Default: test
Resources:
  Topic:
    Type: ALIYUN::KAFKA::Topic
    Properties:
      InstanceId:
        Ref: InstanceId
      Topic:
        Ref: TopicName
      Remark:
        Ref: Remark
Outputs:
  TopicName:
    Value:
      Fn::GetAtt:
        - Topic
        - Topic{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Description": "Test create Kafka Topic",
  "Parameters": {
    "InstanceId": {
      "Type": "String",
      "Description": "Kafka Instance Id",
      "Default": "alikafka_****"
    },
    "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.",
      "Default": "myTopic"
    },
    "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.",
      "Default": "test"
    }
  },
  "Resources": {
    "Topic": {
      "Type": "ALIYUN::KAFKA::Topic",
      "Properties": {
        "InstanceId": {
          "Ref": "InstanceId"
        },
        "Topic": {
          "Ref": "TopicName"
        },
        "Remark": {
          "Ref": "Remark"
        }
      }
    }
  },
  "Outputs": {
    "TopicName": {
      "Value": {
        "Fn::GetAtt": [
          "Topic",
          "Topic"
        ]
      }
    }
  }
}