全部產品
Search
文件中心

CloudOps Orchestration Service:選擇目標資源ACS::SelectTargets

更新時間:Jan 21, 2025

使用該動作,當設定參數時,批量選擇資源將會非常方便。

用途

如果您在模板中使用了ACS::SelectTargets動作,並定義了包含"AssociationProperty": "Targets"的模板參數,當您建立執行來設定參數時,可輕易切換批量選取資源的方式。有手動選擇資源、指定資源的標籤、選擇全部資源、CSV檔案(包含資源ID)和指定配置清單條件幾種方式,方便您快速完成資源的批量選擇。

selecttargets

文法

FormatVersion: OOS-2019-06-01
Description: 'ACS::SelectTargets usage'
Parameters:
  targets:  # 參數名,用來選擇資源範圍。
    Type: Json  # 參數類型,固定為Json。
    AssociationProperty: Targets    # 參數關聯的動作,對應ACS::SelectTargets時,固定為Targets 。
    AssociationPropertyMetadata:  # 參數要選擇的資源定義。
      ResourceType: ALIYUN::ECS::Instance # 要選擇的資源類型。
                    # ALIYUN::ECS::Instance  資源為ECS執行個體
                    # ALIYUN::ECD::Desktop 資源為ECDCloudDesktop
                    # ALIYUN::RDS::Instance 資源為RDS執行個體
                    # ALIYUN::Redis::Instance 資源為REDIS執行個體
                    # ALIYUN::MongoDB::Instance 資源為MongoDB執行個體
                    # ALIYUN::ECS::ManagedInstance 資源為ECS受管理的執行個體
                    # ALIYUN::ComputeNestSupplier::Instance 資源為ComputeNestSupplier執行個體
Tasks:
  - Name: getInstance # 任務名稱。
    Action: 'ACS::SelectTargets'  # 確定選擇具體資源的動作。
    Properties:
      ResourceType: 'ALIYUN::ECS::Instance'  # 要選擇的資源類型。
      Filters: # 要篩選的範圍。
        - '{{ targets }}'  # 選擇資源範圍的參數名。
    Outputs:  # 任務輸出。
      instanceIds: # 任務輸出參數名。
        Type: List  # 輸出參數類型。
        ValueSelector: 'Instances.Instance[].InstanceId'  # jq Selector,其篩選的對象為該資源類型的Describe OpenAPI返回結果,比如ECS執行個體的篩選對象則是DescribeInstances OpenAPI的返回結果。
{
  "FormatVersion": "OOS-2019-06-01",
  "Description": "ACS::SelectTargets usage",
  "Parameters": {
    "targets": {
      "Type": "Json",
      "AssociationProperty": "Targets",
      "AssociationPropertyMetadata": {
        "ResourceType": "ALIYUN::ECS::Instance"
      }
    }
  },
  "Tasks": [
    {
      "Name": "getInstance",
      "Action": "ACS::SelectTargets",
      "Properties": {
        "ResourceType": "ALIYUN::ECS::Instance",
        "Filters": [
          "{{ targets }}"
        ]
      },
      "Outputs": {
        "instanceIds": {
          "Type": "List",
          "ValueSelector": "Instances.Instance[].InstanceId"
        }
      }
    }
  ]
}

模板樣本

  • 大量啟動ECS執行個體

    FormatVersion: OOS-2019-06-01
    Description:
      en: Bulky starts the ECS instances.
      zh-cn: 大量啟動ECS執行個體。
      name-en: ACS-ECS-BulkyStartInstances
      name-zh-cn: 大量啟動ECS執行個體
      categories:
        - instance_manage
    Parameters:
      targets:
        Type: Json
        AssociationProperty: Targets
        AssociationPropertyMetadata:
          ResourceType: 'ALIYUN::ECS::Instance'
      rateControl:
        Description:
          en: Concurrency ratio of task execution.
          zh-cn: 任務執行的並發比率。
        Type: Json
        AssociationProperty: RateControl
        Default:
          Mode: Concurrency
          MaxErrors: 0
          Concurrency: 10
      OOSAssumeRole:
        Description:
          en: The RAM role to be assumed by OOS.
          zh-cn: OOS扮演的RAM角色。
        Type: String
        Default: OOSServiceRole
    RamRole: '{{ OOSAssumeRole }}'
    Tasks:
      - Name: getInstance
        Description:
          en: Views the ECS instances.
          zh-cn: 擷取ECS執行個體。
        Action: 'ACS::SelectTargets'
        Properties:
          ResourceType: 'ALIYUN::ECS::Instance'
          Filters:
            - '{{ targets }}'
        Outputs:
          instanceIds:
            Type: List
            ValueSelector: 'Instances.Instance[].InstanceId'
      - Name: startInstance
        Action: 'ACS::ECS::StartInstance'
        Description:
          en: Starts the ECS instances.
          zh-cn: 啟動執行個體。
        Properties:
          instanceId: '{{ ACS::TaskLoopItem }}'
        Loop:
          RateControl: '{{ rateControl }}'
          Items: '{{ getInstance.instanceIds }}'
    Outputs:
      instanceIds:
        Type: List
        Value: '{{ getInstance.instanceIds }}'
    {
      "FormatVersion": "OOS-2019-06-01",
      "Description": {
        "en": "Bulky starts the ECS instances.",
        "zh-cn": "大量啟動ECS執行個體。",
        "name-en": "ACS-ECS-BulkyStartInstances",
        "name-zh-cn": "大量啟動ECS執行個體",
        "categories": [
          "instance_manage"
        ]
      },
      "Parameters": {
        "targets": {
          "Type": "Json",
          "AssociationProperty": "Targets",
          "AssociationPropertyMetadata": {
            "ResourceType": "ALIYUN::ECS::Instance"
          }
        },
        "rateControl": {
          "Description": {
            "en": "Concurrency ratio of task execution.",
            "zh-cn": "任務執行的並發比率。"
          },
          "Type": "Json",
          "AssociationProperty": "RateControl",
          "Default": {
            "Mode": "Concurrency",
            "MaxErrors": 0,
            "Concurrency": 10
          }
        },
        "OOSAssumeRole": {
          "Description": {
            "en": "The RAM role to be assumed by OOS.",
            "zh-cn": "OOS扮演的RAM角色。"
          },
          "Type": "String",
          "Default": "OOSServiceRole"
        }
      },
      "RamRole": "{{ OOSAssumeRole }}",
      "Tasks": [
        {
          "Name": "getInstance",
          "Description": {
            "en": "Views the ECS instances.",
            "zh-cn": "擷取ECS執行個體。"
          },
          "Action": "ACS::SelectTargets",
          "Properties": {
            "ResourceType": "ALIYUN::ECS::Instance",
            "Filters": [
              "{{ targets }}"
            ]
          },
          "Outputs": {
            "instanceIds": {
              "Type": "List",
              "ValueSelector": "Instances.Instance[].InstanceId"
            }
          }
        },
        {
          "Name": "startInstance",
          "Action": "ACS::ECS::StartInstance",
          "Description": {
            "en": "Starts the ECS instances.",
            "zh-cn": "啟動執行個體。"
          },
          "Properties": {
            "instanceId": "{{ ACS::TaskLoopItem }}"
          },
          "Loop": {
            "RateControl": "{{ rateControl }}",
            "Items": "{{ getInstance.instanceIds }}"
          }
        }
      ],
      "Outputs": {
        "instanceIds": {
          "Type": "List",
          "Value": "{{ getInstance.instanceIds }}"
        }
      }
    }

不同ECS執行個體選擇方式targets參數樣本

  • 根據執行個體ID選擇

    targets:
      Type: ResourceIds
      RegionId: cn-hangzhou
      ResourceIds:
        - i-******************1
        - i-******************2
        - i-******************3
    {
      "targets": {
        "Type": "ResourceIds",
        "RegionId": "cn-hangzhou",
        "ResourceIds": [
          "i-******************1",
          "i-******************2",
          "i-******************3"
        ]
      }
    }
  • 根據標籤選擇(最多選擇1000執行個體,如果大於1000請使用通過標籤選擇ECS執行個體並執行命令模板

    targets:
      Type: Tags
      RegionId: cn-hangzhou
      Tags:
        - Key: key1
          Value: value1
        - Key: key2
          Value: value2
    {
      "targets": {
        "Type": "Tags",
        "RegionId": "cn-hangzhou",
        "Tags": [
          {
            "Key": "key1",
            "Value": "value1"
          },
          {
            "Key": "key2",
            "Value": "value2"
          }
        ]
      }
    }
  • 根據資源群組選擇

    targets:
      Type: ResourceGroup
      RegionId: cn-hangzhou
      ResourceGroupId: rg-acf*********re3y
    {
      "targets": {
        "Type": "ResourceGroup",
        "RegionId": "cn-hangzhou",
        "ResourceGroupId": "rg-acf*********re3y"
      }
    }
  • 選擇所有執行個體

    targets:
      Type: All
      RegionId: cn-hangzhou
      Parameters:
        RegionId: cn-hangzhou
        Status: Running
        Tags:
          - Key: key1
            Value: value1
    {
      "targets": {
        "Type": "All",
        "RegionId": "cn-hangzhou",
        "Parameters": {
          "RegionId": "cn-hangzhou",
          "Status": "Running",
          "Tags": [
            {
              "Key": "key1",
              "Value": "value1"
            }
          ]
        }
      }
    }
  • 根據指定配置清單條件選擇

    targets:
        Type: Inventory
        RegionId: cn-hangzhou
        InventoryFilters:
          - Name: TypeName
            Operator: Equal
            Value:
              - ACS:InstanceInformation
          - Name: ACS:InstanceInformation.Status
            Value:
              - Running
            Operator: Equal
    {
      "targets": {
        "Type": "Inventory",
        "RegionId": "cn-hangzhou",
        "InventoryFilters": [
          {
            "Name": "TypeName",
            "Operator": "Equal",
            "Value": [
              "ACS:InstanceInformation"
            ]
          },
          {
            "Name": "ACS:InstanceInformation.Status",
            "Value": [
              "Running"
            ],
            "Operator": "Equal"
          }
        ]
      }
    }

選擇計算巢服務執行個體Targets參數樣本

  • 擷取計算巢服務執行個體模板樣本

    FormatVersion: OOS-2019-06-01
    Parameters:
      RegionId:
        Type: String
        Label:
          en: RegionId
          zh-cn: 地區ID
        AssociationProperty: RegionId
        Default: '{{ ACS::RegionId }}'
      Targets:
        Type: Json
        Label:
          en: TargetInstance
          zh-cn: 目標執行個體
        AssociationProperty: Targets
        AssociationPropertyMetadata:
          ResourceType: ALIYUN::ComputeNestSupplier::Instance
          RegionId: RegionId
      RateControl:
        Label:
          en: RateControl
          zh-cn: 任務執行的並發比率
        Type: Json
        AssociationProperty: RateControl
        Default:
          Mode: Concurrency
          MaxErrors: 0
          Concurrency: 1
      OOSAssumeRole:
        Label:
          en: OOSAssumeRole
          zh-cn: OOS扮演的RAM角色
        Type: String
    RamRole: '{{ OOSAssumeRole }}'
    Tasks:
      - Name: GetServiceInstance
        Description:
          en: Views the compute nest supplier instances
          zh-cn: 計算巢商家側擷取服務執行個體
        Action: ACS::SelectTargets
        Properties:
          ResourceType: ALIYUN::ComputeNestSupplier::Instance
          RegionId: '{{ RegionId }}'
          Filters:
            - '{{ Targets }}'
        Outputs:
          InstanceIds:
            Type: List
            ValueSelector: ServiceInstances[].ServiceInstanceId
    Metadata:
      ALIYUN::OOS::Interface:
        ParameterGroups:
          - Parameters:
              - RegionId
              - Targets
            Label:
              default:
                zh-cn: 配置參數
                en: Configure Parameters
          - Parameters:
              - RateControl
              - OOSAssumeRole
            Label:
              default:
                zh-cn: 進階選項
                en: Control Options
    {
      "FormatVersion": "OOS-2019-06-01",
      "Parameters": {
        "RegionId": {
          "Type": "String",
          "Label": {
            "en": "RegionId",
            "zh-cn": "地區ID"
          },
          "AssociationProperty": "RegionId",
          "Default": "{{ ACS::RegionId }}"
        },
        "Targets": {
          "Type": "Json",
          "Label": {
            "en": "TargetInstance",
            "zh-cn": "目標執行個體"
          },
          "AssociationProperty": "Targets",
          "AssociationPropertyMetadata": {
            "ResourceType": "ALIYUN::ComputeNestSupplier::Instance",
            "RegionId": "RegionId"
          }
        },
        "RateControl": {
          "Label": {
            "en": "RateControl",
            "zh-cn": "任務執行的並發比率"
          },
          "Type": "Json",
          "AssociationProperty": "RateControl",
          "Default": {
            "Mode": "Concurrency",
            "MaxErrors": 0,
            "Concurrency": 1
          }
        },
        "OOSAssumeRole": {
          "Label": {
            "en": "OOSAssumeRole",
            "zh-cn": "OOS扮演的RAM角色"
          },
          "Type": "String"
        }
      },
      "RamRole": "{{ OOSAssumeRole }}",
      "Tasks": [
        {
          "Name": "GetServiceInstance",
          "Description": {
            "en": "Views the compute nest supplier instances",
            "zh-cn": "計算巢商家側擷取服務執行個體"
          },
          "Action": "ACS::SelectTargets",
          "Properties": {
            "ResourceType": "ALIYUN::ComputeNestSupplier::Instance",
            "RegionId": "{{ RegionId }}",
            "Filters": [
              "{{ Targets }}"
            ]
          },
          "Outputs": {
            "InstanceIds": {
              "Type": "List",
              "ValueSelector": "ServiceInstances[].ServiceInstanceId"
            }
          }
        }
      ],
      "Metadata": {
        "ALIYUN::OOS::Interface": {
          "ParameterGroups": [
            {
              "Parameters": [
                "RegionId",
                "Targets"
              ],
              "Label": {
                "default": {
                  "zh-cn": "配置參數",
                  "en": "Configure Parameters"
                }
              }
            },
            {
              "Parameters": [
                "RateControl",
                "OOSAssumeRole"
              ],
              "Label": {
                "default": {
                  "zh-cn": "進階選項",
                  "en": "Control Options"
                }
              }
            }
          ]
        }
      }
    }
  • 根據執行個體ID選擇參數樣本

    targets:
      ResourceIds:
        - si-9b136xxxxxxxxxxxxxxx
        - si-f63edxxxxxxxxxxxxxxx
      RegionId: cn-hangzhou
      Type: ResourceIds
    {
      "targets": {
        "ResourceIds": [
          "si-9b1363ae63664f19a156",
          "si-f63ed519cc3445eebdcd"
        ],
        "RegionId": "cn-hangzhou",
        "Type": "ResourceIds"
      }
    }
  • 選擇杭州地區服務Id為“"service-xxxx”版本為“4”且狀態為已部署的全部服務執行個體

    targets:
      Type: All
      RegionId: cn-hangzhou
      Parameters:
        Filter:
          - Name: Status
            Value:
              - Deployed
          - Name: 'Version '
            Value:
              - '4'
          - Name: ServiceId
            Value:
              - ervice-ea89c844c3e9430a9b9c
        RegionId: cn-hangzhou
    {
    	"targets": {
    		"Type": "All",
    		"RegionId": "cn-hangzhou",
    		"Parameters": {
    			"Filter": [{
    					"Name": "Status",
    					"Value": [
    						"Deployed"
    					]
    				},
    				{
    					"Name": "Version ",
    					"Value": ["4"]
    				},
    				{
    					"Name": "ServiceId",
    					"Value": ["ervice-ea89c844c3e9430a9b9c"]
    				}
    			],
    			"RegionId": "cn-hangzhou"
    		}
    	}
    }
  • 通過標籤選擇ECS執行個體並執行命令模板

    FormatVersion: OOS-2019-06-01
    Description:
      en: Query instances through tags and execute commands..
      zh-cn: 通過標籤查詢執行個體並執行命令。
      name-en: Run Command
      name-zh-cn: 發送遠程命令
      categories:
        - run_command
        - application_manage
        - computenest
        - tag_operate_resource
    Parameters:
      regionId:
        Type: String
        Label:
          en: RegionId
          zh-cn: 地區ID
        AssociationProperty: RegionId
        Default: '{{ ACS::RegionId }}'
      tags:
        Description:
          name-en: Tags
          name-zh-cn: 標籤
          en: format:[{"Key":"k1","Value":"v1"},{"Key":"k2","Value":"v2"}....].
          zh-cn: 輸入格式:[{"Key":"k1","Value":"v1"},{"Key":"k2","Value":"v2"}....]
        Type: Json
        AssociationProperty: Tags
      commandType:
        Label:
          en: CommandType
          zh-cn: 命令類型
        AssociationPropertyMetadata:
          LocaleKey: ECSCommandType
        Type: String
        AllowedValues:
          - RunShellScript
          - RunPythonScript
          - RunPerlScript
          - RunBatScript
          - RunPowerShellScript
        Default: RunShellScript
      commandContent:
        Label:
          en: CommandContent
          zh-cn: 命令內容
        Type: String
        MaxLength: 16384
        AssociationProperty: ALIYUN::OOS::Command::CommandContent
        AssociationPropertyMetadata:
          CommandType: ${commandType}
      workingDir:
        Description:
          en: 'Linux instances: under the home directory of the administrator (root user): /root.Windows instances: under the directory where the process of the Cloud Assistant client is located, such asC:\Windows\System32. Please ensure you input the correct directory.'
          zh-cn: Linux系統執行個體預設在管理員(root使用者)的home目錄下,即/root。Windows系統執行個體預設在雲助手用戶端進程所在目錄,例如C:\Windows\System32。請確保您輸入的目錄是正確的。'
        Label:
          en: WorkingDir
          zh-cn: 運行目錄
        Type: String
        Default: ''
        AssociationPropertyMetadata:
          Value:
            - Condition:
                Fn::Or:
                  - Fn::Equals:
                      - ${commandType}
                      - RunShellScript
                  - Fn::Equals:
                      - ${commandType}
                      - RunPythonScript
                  - Fn::Equals:
                      - ${commandType}
                      - RunPerlScript
              Value: /root
            - Condition:
                Fn::Or:
                  - Fn::Equals:
                      - ${commandType}
                      - RunBatScript
                  - Fn::Equals:
                      - ${commandType}
                      - RunPowerShellScript
              Value: C:\\Windows\\System32
      timeout:
        Label:
          en: Timeout
          zh-cn: 逾時時間
        Type: Number
        Default: 600
      enableParameter:
        Label:
          en: EnableParameter
          zh-cn: 命令中是否包含加密參數或自訂參數
        Type: Boolean
        Default: false
      username:
        Description:
          en: The username that is used to run the command on the ECS instance, length must not exceed 255 characters. Linux system ECS instance, the default is root. Windows system ECS instance, the default is System. Please ensure you input the correct username. <a href="https://www.alibabacloud.com/help/doc-detail/203771.html" target="_blank">See more</a>
          zh-cn: 在ECS執行個體中執行命令的使用者名稱稱,長度不得超過255個字元。Linux系統的執行個體,預設以root使用者執行命令。Windows系統的執行個體,預設以System使用者執行命令。請確保您輸入的使用者名稱是正確的。<a href="https://www.alibabacloud.com/help/doc-detail/203771.html" target="_blank">瞭解更多</a>
        Label:
          en: Username
          zh-cn: 執行命令的使用者名稱稱
        Type: String
        Default: ''
      windowsPasswordName:
        Label:
          en: WindowsPasswordName
          zh-cn: 在Windows執行個體中執行命令的使用者的密碼名稱
        Type: String
        Default: ''
        AssociationProperty: ALIYUN::OOS::SecretParameter::Value
        AssociationPropertyMetadata:
          Visible:
            Condition:
              Fn::Or:
                - Fn::Equals:
                    - ${commandType}
                    - RunBatScript
                - Fn::Equals:
                    - ${commandType}
                    - RunPowerShellScript
      rateControl:
        Label:
          en: RateControl
          zh-cn: 任務執行的並發比率
        Type: Json
        AssociationProperty: RateControl
        Default:
          Mode: Concurrency
          MaxErrors: 0
          Concurrency: 10
      OOSAssumeRole:
        Label:
          en: OOSAssumeRole
          zh-cn: OOS扮演的RAM角色
        Type: String
        Default: ''
    RamRole: '{{ OOSAssumeRole }}'
    Tasks:
      - Name: ListInstance
        Action: ACS::ExecuteAPI
        Description:
          en: List the eips.
          zh-cn: 通過標籤查詢instance。
        Properties:
          Service: ECS
          API: ListTagResources
          Parameters:
            RegionId: '{{ regionId }}'
            ResourceType: instance
            Tag: '{{ tags }}'
        Outputs:
          instanceIds:
            Type: List
            ValueSelector: .TagResources.TagResource[].ResourceId
      - Name: runCommand
        Action: ACS::ECS::RunCommand
        Description:
          en: Execute cloud assistant command
          zh-cn: 執行雲助手命令
        Properties:
          regionId: '{{ regionId }}'
          commandContent: '{{ commandContent }}'
          instanceId: '{{ ACS::TaskLoopItem }}'
          commandType: '{{ commandType }}'
          workingDir: '{{ workingDir }}'
          timeout: '{{ timeout }}'
          enableParameter: '{{ enableParameter }}'
          username: '{{ username }}'
          windowsPasswordName: '{{ windowsPasswordName }}'
          contentEncoding: PlainText
          parameters: {}
          maxRetryInterval: 300
        Outputs:
          commandOutput:
            Type: String
            ValueSelector: invocationOutput
        Loop:
          Items: '{{ ListInstance.instanceIds }}'
          RateControl: '{{ rateControl }}'
          Outputs:
            commandOutputs:
              AggregateType: Fn::ListJoin
              AggregateField: commandOutput
    Outputs:
      commandOutputs:
        Type: List
        Value: '{{ runCommand.commandOutputs }}'
    Metadata:
      ALIYUN::OOS::Interface:
        ParameterGroups:
          - Parameters:
              - commandType
              - commandContent
              - workingDir
              - timeout
              - enableParameter
              - username
              - windowsPasswordName
            Label:
              default:
                zh-cn: 執行命令選型
                en: run command options
          - Parameters:
              - regionId
              - tags
            Label:
              default:
                zh-cn: 選擇執行個體
                en: Select Ecs Instances
          - Parameters:
              - rateControl
              - OOSAssumeRole
            Label:
              default:
                zh-cn: 進階選項
                en: Control Options
    
    {
      "FormatVersion": "OOS-2019-06-01",
      "Description": {
        "en": "Query instances through tags and execute commands..",
        "zh-cn": "通過標籤查詢執行個體並執行命令。",
        "name-en": "Run Command",
        "name-zh-cn": "發送遠程命令",
        "categories": [
          "run_command",
          "application_manage",
          "computenest",
          "tag_operate_resource"
        ]
      },
      "Parameters": {
        "regionId": {
          "Type": "String",
          "Label": {
            "en": "RegionId",
            "zh-cn": "地區ID"
          },
          "AssociationProperty": "RegionId",
          "Default": "{{ ACS::RegionId }}"
        },
        "tags": {
          "Description": {
            "name-en": "Tags",
            "name-zh-cn": "標籤",
            "en": "format:[{\"Key\":\"k1\",\"Value\":\"v1\"},{\"Key\":\"k2\",\"Value\":\"v2\"}....].",
            "zh-cn": "輸入格式:[{\"Key\":\"k1\",\"Value\":\"v1\"},{\"Key\":\"k2\",\"Value\":\"v2\"}....]"
          },
          "Type": "Json",
          "AssociationProperty": "Tags"
        },
        "commandType": {
          "Label": {
            "en": "CommandType",
            "zh-cn": "命令類型"
          },
          "AssociationPropertyMetadata": {
            "LocaleKey": "ECSCommandType"
          },
          "Type": "String",
          "AllowedValues": [
            "RunShellScript",
            "RunPythonScript",
            "RunPerlScript",
            "RunBatScript",
            "RunPowerShellScript"
          ],
          "Default": "RunShellScript"
        },
        "commandContent": {
          "Label": {
            "en": "CommandContent",
            "zh-cn": "命令內容"
          },
          "Type": "String",
          "MaxLength": 16384,
          "AssociationProperty": "ALIYUN::OOS::Command::CommandContent",
          "AssociationPropertyMetadata": {
            "CommandType": "${commandType}"
          }
        },
        "workingDir": {
          "Description": {
            "en": "Linux instances: under the home directory of the administrator (root user): /root.Windows instances: under the directory where the process of the Cloud Assistant client is located, such asC:\\Windows\\System32. Please ensure you input the correct directory.",
            "zh-cn": "Linux系統執行個體預設在管理員(root使用者)的home目錄下,即/root。Windows系統執行個體預設在雲助手用戶端進程所在目錄,例如C:\\Windows\\System32。請確保您輸入的目錄是正確的。'"
          },
          "Label": {
            "en": "WorkingDir",
            "zh-cn": "運行目錄"
          },
          "Type": "String",
          "Default": "",
          "AssociationPropertyMetadata": {
            "Value": [
              {
                "Condition": {
                  "Fn::Or": [
                    {
                      "Fn::Equals": [
                        "${commandType}",
                        "RunShellScript"
                      ]
                    },
                    {
                      "Fn::Equals": [
                        "${commandType}",
                        "RunPythonScript"
                      ]
                    },
                    {
                      "Fn::Equals": [
                        "${commandType}",
                        "RunPerlScript"
                      ]
                    }
                  ]
                },
                "Value": "/root"
              },
              {
                "Condition": {
                  "Fn::Or": [
                    {
                      "Fn::Equals": [
                        "${commandType}",
                        "RunBatScript"
                      ]
                    },
                    {
                      "Fn::Equals": [
                        "${commandType}",
                        "RunPowerShellScript"
                      ]
                    }
                  ]
                },
                "Value": "C:\\\\Windows\\\\System32"
              }
            ]
          }
        },
        "timeout": {
          "Label": {
            "en": "Timeout",
            "zh-cn": "逾時時間"
          },
          "Type": "Number",
          "Default": 600
        },
        "enableParameter": {
          "Label": {
            "en": "EnableParameter",
            "zh-cn": "命令中是否包含加密參數或自訂參數"
          },
          "Type": "Boolean",
          "Default": false
        },
        "username": {
          "Description": {
            "en": "The username that is used to run the command on the ECS instance, length must not exceed 255 characters. Linux system ECS instance, the default is root. Windows system ECS instance, the default is System. Please ensure you input the correct username. <a href=\"https://www.alibabacloud.com/help/doc-detail/203771.html\" target=\"_blank\">See more</a>",
            "zh-cn": "在ECS執行個體中執行命令的使用者名稱稱,長度不得超過255個字元。Linux系統的執行個體,預設以root使用者執行命令。Windows系統的執行個體,預設以System使用者執行命令。請確保您輸入的使用者名稱是正確的。<a href=\"https://www.alibabacloud.com/help/doc-detail/203771.html\" target=\"_blank\">瞭解更多</a>"
          },
          "Label": {
            "en": "Username",
            "zh-cn": "執行命令的使用者名稱稱"
          },
          "Type": "String",
          "Default": ""
        },
        "windowsPasswordName": {
          "Label": {
            "en": "WindowsPasswordName",
            "zh-cn": "在Windows執行個體中執行命令的使用者的密碼名稱"
          },
          "Type": "String",
          "Default": "",
          "AssociationProperty": "ALIYUN::OOS::SecretParameter::Value",
          "AssociationPropertyMetadata": {
            "Visible": {
              "Condition": {
                "Fn::Or": [
                  {
                    "Fn::Equals": [
                      "${commandType}",
                      "RunBatScript"
                    ]
                  },
                  {
                    "Fn::Equals": [
                      "${commandType}",
                      "RunPowerShellScript"
                    ]
                  }
                ]
              }
            }
          }
        },
        "rateControl": {
          "Label": {
            "en": "RateControl",
            "zh-cn": "任務執行的並發比率"
          },
          "Type": "Json",
          "AssociationProperty": "RateControl",
          "Default": {
            "Mode": "Concurrency",
            "MaxErrors": 0,
            "Concurrency": 10
          }
        },
        "OOSAssumeRole": {
          "Label": {
            "en": "OOSAssumeRole",
            "zh-cn": "OOS扮演的RAM角色"
          },
          "Type": "String",
          "Default": ""
        }
      },
      "RamRole": "{{ OOSAssumeRole }}",
      "Tasks": [
        {
          "Name": "ListInstance",
          "Action": "ACS::ExecuteAPI",
          "Description": {
            "en": "List the eips.",
            "zh-cn": "通過標籤查詢instance。"
          },
          "Properties": {
            "Service": "ECS",
            "API": "ListTagResources",
            "Parameters": {
              "RegionId": "{{ regionId }}",
              "ResourceType": "instance",
              "Tag": "{{ tags }}"
            }
          },
          "Outputs": {
            "instanceIds": {
              "Type": "List",
              "ValueSelector": ".TagResources.TagResource[].ResourceId"
            }
          }
        },
        {
          "Name": "runCommand",
          "Action": "ACS::ECS::RunCommand",
          "Description": {
            "en": "Execute cloud assistant command",
            "zh-cn": "執行雲助手命令"
          },
          "Properties": {
            "regionId": "{{ regionId }}",
            "commandContent": "{{ commandContent }}",
            "instanceId": "{{ ACS::TaskLoopItem }}",
            "commandType": "{{ commandType }}",
            "workingDir": "{{ workingDir }}",
            "timeout": "{{ timeout }}",
            "enableParameter": "{{ enableParameter }}",
            "username": "{{ username }}",
            "windowsPasswordName": "{{ windowsPasswordName }}",
            "contentEncoding": "PlainText",
            "parameters": {},
            "maxRetryInterval": 300
          },
          "Outputs": {
            "commandOutput": {
              "Type": "String",
              "ValueSelector": "invocationOutput"
            }
          },
          "Loop": {
            "Items": "{{ ListInstance.instanceIds }}",
            "RateControl": "{{ rateControl }}",
            "Outputs": {
              "commandOutputs": {
                "AggregateType": "Fn::ListJoin",
                "AggregateField": "commandOutput"
              }
            }
          }
        }
      ],
      "Outputs": {
        "commandOutputs": {
          "Type": "List",
          "Value": "{{ runCommand.commandOutputs }}"
        }
      },
      "Metadata": {
        "ALIYUN::OOS::Interface": {
          "ParameterGroups": [
            {
              "Parameters": [
                "commandType",
                "commandContent",
                "workingDir",
                "timeout",
                "enableParameter",
                "username",
                "windowsPasswordName"
              ],
              "Label": {
                "default": {
                  "zh-cn": "執行命令選型",
                  "en": "run command options"
                }
              }
            },
            {
              "Parameters": [
                "regionId",
                "tags"
              ],
              "Label": {
                "default": {
                  "zh-cn": "選擇執行個體",
                  "en": "Select Ecs Instances"
                }
              }
            },
            {
              "Parameters": [
                "rateControl",
                "OOSAssumeRole"
              ],
              "Label": {
                "default": {
                  "zh-cn": "進階選項",
                  "en": "Control Options"
                }
              }
            }
          ]
        }
      }
    }