日本熟妇hd丰满老熟妇,中文字幕一区二区三区在线不卡 ,亚洲成片在线观看,免费女同在线一区二区

文檔

條件(Conditions)

更新時間:

每個條件項的最外層函數都需要由Fn::And、Fn::Or、Fn::Not或Fn::Equals定義,在每個條件中都可以引用其他條件、參數值或者映射。您可以在模板的Tasks中,將條件與任務關聯起來,條件和任務的關聯可以通過Tasks的When字段實現。

語法

每個條件由條件名和條件組成,其中條件名為字符串類型,條件是由下列函數定義。在條件中可以引用其他條件,每個條件名不能重復。

可以在定義條件時使用內置函數(Builtin-Functions),但是最外層函數只能是上述四個函數。

用法示例

  • 引用模板參數

    直接引用模板Parameters已經聲明的參數,示例引用了模板已聲明的參數buildType

    Conditions:
      NewTemporaryEcs:
        Fn::Equals:
          - '{{ buildType }}'
          - NewTemporaryEcs
  • 引用Task輸出

    引用前序任務的輸出作為條件判斷的一部分,示例引用了任務checkPolicyExist的輸出參數existed

    Conditions:
      createStack:
        Fn::Equals:
          - '{{ checkPolicyExist.existed }}'
          - 'false'
    Tasks:
      - Name: checkPolicyExist
        Action:  ACS::CheckFor
        Description:
          en: Check for the inexistence of policy
          zh-cn: 判斷自定義權限策略名稱存在性
        Properties:
          Service: RAM
          API: GetPolicy
          Parameters:
            PolicyType: 'Custom'
            PolicyName: '{{ policyName }}'
          DesiredValues:
          - 'true'
          - 'false'
          PropertySelector: '.DefaultPolicyVersion != null|tostring'
        Outputs:
          existed:
            Type: String
            ValueSelector: .DefaultPolicyVersion == null|tostring

    注意:條件使用動態參數時,被引用參數的任務必須是條件對應任務的前序任務

  • 多層嵌套函數

    條件中的函數支持多層嵌套,以應對復雜的場景判斷

    Conditions:
      downloadWindowsFile:
        Fn::And:
          - Fn::Equals:
              - '{{ queryInstanceOSType.OSType }}'
              - windows
          - Fn::Not:
              Fn::Equals:
                - '{{ artifactsUrl }}'
                - ''

模板示例

  • 關聯Conditions和Tasks,本示例中,根據操作系統的值決定執行哪一項任務

    FormatVersion: OOS-2019-06-01
    Description:
      name-en: ACS::ECS::CleanUpDisk
      name-zh-cn: 清理磁盤
      en: Cleanup disk by run command
      zh-cn: 通過執行命令清理磁盤
    # 在Conditions模塊設置條件內容
    Conditions:
      Linux:
        Fn::Equals:
            - '{{ queryInstanceOSType.OSType }}'
            - linux
      Windows:
        Fn::Equals:
            - '{{ queryInstanceOSType.OSType }}'
            - windows
    Parameters:
      regionId:
        Description:
          en: The ID of region
          zh-cn: 地域ID
        Type: String
        Default: '{{ ACS::RegionId }}'
      instanceId:
        Description:
          en: The ID of ECS instance
          zh-cn: ECS實例ID
        Type: String
    Tasks:
      - Name: queryInstanceOSType
        Action: 'ACS::ExecuteApi'
        Description:
          en: Queries ECS instance OS type
          zh-cn: 獲取實例操作系統類型
        Properties:
          Service: ECS
          API: DescribeInstances
          Parameters:
            RegionId: '{{ regionId }}'
            InstanceIds:
              - '{{ instanceId }}'
        Outputs:
          OSType:
            Type: String
            ValueSelector: 'Instances.Instance[].OSType'
      - Name: cleanupLinuxInstanceDisk
        # 判斷操作系統是否為Linux
        When: Linux
        Action: 'ACS::ECS::RunCommand'
        Description:
          en: Runs cleanup disk command on linux instance
          zh-cn: 在linux類型實例上執行清理磁盤命令
        Properties:
          regionId: '{{ regionId }}'
          commandContent: |-
            #!/bin/bash
            cleanUpInfos="{{cleanUpInfos}}"
            # 運行清理磁盤命令
          instanceId: '{{ instanceId }}'
          commandType: RunShellScript
        Outputs:
          result:
            Type: String
            ValueSelector: .invocationOutput
      - Name: cleanupWindowsInstanceDisk
        # 判斷操作系統是否為Windows
        When: Windows
        Action: 'ACS::ECS::RunCommand'
        Description:
          en: Runs cleanup disk command on windows instance
          zh-cn: 在windowds類型實例上執行清理磁盤命令
        Properties:
          regionId: '{{ regionId }}'
          commandContent: |-
            #!/bin/bash
            cleanUpInfos="{{cleanUpInfos}}"
            # 運行清理磁盤命令
          instanceId: '{{ instanceId }}'
          commandType: RunPowerShellScript
        Outputs:
          result:
            Type: String
            ValueSelector: .invocationOutput
    Outputs:
      commandOutput:
        Type: String
        Value:
          'Fn::If':
            - 'Fn::Equals':
                - linux
                - '{{ queryInstanceOSType.OSType }}'
            - '{{ cleanupLinuxInstanceDisk.result }}'
            - '{{ cleanupWindowsInstanceDisk.result }}'