ALIYUN::POLARDB::Extensions类型用于安装插件。
语法
{
"Type": "ALIYUN::POLARDB::Extensions",
"Properties": {
"AccountName": String,
"DBClusterId": String,
"DBNames": List,
"Extensions": List,
"ResourceGroupId": String,
"SourceDBName": String,
"VpcId": String
}
}
属性
|
属性名称 |
类型 |
必须 |
允许更新 |
描述 |
约束 |
|
AccountName |
String |
是 |
否 |
与数据库关联的账号名称。 |
无 |
|
DBClusterId |
String |
是 |
否 |
集群ID。 |
无 |
|
DBNames |
List |
是 |
否 |
数据库名称。 |
无 |
|
Extensions |
List |
否 |
否 |
要安装的扩展。 |
无 |
|
ResourceGroupId |
String |
否 |
否 |
资源组ID。 |
无 |
|
SourceDBName |
String |
否 |
否 |
源数据库名称。 |
无 |
|
VpcId |
String |
否 |
否 |
访问端点的VPC ID。 |
无 |
返回值
Fn::GetAtt
无
示例
场景 1 :在已有PolarDB集群上为单个数据库安装扩展
ROSTemplateFormatVersion: '2015-09-01'
Description:
zh-cn: 在已有 PolarDB 集群上为单个数据库安装数据库扩展(如 PostGIS、pgvector)。
Parameters:
DBClusterId:
Type: String
Label: PolarDB集群ID
Description: 已创建的 PolarDB 集群 ID。
DBName:
Type: String
Label: 数据库名称
Description: 需要安装扩展的数据库名称。
Default: appdb
AccountName:
Type: String
Label: 数据库账号
Description: 关联数据库的账号名称(需对数据库具备权限)。
Extensions:
Type: CommaDelimitedList
Label: 扩展列表
Description: 要安装的数据库扩展名称列表,多个用英文逗号分隔,例如 postgis,pgvector。
Default: postgis,pgvector
Resources:
DbExtensions:
Type: ALIYUN::POLARDB::Extensions
Properties:
DBClusterId:
Ref: DBClusterId
DBNames:
- Ref: DBName
AccountName:
Ref: AccountName
Extensions:
Ref: Extensions
Outputs:
DBClusterId:
Description: PolarDB 集群 ID。
Value:
Ref: DBClusterId
DBName:
Description: 安装扩展的数据库名称。
Value:
Ref: DBName
AccountName:
Description: 关联数据库的账号名称。
Value:
Ref: AccountName
Extensions:
Description: 已安装的数据库扩展列表。
Value:
Fn::Join:
- ','
- Ref: Extensions{
"ROSTemplateFormatVersion": "2015-09-01",
"Description": {
"zh-cn": "在已有 PolarDB 集群上为单个数据库安装数据库扩展(如 PostGIS、pgvector)。"
},
"Parameters": {
"DBClusterId": {
"Type": "String",
"Label": "PolarDB集群ID",
"Description": "已创建的 PolarDB 集群 ID。"
},
"DBName": {
"Type": "String",
"Label": "数据库名称",
"Description": "需要安装扩展的数据库名称。",
"Default": "appdb"
},
"AccountName": {
"Type": "String",
"Label": "数据库账号",
"Description": "关联数据库的账号名称(需对数据库具备权限)。"
},
"Extensions": {
"Type": "CommaDelimitedList",
"Label": "扩展列表",
"Description": "要安装的数据库扩展名称列表,多个用英文逗号分隔,例如 postgis,pgvector。",
"Default": "postgis,pgvector"
}
},
"Resources": {
"DbExtensions": {
"Type": "ALIYUN::POLARDB::Extensions",
"Properties": {
"DBClusterId": { "Ref": "DBClusterId" },
"DBNames": [{ "Ref": "DBName" }],
"AccountName": { "Ref": "AccountName" },
"Extensions": { "Ref": "Extensions" }
}
}
},
"Outputs": {
"DBClusterId": {
"Description": "PolarDB 集群 ID。",
"Value": { "Ref": "DBClusterId" }
},
"DBName": {
"Description": "安装扩展的数据库名称。",
"Value": { "Ref": "DBName" }
},
"AccountName": {
"Description": "关联数据库的账号名称。",
"Value": { "Ref": "AccountName" }
},
"Extensions": {
"Description": "已安装的数据库扩展列表。",
"Value": { "Fn::Join": [",", { "Ref": "Extensions" }] }
}
}
}场景 2 :在已有PolarDB集群上为多个数据库批量安装多个扩展。
ROSTemplateFormatVersion: '2015-09-01'
Description:
zh-cn: 在已有 PolarDB 集群上为多个数据库批量安装多个数据库扩展。
Parameters:
DBClusterId:
Type: String
Label: PolarDB集群ID
Description: 已创建的 PolarDB 集群 ID。
DBNames:
Type: CommaDelimitedList
Label: 数据库名称列表
Description: 需要安装扩展的数据库名称列表,多个用英文逗号分隔,例如 appdb1,appdb2。
Default: appdb1,appdb2
AccountName:
Type: String
Label: 数据库账号
Description: 关联数据库的账号名称(需对所列数据库具备权限)。
Extensions:
Type: CommaDelimitedList
Label: 扩展列表
Description: 要安装的数据库扩展名称列表,多个用英文逗号分隔,例如 postgis,pgvector。
Default: postgis,pgvector
Resources:
DbExtensions:
Type: ALIYUN::POLARDB::Extensions
Properties:
DBClusterId:
Ref: DBClusterId
DBNames:
Ref: DBNames
AccountName:
Ref: AccountName
Extensions:
Ref: Extensions
Outputs:
DBClusterId:
Description: PolarDB 集群 ID。
Value:
Ref: DBClusterId
AccountName:
Description: 关联数据库的账号名称。
Value:
Ref: AccountName
DBNames:
Description: 安装扩展的数据库名称列表。
Value:
Fn::Join:
- ','
- Ref: DBNames
Extensions:
Description: 已安装的数据库扩展列表。
Value:
Fn::Join:
- ','
- Ref: Extensions{
"ROSTemplateFormatVersion": "2015-09-01",
"Description": {
"zh-cn": "在已有 PolarDB 集群上为多个数据库批量安装多个数据库扩展。"
},
"Parameters": {
"DBClusterId": {
"Type": "String",
"Label": "PolarDB集群ID",
"Description": "已创建的 PolarDB 集群 ID。"
},
"DBNames": {
"Type": "CommaDelimitedList",
"Label": "数据库名称列表",
"Description": "需要安装扩展的数据库名称列表,多个用英文逗号分隔,例如 appdb1,appdb2。",
"Default": "appdb1,appdb2"
},
"AccountName": {
"Type": "String",
"Label": "数据库账号",
"Description": "关联数据库的账号名称(需对所列数据库具备权限)。"
},
"Extensions": {
"Type": "CommaDelimitedList",
"Label": "扩展列表",
"Description": "要安装的数据库扩展名称列表,多个用英文逗号分隔,例如 postgis,pgvector。",
"Default": "postgis,pgvector"
}
},
"Resources": {
"DbExtensions": {
"Type": "ALIYUN::POLARDB::Extensions",
"Properties": {
"DBClusterId": { "Ref": "DBClusterId" },
"DBNames": { "Ref": "DBNames" },
"AccountName": { "Ref": "AccountName" },
"Extensions": { "Ref": "Extensions" }
}
}
},
"Outputs": {
"DBClusterId": {
"Description": "PolarDB 集群 ID。",
"Value": { "Ref": "DBClusterId" }
},
"AccountName": {
"Description": "关联数据库的账号名称。",
"Value": { "Ref": "AccountName" }
},
"DBNames": {
"Description": "安装扩展的数据库名称列表。",
"Value": { "Fn::Join": [",", { "Ref": "DBNames" }] }
},
"Extensions": {
"Description": "已安装的数据库扩展列表。",
"Value": { "Fn::Join": [",", { "Ref": "Extensions" }] }
}
}
}场景 3 :创建PolarDB PostgreSQL集群、账号与数据库并安装扩展。
ROSTemplateFormatVersion: '2015-09-01'
Description:
zh-cn: 创建 PolarDB PostgreSQL 集群、特权账号与数据库,并安装数据库扩展(如 PostGIS、pgvector),适用于端到端初始化扩展数据库场景。
Parameters:
ZoneId:
Type: String
Label: 可用区
Description: 集群与交换机所属可用区。
AssociationProperty: ALIYUN::ECS::Instance::ZoneId
DBNodeClass:
Type: String
Label: 节点规格
Description: PolarDB-PG 计算节点规格,例如 polar.pg.x4.medium、polar.pg.x4.large。
Default: polar.pg.x4.medium
DBVersion:
Type: String
Label: 数据库引擎版本
Description: PolarDB-PG 引擎版本。
AllowedValues:
- '11'
- '14'
- '15'
Default: '14'
DBClusterDescription:
Type: String
Label: 集群描述
Description: PolarDB 集群描述,2-256 字符。
Default: PolarDB-PG extensions demo
SecurityIPList:
Type: String
Label: IP白名单
Description: 允许访问集群的 IP 白名单,多个用逗号分隔;生产环境请收敛为具体 IP 段。
Default: 0.0.0.0/0
AccountName:
Type: String
Label: 特权账号名称
Description: 集群特权账号名称,小写字母开头,仅含小写字母/数字/下划线,1-16 字符,不能为 root/admin 等保留字。
MinLength: 1
MaxLength: 16
Default: polardb_user
AccountPassword:
Type: String
Label: 特权账号密码
Description: 8-32 位,需同时包含大写字母、小写字母、数字和特殊字符。
NoEcho: true
MinLength: 8
MaxLength: 32
DBName:
Type: String
Label: 数据库名称
Description: 数据库名称,小写字母开头,仅含小写字母/数字/连字符/下划线,1-64 字符。
Default: appdb
CharacterSetName:
Type: String
Label: 字符集
Description: 数据库字符集。
Default: UTF8
Collate:
Type: String
Label: 排序规则
Description: 数据库排序规则(PostgreSQL 必填),需与字符集兼容。
Default: C
Ctype:
Type: String
Label: 字符分类
Description: 数据库字符分类(PostgreSQL 必填),需与排序规则一致。
Default: C
Extensions:
Type: CommaDelimitedList
Label: 扩展列表
Description: 要安装的数据库扩展名称列表,多个用英文逗号分隔,例如 postgis,pgvector。
Default: postgis,pgvector
Resources:
Vpc:
Type: ALIYUN::ECS::VPC
Properties:
CidrBlock: 192.168.0.0/16
VpcName: polardb-demo-vpc
VSwitch:
Type: ALIYUN::ECS::VSwitch
Properties:
ZoneId:
Ref: ZoneId
CidrBlock: 192.168.0.0/24
VpcId:
Ref: Vpc
VSwitchName: polardb-demo-vsw
DBCluster:
Type: ALIYUN::POLARDB::DBCluster
Properties:
DBType: PostgreSQL
DBVersion:
Ref: DBVersion
DBNodeClass:
Ref: DBNodeClass
PayType: PayAsYouGo
ZoneId:
Ref: ZoneId
VpcId:
Ref: Vpc
VSwitchId:
Ref: VSwitch
DBClusterDescription:
Ref: DBClusterDescription
StorageType: PSL5
SecurityIPList:
Ref: SecurityIPList
DbAccount:
Type: ALIYUN::POLARDB::Account
Properties:
DBClusterId:
Fn::GetAtt:
- DBCluster
- DBClusterId
AccountName:
Ref: AccountName
AccountPassword:
Ref: AccountPassword
AccountType: Super
AccountDescription: PolarDB privileged account for extensions
DependsOn: DBCluster
DbDatabase:
Type: ALIYUN::POLARDB::Database
Properties:
DBClusterId:
Fn::GetAtt:
- DBCluster
- DBClusterId
DBName:
Ref: DBName
CharacterSetName:
Ref: CharacterSetName
AccountName:
Ref: AccountName
AccountPrivilege: ReadWrite
Collate:
Ref: Collate
Ctype:
Ref: Ctype
DBDescription: Application database for extensions
DependsOn: DbAccount
DbExtensions:
Type: ALIYUN::POLARDB::Extensions
Properties:
DBClusterId:
Fn::GetAtt:
- DBCluster
- DBClusterId
DBNames:
- Ref: DBName
AccountName:
Ref: AccountName
Extensions:
Ref: Extensions
DependsOn:
- DbDatabase
- DbAccount
Outputs:
DBClusterId:
Description: PolarDB 集群 ID。
Value:
Fn::GetAtt:
- DBCluster
- DBClusterId
PrimaryConnectionString:
Description: PolarDB 集群主连接地址。
Value:
Fn::GetAtt:
- DBCluster
- PrimaryConnectionString
AccountName:
Description: 集群特权账号名称。
Value:
Ref: AccountName
DBName:
Description: 创建的数据库名称。
Value:
Ref: DBName
Extensions:
Description: 已安装的数据库扩展列表。
Value:
Fn::Join:
- ','
- Ref: Extensions{
"ROSTemplateFormatVersion": "2015-09-01",
"Description": {
"zh-cn": "创建 PolarDB PostgreSQL 集群、特权账号与数据库,并安装数据库扩展(如 PostGIS、pgvector),适用于端到端初始化扩展数据库场景。"
},
"Parameters": {
"ZoneId": {
"Type": "String",
"Label": "可用区",
"Description": "集群与交换机所属可用区。",
"AssociationProperty": "ALIYUN::ECS::Instance::ZoneId"
},
"DBNodeClass": {
"Type": "String",
"Label": "节点规格",
"Description": "PolarDB-PG 计算节点规格,例如 polar.pg.x4.medium、polar.pg.x4.large。",
"Default": "polar.pg.x4.medium"
},
"DBVersion": {
"Type": "String",
"Label": "数据库引擎版本",
"Description": "PolarDB-PG 引擎版本。",
"AllowedValues": ["11", "14", "15"],
"Default": "14"
},
"DBClusterDescription": {
"Type": "String",
"Label": "集群描述",
"Description": "PolarDB 集群描述,2-256 字符。",
"Default": "PolarDB-PG extensions demo"
},
"SecurityIPList": {
"Type": "String",
"Label": "IP白名单",
"Description": "允许访问集群的 IP 白名单,多个用逗号分隔;生产环境请收敛为具体 IP 段。",
"Default": "0.0.0.0/0"
},
"AccountName": {
"Type": "String",
"Label": "特权账号名称",
"Description": "集群特权账号名称,小写字母开头,仅含小写字母/数字/下划线,1-16 字符,不能为 root/admin 等保留字。",
"MinLength": 1,
"MaxLength": 16,
"Default": "polardb_user"
},
"AccountPassword": {
"Type": "String",
"Label": "特权账号密码",
"Description": "8-32 位,需同时包含大写字母、小写字母、数字和特殊字符。",
"NoEcho": true,
"MinLength": 8,
"MaxLength": 32
},
"DBName": {
"Type": "String",
"Label": "数据库名称",
"Description": "数据库名称,小写字母开头,仅含小写字母/数字/连字符/下划线,1-64 字符。",
"Default": "appdb"
},
"CharacterSetName": {
"Type": "String",
"Label": "字符集",
"Description": "数据库字符集。",
"Default": "UTF8"
},
"Collate": {
"Type": "String",
"Label": "排序规则",
"Description": "数据库排序规则(PostgreSQL 必填),需与字符集兼容。",
"Default": "C"
},
"Ctype": {
"Type": "String",
"Label": "字符分类",
"Description": "数据库字符分类(PostgreSQL 必填),需与排序规则一致。",
"Default": "C"
},
"Extensions": {
"Type": "CommaDelimitedList",
"Label": "扩展列表",
"Description": "要安装的数据库扩展名称列表,多个用英文逗号分隔,例如 postgis,pgvector。",
"Default": "postgis,pgvector"
}
},
"Resources": {
"Vpc": {
"Type": "ALIYUN::ECS::VPC",
"Properties": { "CidrBlock": "192.168.0.0/16", "VpcName": "polardb-demo-vpc" }
},
"VSwitch": {
"Type": "ALIYUN::ECS::VSwitch",
"Properties": {
"ZoneId": { "Ref": "ZoneId" },
"CidrBlock": "192.168.0.0/24",
"VpcId": { "Ref": "Vpc" },
"VSwitchName": "polardb-demo-vsw"
}
},
"DBCluster": {
"Type": "ALIYUN::POLARDB::DBCluster",
"Properties": {
"DBType": "PostgreSQL",
"DBVersion": { "Ref": "DBVersion" },
"DBNodeClass": { "Ref": "DBNodeClass" },
"PayType": "PayAsYouGo",
"ZoneId": { "Ref": "ZoneId" },
"VpcId": { "Ref": "Vpc" },
"VSwitchId": { "Ref": "VSwitch" },
"DBClusterDescription": { "Ref": "DBClusterDescription" },
"StorageType": "PSL5",
"SecurityIPList": { "Ref": "SecurityIPList" }
}
},
"DbAccount": {
"Type": "ALIYUN::POLARDB::Account",
"Properties": {
"DBClusterId": { "Fn::GetAtt": ["DBCluster", "DBClusterId"] },
"AccountName": { "Ref": "AccountName" },
"AccountPassword": { "Ref": "AccountPassword" },
"AccountType": "Super",
"AccountDescription": "PolarDB privileged account for extensions"
},
"DependsOn": "DBCluster"
},
"DbDatabase": {
"Type": "ALIYUN::POLARDB::Database",
"Properties": {
"DBClusterId": { "Fn::GetAtt": ["DBCluster", "DBClusterId"] },
"DBName": { "Ref": "DBName" },
"CharacterSetName": { "Ref": "CharacterSetName" },
"AccountName": { "Ref": "AccountName" },
"AccountPrivilege": "ReadWrite",
"Collate": { "Ref": "Collate" },
"Ctype": { "Ref": "Ctype" },
"DBDescription": "Application database for extensions"
},
"DependsOn": "DbAccount"
},
"DbExtensions": {
"Type": "ALIYUN::POLARDB::Extensions",
"Properties": {
"DBClusterId": { "Fn::GetAtt": ["DBCluster", "DBClusterId"] },
"DBNames": [{ "Ref": "DBName" }],
"AccountName": { "Ref": "AccountName" },
"Extensions": { "Ref": "Extensions" }
},
"DependsOn": ["DbDatabase", "DbAccount"]
}
},
"Outputs": {
"DBClusterId": {
"Description": "PolarDB 集群 ID。",
"Value": { "Fn::GetAtt": ["DBCluster", "DBClusterId"] }
},
"PrimaryConnectionString": {
"Description": "PolarDB 集群主连接地址。",
"Value": { "Fn::GetAtt": ["DBCluster", "PrimaryConnectionString"] }
},
"AccountName": {
"Description": "集群特权账号名称。",
"Value": { "Ref": "AccountName" }
},
"DBName": {
"Description": "创建的数据库名称。",
"Value": { "Ref": "DBName" }
},
"Extensions": {
"Description": "已安装的数据库扩展列表。",
"Value": { "Fn::Join": [",", { "Ref": "Extensions" }] }
}
}
}该文章对您有帮助吗?