當您使用ROS建立資源棧管理多種資源時,通常需要開啟多個控制台尋找資源參數資訊。此時您可以在模板的參數配置中指定AssociationProperty以擷取所選地區下對應的資源,指定AssociationPropertyMetadata對不同參數添加篩選條件,以便在控制台動態選擇參數配置。
參數說明
AssociationPropertyMetadata參數的取值:
-
為參數指定特定值。例如:
"RegionId": "cn-hangzhou",ROS將填入特定的地區cn-hangzhou。 -
為參數指定變數,格式為
${ParameterKey}。例如:"VpcId": "${VpcId}",ROS將動態擷取當前模板中參數VpcId對應的值。說明-
如果需要將
${ParameterKey}指定為固定值,可以增加驚嘆號(!)。例如:${!Literal}表示取值為${Literal}。 -
如果要在Terraform模板中使用參數變數,需要在
$前增加一個$。例如:"VpcId": "$${VpcId}",ROS將動態擷取Terraform模板中VpcId對應的值。
-
ROS支援的AssociationProperty為不同資源時,對應的AssociationPropertyMetadata如下所示。
-
自訂資源:用於阿里雲產品OpenApi根據參數進行資料查詢等自訂資源配置
-
基礎資源:通用基礎參數類型的配置
-
ACR資源:Container Registry個人版資源
-
APIG資源:API Gateway資源
-
ALB資源:應用型負載平衡資源
-
Bailian資源:百鍊資源
-
BSS資源:使用者中心資源
-
CAS資源:SSL認證資源
-
CEN資源:雲企業網資源
-
CMS資源:CloudMonitor資源
-
CR資源:Container Registry企業版資源
-
CS資源:Container ServiceKubernetes資源
-
ComputeNest資源:計算巢資源
-
ComputeNestSupplier資源:計算巢服務商資源
-
DNS資源:Alibaba Cloud DNS資源
-
DashVector資源:DashVector向量檢索服務資源
-
Domain資源:網域名稱資源
-
EAS資源:Machine Learning Platform for AI-EAS資源
-
ECD資源:CloudDesktop資源
-
ECI資源:Elastic Container Instance資源
-
ECS資源:Elastic Compute Service資源
-
EHPC資源:彈性高效能運算資源
-
ESS資源:Auto Scaling資源
-
Elasticsearch資源:Elasticsearch資源
-
Emr資源:E-MapReduce資源
-
FC3資源:Function ComputeFC3資源
-
FC資源:Function ComputeFC資源
-
Flow資源:邏輯編排資源
-
Hologres資源:即時數倉Hologres資源
-
InfluxDB資源:時序資料庫InfluxDB資源
-
Kafka資源:訊息佇列Kafka資源
-
Lindorm資源:雲原生多模資料庫Lindorm資源
-
MongoDB資源:ApsaraDB for MongoDB資源
-
NAS資源:Apsara File Storage NAS資源
-
NLB資源:網路型負載平衡NLB資源
-
OOS資源:營運編排服務資源
-
OSS資源:Object Storage Service資源
-
PolarDB資源:雲原生資料庫PolarDB資源
-
RAM資源:存取控制RAM資源
-
RDS資源:雲資料庫RDS資源
-
Redis資源:Redis資源
-
ResourceManager資源:資源管理資源
-
SAE資源:Serverless應用引擎資源
-
SLB資源:Server Load Balancer資源
-
ServiceCatalog資源:服務類別目錄資源
-
Tag資源:標籤資源
-
User資源:使用者資源
-
VPC資源:Virtual Private Cloud資源
使用樣本
樣本1:AssociationProperty樣本
在參數中指定AssociationProperty取值為ALIYUN::ECS::Image::ImageId,以擷取所選地區下所有的鏡像ID。
JSON樣本:
{
"ROSTemplateFormatVersion": "2015-09-01",
"Parameters": {
"UserName": {
"Label": "使用者名稱",
"Description": "請輸入使用者名稱",
"Default": "anonymous",
"Type": "String",
"MinLength": "6",
"MaxLength": "12",
"AllowedValues": [
"anonymous",
"user-one",
"user-two"
]
},
"PassWord": {
"Label": "密碼",
"NoEcho": "True",
"Description": "請輸入使用者密碼",
"Type": "String",
"MinLength": "1",
"MaxLength": "41",
"AllowedPattern": "[a-zA-Z0-9]*"
},
"ImageId": {
"Label": "鏡像",
"Type": "String",
"Description": "請選擇鏡像",
"AssociationProperty": "ALIYUN::ECS::Image::ImageId",
"Default": "centos_7_7_x64_20G_alibase_2020****.vhd"
}
}
}
YAML樣本:
ROSTemplateFormatVersion: '2015-09-01'
Parameters:
UserName:
Label: 使用者名稱
Description: 請輸入使用者名稱
Default: anonymous
Type: String
MinLength: '6'
MaxLength: '12'
AllowedValues:
- anonymous
- user-one
- user-two
PassWord:
Label: 密碼
NoEcho: 'True'
Description: 請輸入使用者密碼
Type: String
MinLength: '1'
MaxLength: '41'
AllowedPattern: '[a-zA-Z0-9]*'
ImageId:
Label: 鏡像
Type: String
Description: 請選擇鏡像
AssociationProperty: ALIYUN::ECS::Image::ImageId
Default: centos_7_7_x64_20G_alibase_2020****.vhd
參數說明:
-
UserName:使用者名稱。String類型,長度為6~12個字元,取值:
-
anonymous(預設值)
-
user-one
-
user-two
-
-
PassWord:密碼。String類型,無預設值。長度為1~41個字元,支援大寫英文字母、小寫英文字母和數字。
NoEcho取值為true,表示查詢資源棧時將不會返回參數值。
-
ImageId:鏡像ID。String類型。
AssociationProperty取值為ALIYUN::ECS::Image::ImageId,建立資源棧時ROS控制台將會驗證參數指定的鏡像ID是否可用,並以下拉框的方式列出所選地區的其他鏡像ID取值。
樣本2:AssociationPropertyMetadata樣本
在參數中指定AssociationProperty和對應的AssociationPropertyMetadata(RegionId、VpcId和ZoneId),以便擷取指定專用網路和可用性區域的交換器。其中,RegionId取值為固定值cn-hangzhou;VpcId和ZoneId取值為變數${VpcId}和${EcsZone},將根據ALIYUN::ECS::VPC::VPCId和ZoneId選定的取值進行動態重新整理,從而建立交換器與專用網路和可用性區域的關聯關係。
針對EcsZone這類配置了AllowedValues的參數,通過在AssociationPropertyMetadata中加入AutoChangeType並配置取值為false從而實現在Resource Orchestration Service控制台頁面對AllowedValues參數的配置資訊展示為下拉式清單樣式。
JSON樣本:
{
"ROSTemplateFormatVersion": "2015-09-01",
"Parameters": {
"VpcId": {
"Type": "String",
"AssociationProperty": "ALIYUN::ECS::VPC::VPCId"
},
"EcsZone": {
"Type": "String",
"AllowedValues": [
"cn-hangzhou-i",
"cn-hangzhou-j",
"cn-hangzhou-k",
"cn-hangzhou-h"
],
"AssociationPropertyMetadata": {
"AutoChangeType": false
}
},
"VSwitchId": {
"Type": "String",
"AssociationProperty": "ALIYUN::VPC::VSwitch::VSwitchId",
"AssociationPropertyMetadata": {
"RegionId": "cn-hangzhou",
"VpcId": "${VpcId}",
"ZoneId": "${EcsZone}"
}
}
}
}
YAML樣本:
ROSTemplateFormatVersion: '2015-09-01'
Parameters:
VpcId:
Type: String
AssociationProperty: ALIYUN::ECS::VPC::VPCId
EcsZone:
Type: String
AllowedValues:
- cn-hangzhou-i
- cn-hangzhou-j
- cn-hangzhou-k
- cn-hangzhou-h
AssociationPropertyMetadata:
AutoChangeType: false
VSwitchId:
Type: String
AssociationProperty: ALIYUN::VPC::VSwitch::VSwitchId
AssociationPropertyMetadata:
RegionId: cn-hangzhou
VpcId: ${VpcId}
ZoneId: ${EcsZone}
樣本3:Terraform自動轉換樣本
當AssociationProperty取值為Auto時,ROS會基於Terraform未經處理資料結構,自動產生AssociationProperty和AssociationPropertyMetadata等欄位。
更多樣本
您也可以使用AssociationProperty和AssociationPropertyMetadata,實現以下訴求: