All Products
Search
Document Center

Resource Orchestration Service:How to specify different instance names and hostnames for batch-created ECS instances

Last Updated:Jun 10, 2026

When you use the ALIYUN::ECS::InstanceGroup resource type to batch-create ECS instances, you can give each instance a unique, predictable name and hostname without writing a separate template block per instance.

Set the InstanceName and HostName properties using the following pattern:

name_prefix[begin_number,bits]name_suffix

Naming pattern fields

  • name_prefix — Required. The fixed prefix that appears at the start of every generated name.

  • [begin_number,bits] — The auto-incrementing part. begin_number sets the starting number; bits sets how many digits the number occupies (zero-padded).

    The field must meet these requirements:

    • No spaces inside the brackets.

    • bits must be in the range of 1 to 4.

    • begin_number must be in the range of 0 to 9999.

    Default behavior for bits:

    • If you specify only begin_number (for example, [5]): bits defaults to 4, producing a 4-digit zero-padded number.

    • If you write [] or [,] (omitting both values): begin_number defaults to 0 and bits defaults to 4.

    • If begin_number has more digits than bits specifies (for example, [1234,1]): bits is overridden and defaults to 4, because begin_number (1234) already has four digits. This override applies only when begin_number is in the range of 0 to 9999.

  • name_suffix — Optional. A fixed string appended after the incrementing number.

Batch instance naming example

The following template creates two ECS instances with distinct names and hostnames.

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-[1114]
      HostName: host[]

ROS generates the following names:

  • Instance names: my.test-1114 and my.test-1115 — InstanceName: my.test-[1114] means begin_number=1114, bits defaults to 4.

  • Hostnames: host0000 and host0001 — HostName: host[] means begin_number defaults to 0, bits defaults to 4.

Important

Template validation fails if the generated names do not conform to the naming rules for InstanceName and HostName. Verify your pattern produces valid names before deploying the template.