Tous les produits
Search
Centre de documentation

CloudOps Orchestration Service:Select target resources: ACS::SelectTargets

Dernière mise à jour :Aug 11, 2026

Cette action permet de sélectionner des ressources par lot lors de la définition des paramètres.

Objectif

Lorsque vous créez une exécution basée sur un modèle utilisant l'action ACS::SelectTargets avec le paramètre AssociationProperty défini sur Targets, vous pouvez changer de méthode de sélection des ressources sans modifier le modèle. Lors de la création d'une exécution, sélectionnez plusieurs ressources simultanément en utilisant l'une des méthodes suivantes : sélection de ressources spécifiques, spécification de tags de ressource, sélection de toutes les ressources, téléchargement d'un fichier CSV contenant les ID de ressource ou spécification d'un inventaire.

selecttargets

Syntaxe

FormatVersion: OOS-2019-06-01
Description: 'ACS::SelectTargets usage'
Parameters:
  targets:  # The parameter name used to select the resource scope.
    Type: Json  # The parameter type. This must be Json.
    AssociationProperty: Targets    # The action associated with the parameter. For ACS::SelectTargets, this must be Targets.
    AssociationPropertyMetadata:  # The definition of the resources to select.
      ResourceType: ALIYUN::ECS::Instance # The type of resources to select.
                    # ALIYUN::ECS::Instance: The resources are ECS instances.
                    # ALIYUN::ECD::Desktop: The resources are Cloud Desktop instances.
                    # ALIYUN::RDS::Instance: The resources are ApsaraDB RDS instances.
                    # ALIYUN::Redis::Instance: The resources are Redis instances.
                    # ALIYUN::MongoDB::Instance: The resources are MongoDB instances.
                    # ALIYUN::ECS::ManagedInstance: The resources are managed instances.
                    # ALIYUN::ComputeNestSupplier::Instance: The resources are Compute Nest service instances.
                    # ALIYUN::SWAS::Instance: The resources are Simple Application Server instances.
Tasks:
  - Name: getInstance # The task name.
    Action: 'ACS::SelectTargets'  # The action to select specific resources.
    Properties:
      ResourceType: 'ALIYUN::ECS::Instance'  # The type of resources to select.
      Filters: # The scope to filter.
        - '{{ targets }}'  # The name of the parameter for the resource scope.
    Outputs:  # The task output.
      instanceIds: # The name of the output parameter.
        Type: List  # The type of the output parameter.
        ValueSelector: 'Instances.Instance[].InstanceId'  # A jq selector. It filters the results returned by the Describe OpenAPI operation for the resource type. For example, for ECS instances, the filter object is the result of the DescribeInstances OpenAPI operation.
{
  "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"
        }
      }
    }
  ]
}

Modèles d'exemple

  • Démarrer des instances ECS par lot

    FormatVersion: OOS-2019-06-01
    Description:
      en: Starts ECS instances in bulk.
      name-en: ACS-ECS-BulkyStartInstances
      categories:
        - instance_manage
    Parameters:
      targets:
        Type: Json
        AssociationProperty: Targets
        AssociationPropertyMetadata:
          ResourceType: 'ALIYUN::ECS::Instance'
      rateControl:
        Description:
          en: Concurrency ratio of task execution.
        Type: Json
        AssociationProperty: RateControl
        Default:
          Mode: Concurrency
          MaxErrors: 0
          Concurrency: 10
      OOSAssumeRole:
        Description:
          en: The RAM role to be assumed by OOS.
        Type: String
        Default: OOSServiceRole
    RamRole: '{{ OOSAssumeRole }}'
    Tasks:
      - Name: getInstance
        Description:
          en: Views the ECS instances.
        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.
        Properties:
          instanceId: '{{ ACS::TaskLoopItem }}'
        Loop:
          RateControl: '{{ rateControl }}'
          Items: '{{ getInstance.instanceIds }}'
    Outputs:
      instanceIds:
        Type: List
        Value: '{{ getInstance.instanceIds }}'
    {
      "FormatVersion": "OOS-2019-06-01",
      "Description": {
        "en": "Starts ECS instances in bulk.",
        "name-en": "ACS-ECS-BulkyStartInstances",
        "categories": [
          "instance_manage"
        ]
      },
      "Parameters": {
        "targets": {
          "Type": "Json",
          "AssociationProperty": "Targets",
          "AssociationPropertyMetadata": {
            "ResourceType": "ALIYUN::ECS::Instance"
          }
        },
        "rateControl": {
          "Description": {
            "en": "Concurrency ratio of task execution."
          },
          "Type": "Json",
          "AssociationProperty": "RateControl",
          "Default": {
            "Mode": "Concurrency",
            "MaxErrors": 0,
            "Concurrency": 10
          }
        },
        "OOSAssumeRole": {
          "Description": {
            "en": "The RAM role to be assumed by OOS."
          },
          "Type": "String",
          "Default": "OOSServiceRole"
        }
      },
      "RamRole": "{{ OOSAssumeRole }}",
      "Tasks": [
        {
          "Name": "getInstance",
          "Description": {
            "en": "Gets the ECS instances."
          },
          "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 instance."
          },
          "Properties": {
            "instanceId": "{{ ACS::TaskLoopItem }}"
          },
          "Loop": {
            "RateControl": "{{ rateControl }}",
            "Items": "{{ getInstance.instanceIds }}"
          }
        }
      ],
      "Outputs": {
        "instanceIds": {
          "Type": "List",
          "Value": "{{ getInstance.instanceIds }}"
        }
      }
    }

Exemples de configuration du paramètre targets pour sélectionner des instances ECS à l'aide de différentes méthodes

  • Sélection par ID d'instance.

    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"
        ]
      }
    }
  • Sélection des instances selon leurs tags. Vous pouvez sélectionner au maximum 1 000 instances. Pour en sélectionner davantage, consultez la section ACS::SelectTargets.

    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"
          }
        ]
      }
    }
  • Sélection par groupe de ressources

    targets:
      Type: ResourceGroup
      RegionId: cn-hangzhou
      ResourceGroupId: rg-acf*********re3y
    {
      "targets": {
        "Type": "ResourceGroup",
        "RegionId": "cn-hangzhou",
        "ResourceGroupId": "rg-acf*********re3y"
      }
    }
  • Sélection de toutes les instances ECS

    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"
            }
          ]
        }
      }
    }
  • Sélection basée sur les critères spécifiés dans le manifeste d'inventaire.

    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"
          }
        ]
      }
    }

    Sélection des instances par ID au sein d'un groupe d'applications spécifié

    targets:
      ResourceIds:
        - i-001
        - i-002
      ApplicationName: 'test'
      ApplicationGroupName: 'test'
      RegionId: cn-hangzhou
      Type: ApplicationGroup
    {
      "targets": {
        "ResourceIds": [
          "i-001",
          "i-002"
        ],
        "ApplicationName": "test",
        "ApplicationGroupName": "test",
        "RegionId": "cn-hangzhou",
        "Type": "ApplicationGroup"
      }
    }

    Sélection de toutes les instances d'un groupe d'applications spécifié

    targets:
      ApplicationName: 'test'
      ApplicationGroupName: 'test'
      RegionId: cn-hangzhou
      Type: ApplicationGroup
    {
      "targets": {
        "ApplicationName": "test",
        "ApplicationGroupName": "test",
        "RegionId": "cn-hangzhou",
        "Type": "ApplicationGroup"
      }
    }

Exemples de configuration du paramètre targets pour sélectionner des instances de service Compute Nest

  • Obtenir un modèle d'exemple pour une instance Compute Nest

    FormatVersion: OOS-2019-06-01
    Parameters:
      RegionId:
        Type: String
        Label:
          en: RegionId
          zh-cn: Region ID
        AssociationProperty: RegionId
        Default: '{{ ACS::RegionId }}'
      Targets:
        Type: Json
        Label:
          en: TargetInstance
          zh-cn: Target Instance
        AssociationProperty: Targets
        AssociationPropertyMetadata:
          ResourceType: ALIYUN::ComputeNestSupplier::Instance
          RegionId: RegionId
      RateControl:
        Label:
          en: RateControl
          zh-cn: Concurrency rate for task execution
        Type: Json
        AssociationProperty: RateControl
        Default:
          Mode: Concurrency
          MaxErrors: 0
          Concurrency: 1
      OOSAssumeRole:
        Label:
          en: OOSAssumeRole
          zh-cn: RAM role to be assumed by OOS
        Type: String
    RamRole: '{{ OOSAssumeRole }}'
    Tasks:
      - Name: GetServiceInstance
        Description:
          en: Views the compute nest supplier instances
          zh-cn: Retrieves service instances from the supplier side of Compute Nest
        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: Configuration Parameters
                en: Configure Parameters
          - Parameters:
              - RateControl
              - OOSAssumeRole
            Label:
              default:
                zh-cn: Advanced Options
                en: Control Options
    {
      "FormatVersion": "OOS-2019-06-01",
      "Parameters": {
        "RegionId": {
          "Type": "String",
          "Label": {
            "en": "RegionId",
            "zh-cn": "Region ID"
          },
          "AssociationProperty": "RegionId",
          "Default": "{{ ACS::RegionId }}"
        },
        "Targets": {
          "Type": "Json",
          "Label": {
            "en": "TargetInstance",
            "zh-cn": "Target Instance"
          },
          "AssociationProperty": "Targets",
          "AssociationPropertyMetadata": {
            "ResourceType": "ALIYUN::ComputeNestSupplier::Instance",
            "RegionId": "RegionId"
          }
        },
        "RateControl": {
          "Label": {
            "en": "RateControl",
            "zh-cn": "Concurrency rate for task execution"
          },
          "Type": "Json",
          "AssociationProperty": "RateControl",
          "Default": {
            "Mode": "Concurrency",
            "MaxErrors": 0,
            "Concurrency": 1
          }
        },
        "OOSAssumeRole": {
          "Label": {
            "en": "OOSAssumeRole",
            "zh-cn": "The RAM role that OOS assumes"
          },
          "Type": "String"
        }
      },
      "RamRole": "{{ OOSAssumeRole }}",
      "Tasks": [
        {
          "Name": "GetServiceInstance",
          "Description": {
            "en": "Views the compute nest supplier instances",
            "zh-cn": "Retrieve service instances on the supplier side of Compute Nest"
          },
          "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": "Configuration Parameters",
                  "en": "Configure Parameters"
                }
              }
            },
            {
              "Parameters": [
                "RateControl",
                "OOSAssumeRole"
              ],
              "Label": {
                "default": {
                  "zh-cn": "Advanced Options",
                  "en": "Control Options"
                }
              }
            }
          ]
        }
      }
    }
  • Exemple : sélection des paramètres par ID d'instance

    targets:
      ResourceIds:
        - si-9b136xxxxxxxxxxxxxxx
        - si-f63edxxxxxxxxxxxxxxx
      RegionId: cn-hangzhou
      Type: ResourceIds
    {
      "targets": {
        "ResourceIds": [
          "si-9b1363ae63664f19a156",
          "si-f63ed519cc3445eebdcd"
        ],
        "RegionId": "cn-hangzhou",
        "Type": "ResourceIds"
      }
    }
  • Sélectionner toutes les instances de service déployées dans la région Chine (Hangzhou), dont les ID de service sont au format service-xxxx et dont la version de service est 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"
    		}
    	}
    }
  • Sélectionner des instances ECS par tag et exécuter des modèles de commande.

    FormatVersion: OOS-2019-06-01
    Description:
      en: Queries instances using tags and executes commands.
      zh-cn: Queries instances using tags and executes commands.
      name-en: Run Command
      name-zh-cn: Run Command
      categories:
        - run_command
        - application_manage
        - computenest
        - tag_operate_resource
    Parameters:
      regionId:
        Type: String
        Label:
          en: Region ID
          zh-cn: Region ID
        AssociationProperty: RegionId
        Default: '{{ ACS::RegionId }}'
      tags:
        Description:
          name-en: Tags
          name-zh-cn: Tags
          en: 'Format: [{"Key":"k1","Value":"v1"},{"Key":"k2","Value":"v2"}....].'
          zh-cn: 'Format: [{"Key":"k1","Value":"v1"},{"Key":"k2","Value":"v2"}....].'
        Type: Json
        AssociationProperty: Tags
      commandType:
        Label:
          en: Command Type
          zh-cn: Command Type
        AssociationPropertyMetadata:
          LocaleKey: ECSCommandType
        Type: String
        AllowedValues:
          - RunShellScript
          - RunPythonScript
          - RunPerlScript
          - RunBatScript
          - RunPowerShellScript
        Default: RunShellScript
      commandContent:
        Label:
          en: Command Content
          zh-cn: Command Content
        Type: String
        MaxLength: 16384
        AssociationProperty: ALIYUN::OOS::Command::CommandContent
        AssociationPropertyMetadata:
          CommandType: ${commandType}
      workingDir:
        Description:
          en: 'For Linux instances, the default working directory is the home directory of the administrator (root user), which is /root. For Windows instances, the default working directory is the directory where the Cloud Assistant client process is located, such as C:\Windows\System32. Make sure that you enter a valid directory.'
          zh-cn: 'For Linux instances, the default working directory is the home directory of the administrator (root user), which is /root. For Windows instances, the default working directory is the directory where the Cloud Assistant client process is located, such as C:\Windows\System32. Make sure that you enter a valid directory.'
        Label:
          en: Working Directory
          zh-cn: Working Directory
        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: Timeout
        Type: Number
        Default: 600
      enableParameter:
        Label:
          en: Enable Custom or Encrypted Parameters
          zh-cn: Enable Custom or Encrypted Parameters
        Type: Boolean
        Default: false
      username:
        Description:
          en: The username used to run the command on the ECS instance. The username can be up to 255 characters in length. By default, commands are run as the root user on Linux instances and as the System user on Windows instances. Make sure that the username you enter is correct. <a href="https://www.alibabacloud.com/help/doc-detail/203771.html" target="_blank">Learn more</a>
          zh-cn: The username used to run the command on the ECS instance. The username can be up to 255 characters in length. By default, commands are run as the root user on Linux instances and as the System user on Windows instances. Make sure that the username you enter is correct. <a href="https://www.alibabacloud.com/help/doc-detail/203771.html" target="_blank">Learn more</a>
        Label:
          en: Username
          zh-cn: Username
        Type: String
        Default: ''
      windowsPasswordName:
        Label:
          en: Password Name for Windows User
          zh-cn: Password Name for Windows User
        Type: String
        Default: ''
        AssociationProperty: ALIYUN::OOS::SecretParameter::Value
        AssociationPropertyMetadata:
          Visible:
            Condition:
              Fn::Or:
                - Fn::Equals:
                    - ${commandType}
                    - RunBatScript
                - Fn::Equals:
                    - ${commandType}
                    - RunPowerShellScript
      rateControl:
        Label:
          en: Task Execution Concurrency
          zh-cn: Task Execution Concurrency
        Type: Json
        AssociationProperty: RateControl
        Default:
          Mode: Concurrency
          MaxErrors: 0
          Concurrency: 10
      OOSAssumeRole:
        Label:
          en: RAM Role for OOS
          zh-cn: RAM Role for OOS
        Type: String
        Default: ''
    RamRole: '{{ OOSAssumeRole }}'
    Tasks:
      - Name: ListInstance
        Action: ACS::ExecuteAPI
        Description:
          en: Queries instances using tags.
          zh-cn: Queries instances using tags.
        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: Runs a Cloud Assistant command.
          zh-cn: Runs a Cloud Assistant command.
        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: Run Command Options
                en: Run Command Options
          - Parameters:
              - regionId
              - tags
            Label:
              default:
                zh-cn: Select ECS Instances
                en: Select ECS Instances
          - Parameters:
              - rateControl
              - OOSAssumeRole
            Label:
              default:
                zh-cn: Advanced Options
                en: Advanced Options
    
    {
      "FormatVersion": "OOS-2019-06-01",
      "Description": {
        "en": "Query instances through tags and execute commands..",
        "zh-cn": "Query instances using tags and execute commands.",
        "name-en": "Run Command",
        "name-zh-cn": "Run Command",
        "categories": [
          "run_command",
          "application_manage",
          "computenest",
          "tag_operate_resource"
        ]
      },
      "Parameters": {
        "regionId": {
          "Type": "String",
          "Label": {
            "en": "RegionId",
            "zh-cn": "Region ID"
          },
          "AssociationProperty": "RegionId",
          "Default": "{{ ACS::RegionId }}"
        },
        "tags": {
          "Description": {
            "name-en": "Tags",
            "name-zh-cn": "Tags",
            "en": "format:[{\"Key\":\"k1\",\"Value\":\"v1\"},{\"Key\":\"k2\",\"Value\":\"v2\"}....].",
            "zh-cn": "Input format: [{\"Key\":\"k1\",\"Value\":\"v1\"},{\"Key\":\"k2\",\"Value\":\"v2\"}....]"
          },
          "Type": "Json",
          "AssociationProperty": "Tags"
        },
        "commandType": {
          "Label": {
            "en": "CommandType",
            "zh-cn": "Command Type"
          },
          "AssociationPropertyMetadata": {
            "LocaleKey": "ECSCommandType"
          },
          "Type": "String",
          "AllowedValues": [
            "RunShellScript",
            "RunPythonScript",
            "RunPerlScript",
            "RunBatScript",
            "RunPowerShellScript"
          ],
          "Default": "RunShellScript"
        },
        "commandContent": {
          "Label": {
            "en": "CommandContent",
            "zh-cn": "Command Content"
          },
          "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": "For Linux instances, the default working directory is the home directory of the administrator (root user), which is /root. For Windows instances, the default working directory is the directory where the Cloud Assistant client process is located, such as C:\\Windows\\System32. Make sure that the directory you enter is correct."
          },
          "Label": {
            "en": "WorkingDir",
            "zh-cn": "Working Directory"
          },
          "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": "Timeout"
          },
          "Type": "Number",
          "Default": 600
        },
        "enableParameter": {
          "Label": {
            "en": "EnableParameter",
            "zh-cn": "Enable encrypted or custom parameters"
          },
          "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": "The name of the user that runs the command on the ECS instance. The name can be up to 255 characters in length. For Linux instances, the command is run by the root user by default. For Windows instances, the command is run by the System user by default. Make sure that the username you enter is correct. <a href=\"https://www.alibabacloud.com/help/doc-detail/203771.html\" target=\"_blank\">Learn more</a>"
          },
          "Label": {
            "en": "Username",
            "zh-cn": "Username"
          },
          "Type": "String",
          "Default": ""
        },
        "windowsPasswordName": {
          "Label": {
            "en": "WindowsPasswordName",
            "zh-cn": "Password name for Windows user"
          },
          "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": "Rate control for task execution"
          },
          "Type": "Json",
          "AssociationProperty": "RateControl",
          "Default": {
            "Mode": "Concurrency",
            "MaxErrors": 0,
            "Concurrency": 10
          }
        },
        "OOSAssumeRole": {
          "Label": {
            "en": "OOSAssumeRole",
            "zh-cn": "RAM role for OOS to assume"
          },
          "Type": "String",
          "Default": ""
        }
      },
      "RamRole": "{{ OOSAssumeRole }}",
      "Tasks": [
        {
          "Name": "ListInstance",
          "Action": "ACS::ExecuteAPI",
          "Description": {
            "en": "List the eips.",
            "zh-cn": "Queries instances using tags."
          },
          "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": "Executes a Cloud Assistant command."
          },
          "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": "Command Execution Options",
                  "en": "run command options"
                }
              }
            },
            {
              "Parameters": [
                "regionId",
                "tags"
              ],
              "Label": {
                "default": {
                  "zh-cn": "Select Instances",
                  "en": "Select Ecs Instances"
                }
              }
            },
            {
              "Parameters": [
                "rateControl",
                "OOSAssumeRole"
              ],
              "Label": {
                "default": {
                  "zh-cn": "Advanced Options",
                  "en": "Control Options"
                }
              }
            }
          ]
        }
      }
    }