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"
]
}
}
}
}