All Products
Search
Document Center

Resource Orchestration Service:ALIYUN::ECS::Invocation

Last Updated:May 06, 2023

ALIYUN::ECS::Invocation is used to run a Cloud Assistant command on Elastic Compute Service (ECS) instances.

Syntax

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

Properties

Property

Type

Required

Editable

Description

Constraint

Timed

Boolean

No

No

Specifies whether to run the command on a schedule.

Valid values:

  • true

  • false (default)

Frequency

String

No

No

The schedule on which to run the command. For more information about the value specifications, see Cron expressions.

The interval between two consecutive command executions must be at least 10 seconds. This property must be specified when Timed is set to true.

CommandId

String

No

Yes

The command ID.

None.

InstanceIds

List

Yes

Yes

The IDs of the instances on which you want to run the command.

You can specify up to 20 instance IDs.

Parameters

Map

No

Yes

The key-value pairs of the custom parameters that are passed in 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 encoded in Base64, the total size can be up to 16 KB.

The custom parameter names that are specified in Parameters must be included in the custom parameter names that you specified when you created 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 in synchronous mode.

Valid values:

  • true: runs the command in synchronous mode.

  • false: runs the command in asynchronous mode.

CommandName

String

No

No

The name of the command.

None.

Return values

Fn::GetAtt

InvokeId: the ID of the command invocation.

InvokeInstances: the instances on which the command is run.

Note

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

Examples

  • YAML format

    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                   
  • JSON format

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