ALIYUN::ECS::Invocation is used to run a Cloud Assistant command for one or more Elastic Compute Service (ECS) instances.

Syntax

{
  "Type": "ALIYUN::ECS::Invocation",
  "Properties": {
    "Timed": Boolean,
    "Frequency": String,
    "CommandId": String,
    "Parameters": Map,
    "InstanceIds": List, 
    "Sync": Boolean
  }
}

Properties

Property Type Required Editable Description Constraint
Timed Boolean No No Specifies whether to run the command on a periodic basis. Default value: false. Valid values:
  • true
  • false
Frequency String No No The frequency at which the command is run on a periodic basis. For more information about the value of this property, see Cron expression. The interval at which the command is run on a periodic basis must be at least 10 seconds. This property is required if you set the Timed property to true.
CommandId String Yes Yes The ID of the command. None.
InstanceIds List Yes Yes The IDs of the instances for which you want to run the command. You can specify up to 50 instance IDs.
Parameters Map No Yes The key-value pairs of custom parameters that you want to pass to the command when the custom parameter feature is enabled. Example: {"name": "Jack", "accessKey": "LTAIdyv******aRY"}. You can specify up to 10 custom parameters.

Keys in a Map collection can be up to 64 characters in length and cannot be empty strings. Values in a Map collection can be empty strings.

After the custom parameters and the original command content are Base64-encoded, the total size cannot exceed 16 KB.

The set of custom parameter names must be a subset of the parameter set that you specify when you create the command. You can use empty strings to represent the custom parameters that are not specified.

Sync Boolean No No Specifies whether to run the command synchronously. Valid values:
  • true: runs the command synchronously.
  • false: runs the command asynchronously.

Return values

Fn::GetAtt

InvokeId: the invocation ID of the command.

InvokeInstances: the instances for which the command is run.

Note If you want to run the command only once, see ALIYUN::ECS::RunCommand.

Examples

  • YAMLformat

    ROSTemplateFormatVersion: '2015-09-01'
    Parameters:
      CommandId:
        Type: String
        Description: The id of command.
      InstanceId:
        Type: String
        AssociationProperty: ALIYUN::ECS::Instance::InstanceId
    Resources:
      Invocation:
        Type: ALIYUN::ECS::Invocation
        Properties:
          CommandId:
            Ref: CommandId
          InstanceIds:
            - Ref: InstanceId
    Outputs:
      InvokeId:
        Description: The id of command execution.
        Value:
          Fn::GetAtt:
            - Invocation
            - InvokeId                   
  • JSONformat

    {
      "ROSTemplateFormatVersion": "2015-09-01",
      "Parameters": {
        "CommandId": {
          "Type": "String",
          "Description": "The id of command."
        },
        "InstanceId": {
          "Type": "String",
          "AssociationProperty": "ALIYUN::ECS::Instance::InstanceId"
        }
      },
      "Resources": {
        "Invocation": {
          "Type": "ALIYUN::ECS::Invocation",
          "Properties": {
            "CommandId": {
              "Ref": "CommandId"
            },
            "InstanceIds": [
              {
                "Ref": "InstanceId"
              }
            ]
          }
        }
      },
      "Outputs": {
        "InvokeId": {
          "Description": "The id of command execution.",
          "Value": {
            "Fn::GetAtt": [
              "Invocation",
              "InvokeId"
            ]
          }
        }
      }
    }