When you batch create multiple Elastic Compute Service (ECS) instances, the same default instance name or hostname is generated for all instances. To classify the instances or facilitate instance management and identification, you can batch configure sequential instance names or hostnames by specifying a sequence or by using the automatic sorting feature during instance creation.
Specify a sequence to batch configure sequential instance names or hostnames
When you batch create multiple ECS instances, you can specify a sequence to configure sequential names or hostnames for the instances.
Specify a sequence
To specify a sequence for the names and hostnames of multiple ECS instances, configure the instance name parameter and hostname parameter in a fixed format. The format includes fields that specify sequential numeric values.
The system generates names and hostnames that contain the specified numerical sequence for the ECS instances based on the parameters. Specify a sequence by configuring the instance name parameter or hostname parameter in the following format: name_prefix[begin_number,bits]name_suffix. The following tables describe the fields that are contained in the format and provide examples on how to configure the parameters.
Procedure
In the examples, three ECS instances are created, the instance names and hostnames start with k8s-node- and increment from 0006, and the hostnames end with -ecshost.
The instance name or hostname that you specify must meet the following requirements:
Instance name: The name must be 2 to 128 characters in length and must start with a letter. It can contain letters, digits, periods (.), underscores (_), colons (:), and hyphens (-).
Hostname:
For Windows, the hostname must be 2 to 15 characters in length and can contain letters, digits, and hyphens (-). The hostname cannot start or end with a hyphen (-), contain consecutive hyphens (-), or contain only digits.
For other operating systems such as Linux, the hostname must be 2 to 64 characters in length. You can use periods (.) to separate the hostname into multiple segments. Each segment can contain letters, digits, and hyphens (-) and cannot contain consecutive periods (.) or hyphens (-). The hostname cannot start or end with a period (.) or a hyphen (-).
Use the ECS console
For information about how to create an ECS instance, see Create an instance on the Custom Launch tab. When you create ECS instances in the ECS console, complete the following configurations:
Quantity: On the right side of the Custom Launch tab, click the plus sign to increase the value in the Quantity spin box to 3.
Batch configure sequential instance names or hostnames in the following format:
name_prefix[begin_number,bits]name_suffix
. For information about how to configure the fields that are contained in the format, see the Specify a sequence section in this topic.ImportantThe example is used only to show how to specify a sequence. Sequential Suffix is not selected.
Instance Name: Enter an instance name. For example, to create three ECS instances whose names start with
k8s-node-
and increment from 0006, enterk8s-node-[6,4]
in the Instance Name field.Hostname: Select Custom Sequential Hostname below the Hostname field and enter a hostname. For example, to create three ECS instances whose hostnames start with
k8s-node-
, increment from 0006, and end with-ecshost
, enterk8s-node-[6,4]-ecshost
in the Hostname field.
After you complete the configurations and click Create Order, a success message appears. You can click Console in the message to view instance information.
You can view the new ECS instances on the Instances page. In this example, the generated instance names are k8s-node-0006, k8s-node-0007, and k8s-node-0008.
You can go to the Instance Details page of each new ECS instance and view the hostname of the instance in the Other Information section. In this example, the hostnames that are generated for the new ECS instances are k8s-node-0006-ecshost, k8s-node-0007-ecshost, and k8s-node-0008-ecshost.
Call an API operation
You can call the RunInstances operation to create ECS instances and specify names and hostnames for the instances. Configure the following parameters to specify sequential instance names and hostnames when you call the RunInstances operation:
Specify values for the InstanceName and HostName parameters in the following format: name_prefix[begin_number,bits]name_suffix
. For information about how to configure the fields that are contained in the format, see the Specify a sequence section in this topic.
In this example, three ECS instances are created, the instance names and hostnames start with k8s-node- and increment from 0006, and the hostnames end with -ecshost. Configure the following parameters:
Amount: 3
InstanceName: k8s-node-[6,4]
HostName: k8s-node-[6,4]-ecshost
This example is used only to show how to specify a sequence. The UniqueSuffix parameter is set to false.
In this example, the generated instance names are k8s-node-0006, k8s-node-0007, and k8s-node-0008, and the generated hostnames are k8s-node-0006-ecshost, k8s-node-0007-ecshost, and k8s-node-0008-ecshost.
Use the automatic sorting feature to batch configure sequential instance names or hostnames
When you batch create multiple ECS instances, you can enable the automatic sorting feature to automatically add sequential suffixes to the instance names and hostnames.
Use the automatic sorting feature
You can use the automatic sorting feature to automatically add three-digit sequential suffixes to instance names and hostnames. The sequential suffixes range from 001 to 999. After you enable the automatic sorting feature, the added suffix starts from 001 and increments for each ECS instance. When ECS instances are created, instance names and hostnames that have different suffixes are generated.
By default, the automatic sorting feature is disabled. When you create ECS instances, enable the automatic sorting feature and enter an instance name and a hostname. The system adds sequential suffixes to the instance name and hostname that you specify to generate new instances names and hostnames.
The following table describes the format in which you can enter an instance name or a hostname when you enable the automatic sorting feature.
If you want to use a specific sequence together with the automatic sorting feature, specify the name_suffix
field. If you do not specify the field, the automatic sorting feature does not take effect. For information about how to specify a sequence, see the Specify a sequence section in this topic.
Procedure
In the examples, three ECS instances are created, ecs is specified as the instance name, ecshost is specified as the hostname, and a sequential suffix is automatically added to the specified instance name and hostname to generate a new name and hostname for each instance.
The instance name or hostname that you specify must meet the following requirements:
Instance name: The name must be 2 to 128 characters in length and must start with a letter. It can contain letters, digits, periods (.), underscores (_), colons (:), and hyphens (-).
Hostname:
For Windows, the hostname must be 2 to 15 characters in length and can contain letters, digits, and hyphens (-). The hostname cannot start or end with a hyphen (-), contain consecutive hyphens (-), or contain only digits.
For other operating systems such as Linux, the hostname must be 2 to 64 characters in length. You can use periods (.) to separate the hostname into multiple segments. Each segment can contain letters, digits, and hyphens (-) and cannot contain consecutive periods (.) or hyphens (-). The hostname cannot start or end with a period (.) or a hyphen (-).
Use the ECS console
For information about how to create an ECS instance, see Create an instance on the Custom Launch tab. When you create ECS instances in the ECS console, complete the following configurations:
Quantity: On the right side of the Custom Launch tab, click the plus sign to increase the value in the Quantity spin box to 3.
Configure sequential instance names or hostnames that you want to automatically generate. For information about the rules for automatic sorting, see the Use the automatic sorting feature section in this topic.
Instance Name: Enter an instance name. For example, to create three ECS instances whose names start with ecs, enter
ecs
in the Instance Name field.Hostname: Enter a hostname. For example, to create three ECS instances whose hostnames start with ecshost, enter
ecshost
in the Hostname field.Sequential Suffix: If you select this parameter, the system adds sequential suffixes to the values of the Instance Name and Hostname parameters and sorts the values.
After you complete the configurations and click Create Order, a success message appears. You can click Console in the message to view instance information.
You can view the new ECS instances on the Instances page. In this example, the generated instance names are ecs001, ecs002, and ecs003.
You can go to the Instance Details page of each new ECS instance and view the hostname of the instance in the Other Information section. In this example, the generated hostnames are ecshost001, ecshost002, and ecshost003.
Call an API operation
You can call the RunInstances operation to create ECS instances and configure sequential instance names and hostnames that you want to automatically generate for the instances. Configure the following parameters when you call the RunInstances operation:
Set UniqueSuffix to true. The system adds sequential suffixes to the values of the InstanceName and HostName parameters and sorts the values. The added suffix starts from 001 and increments for each ECS instance. For information about the rules for automatic sorting, see the Use the automatic sorting feature section in this topic.
In this example, sequential names and hostnames are automatically generated for three ECS instances. Configure the following parameters:
Amount: 3
InstanceName: ecs
HostName: ecshost
UniqueSuffix: true
In this example, the generated instance names are ecs001, ecs002, and ecs003, and the generated hostnames are ecshost001, ecshost002, and ecshost003.
References
When you use ECS instances, you can modify the attributes of the instances, including instance names, hostnames, and instance descriptions, based on your business requirements. For more information, see Modify the attributes of an instance.
You can use and manage ECS instances based on your business requirements. For more information, see Manage instance status or Manage instance configurations.
You can build websites on ECS instances. For more information, see Quick start or Summary of website building methods.