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 following fields are included in the syntax:
- name_prefix: Required. The prefix of the instance name or hostname.
- [begin_number,bits]: Required. The part that changes for each name. begin_number specifies the starting number of the instance name or hostname. bits specifies 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 without spaces.
- The value of bits ranges from 1 to 4.
- The value of begin_number ranges from 0 to 9999.
The value of bits follows the following rules:
- 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, and 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.
ROSTemplateFormatVersion: '2015-09-01' Resources: WebServer: Type: ALIYUN::ECS::InstanceGroup Properties: ImageId: Cen**** InstanceType: ecs.n4.large Password: Test1234 MinAmount: 2 MaxAmount: 2 SecurityGroupId: sg-2zedcm7ep5quses0**** SystemDiskCategory: cloud_efficiency IoOptimized: optimized InstanceName: my.test- 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.
- The hostnames of the two instances are host0000 and host0001.
Important The InstanceName and HostName properties must be specified based on the preceding naming conventions to be correctly parsed. Otherwise, the template cannot be validated.