全部產品
Search
文件中心

Resource Orchestration Service:偽參數(Pseudo parameters)

更新時間:Jun 08, 2024

偽參數是Resource Orchestration Service服務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"
      }
    }
  }
}