All Products
Search
Document Center

Elastic Compute Service:Create an ECS instance from an image family

Last Updated:Jul 15, 2026

Specify the ImageFamily parameter when calling RunInstances to auto-select the latest active image.

Procedure

  1. Log on to OpenAPI Explorer.

  2. Call the RunInstances operation.

    This example creates an instance from the image-test image family with the following parameters:

    • RegionId: The region ID, such as cn-hangzhou.

    • InstanceType: The instance type, such as ecs.g6.large.

    • ImageFamily: The image family name, such as image-test.

    • SecurityGroupId: The security group ID, such as sg-bp1i4c0xgqxadew2****.

    • VSwitchId: The vSwitch ID, such as vsw-bp1ddbrxdlrcbim46****.

    The response returns the instance ID.

    {
        "RequestId": "409D4604-84D0-4F16-B99E-809E2E72****",
        "InstanceIdSets": {
            "InstanceIdSet": [
                "i-bp1env7nl3mijm2t****"
            ]
        }
    }
  3. Verify the image used by the instance.

    1. Call the DescribeImageFromFamily operation to query the latest image in the image family.

      This example queries the image-test image family with the following parameters:

      • RegionId: The region ID of the image family.

      • ImageFamily: The image family name, such as image-test.

      The response returns the latest active image ID.

      In the returned JSON, find the ImageId field, which is the ID of the latest image in the image family. Sample response snippet:

      },
          "ImageVersion": "",
          "OSType": "linux",
          "ImageId": "m-bp1xxx",
          "CreationTime": "2020-03-17T06:19:19Z",
    2. Call the DescribeInstances operation to query the instance image.

      Set the following parameters:

      • RegionId: The region ID of the instance.

      • InstanceIds: The instance ID in JSON array format, such as ["i-bp1env7nl3mijm2t****"].

      Verify that the instance image ID matches the latest active image ID from the image family.

      The ImageId in the response is the image ID used by the instance.

      "OSName": "CentOS  8.0 64位",
      "InstanceNetworkType": "vpc",
      "InnerIpAddress": {
          "IpAddress": []
      },
      "ExpiredTime": "2099-12-31T15:59Z",
      "ImageId": "m-bp1cxxx",
      "EipAddress": {
          "AllocationId": "",
          "IpAddress": "",
          "InternetChargeType": ""