偽參數是資源編排服務ROS的編排引擎提供的固定參數。它們可以和用戶定義的參數一樣被引用,其值在ROS運行時被確定。
偽參數
ROS為您提供了以下偽參數:
ALIYUN::StackName
:資源棧名稱。ALIYUN::StackId
:資源棧ID。ALIYUN::Region
:資源棧所在地域。ALIYUN::AccountId
:執行者賬號ID。ALIYUN::TenantId
:當前賬號的阿里云賬號ID。ALIYUN::ResourceGroupId
:資源棧所屬資源組。ALIYUN::NoValue
:創建或更新資源棧時,如果ALIYUN::NoValue
用于可選屬性,則將刪除該屬性;如果ALIYUN::NoValue
用于必選屬性,則將按類型獲取默認值(例如,用于String類型的屬性值為空字符串;用于Integer類型的屬性值為0;用于數組類型屬性值為空數組等)。ALIYUN::Index
:一個特殊的偽參數,僅在資源Count
功能中使用,其他情況不能使用。Count
詳情,請參見Count。
示例
YAML
格式
ROSTemplateFormatVersion: '2015-09-01'
Parameters:
EnvType:
Default: pre
Type: String
Conditions:
CreateDisk:
Fn::Equals:
- prod
- Ref: EnvType
Resources:
WebServer:
Type: ALIYUN::ECS::Instance
Properties:
DiskMappings:
Fn::If:
- CreateDisk
- - Category: cloud_efficiency
DiskName: FirstDataDiskName
Size: 40
- Category: cloud_ssd
DiskName: SecondDataDiskName
Size: 40
- Ref: ALIYUN::NoValue
VpcId: vpc-m5eebunc50zfbmts7****
SystemDiskCategory: cloud_efficiency
SecurityGroupId: sg-m5eagh7rzys2z8sa****
SystemDiskSize: 40
ImageId: cent****
IoOptimized: optimized
VSwitchId: vsw-m5eem62p9729y6gps****
InstanceType: ecs.c5.large
Outputs:
StackName:
Value:
Ref: ALIYUN::StackName
StackId:
Value:
Ref: ALIYUN::StackId
Region:
Value:
Ref: ALIYUN::Region
UserID:
Value:
Ref: ALIYUN::AccountId
JSON
格式
{
"ROSTemplateFormatVersion": "2015-09-01",
"Parameters": {
"EnvType": {
"Default": "pre",
"Type": "String"
}
},
"Conditions": {
"CreateDisk": {
"Fn::Equals": [
"prod",
{
"Ref": "EnvType"
}
]
}
},
"Resources": {
"WebServer": {
"Type": "ALIYUN::ECS::Instance",
"Properties": {
"DiskMappings": {
"Fn::If": [
"CreateDisk",
[
{
"Category": "cloud_efficiency",
"DiskName": "FirstDataDiskName",
"Size": 40
},
{
"Category": "cloud_ssd",
"DiskName": "SecondDataDiskName",
"Size": 40
}
],
{
"Ref": "ALIYUN::NoValue"
}
]
},
"VpcId": "vpc-m5eebunc50zfbmts7****",
"SystemDiskCategory": "cloud_efficiency",
"SecurityGroupId": "sg-m5eagh7rzys2z8sa****",
"SystemDiskSize": 40,
"ImageId": "cent****",
"IoOptimized": "optimized",
"VSwitchId": "vsw-m5eem62p9729y6gps****",
"InstanceType": "ecs.c5.large"
}
}
},
"Outputs": {
"StackName": {
"Value": {
"Ref": "ALIYUN::StackName"
}
},
"StackId": {
"Value": {
"Ref": "ALIYUN::StackId"
}
},
"Region": {
"Value": {
"Ref": "ALIYUN::Region"
}
},
"UserID": {
"Value": {
"Ref": "ALIYUN::AccountId"
}
}
}
}
文檔內容是否對您有幫助?