You can use ALIYUN::ECS::InstanceGroup to create multiple ECS instances at a time.

Specifically, use the InstanceName and HostName properties to define instance names and hostnames. You can use the following syntax to specify each instance name or hostname in Resource Orchestration Service (ROS): name_prefix[begin_number,bits]name_suffix.

The syntax is described as follows:

  • name_prefix: Required. The prefix of the instance name or hostname.
  • [begin_number,bits]: Required. The part that changes for each name. begin_number indicates the starting number of the instance name or hostname. bits indicates the number of digits of each number.

    This part must meet the following requirements to be correctly parsed:

    • begin_number and bits are separated by a comma only, and have no spaces.
    • The value of bits ranges from 1 to 4.
    • The value of begin_number ranges from 0 to 9999.

    The rules on the value of bits are as follows:

    • If you only specify a value for begin_number, the default value of bits is 4.
    • If you do not specify a value for begin_number or bits, begin_number is set to 0 and bits is set to 4.
    • If the specified value of begin_number has more digits than that specified in bits, the larger digit number takes effect. For example, in [1234,1], the value of begin_number is 1234 while the value of digits is 1. 1234 is a four-digit number within the valid value range of 0 to 9999. Therefore, the actual value of bits is 4.
  • name_suffix: Optional. The suffix of the instance name or hostname.

Examples

{
  "ROSTemplateFormatVersion" : "2015-09-01",
  "Resources" : {
    "WebServer": {
      "Type": "ALIYUN::ECS::InstanceGroup",
      "Properties": {
        "ImageId" : "CentOs*",
        "InstanceType": "ecs.n4.large",
        "Password": "Test1234",
        "MinAmount": 2,
        "MaxAmount": 2,
        "SecurityGroupId": "sg-2zedcm7ep5quses05fs4",
        "SystemDiskCategory": "cloud_efficiency",
        "IoOptimized": "optimized",
        "InstanceName": "my.test-[1114]",
        "HostName": "host[]"
      }
    }
  }
}
		

ROS will create two ECS instances at a time based on the preceding template.

  • The instance names of the two instances are my.test-1114 and my.test-1115, respectively.
  • The hostnames of the two instances are host0000 and host0001, respectively.
Notice The InstanceName and HostName properties must be specified based on the preceding naming conventions in order to be parsed correctly. Otherwise, the template cannot be validated.