ALIYUN::ECS::InstanceClone is used to clone an Elastic Compute Service (ECS) instance.

Syntax

{
  "Type": "ALIYUN::ECS::InstanceClone",
  "Properties": {
    "DeletionProtection": Boolean,
    "DiskMappings": List,
    "LoadBalancerIdToAttach": String,
    "Description": String,
    "BackendServerWeight": Integer,
    "Tags": List,
    "SecurityGroupId": String,
    "RamRoleName": String,
    "ImageId": String,
    "ResourceGroupId": String,
    "SpotPriceLimit": String,
    "InstanceChargeType": String,
    "SourceInstanceId": String,
    "Period": Number,
    "SpotStrategy": String,
    "Password": String,
    "InstanceName": String,
    "InternetMaxBandwidthIn": Integer,
    "ZoneId": String,
    "KeyPairName": String
  }
}

Properties

Property Type Required Editable Description Constraint
ResourceGroupId String No No The ID of the resource group to which the ECS instance belongs. None
SourceInstanceId String Yes No The ID of the source ECS instance. The clone operation clones the source ECS instance, including its instance type, image, bandwidth billing method, bandwidth limit, and network type. If the source ECS instance belongs to multiple security groups, the created instances are added only to the first security group.
BackendServerWeight Integer No No The weight that is assigned to the ECS instance in the Server Load Balancer (SLB) instance. Valid values: 0 to 100.

Default value: 100.

LoadBalancerIdToAttach String No No The ID of the SLB instance to which the created ECS instance is to be attached. None
Description String No No The description of the created ECS instance. The description can be up to 256 characters in length.
ImageId String No Yes The ID of the image that is used to start the created ECS instance. You can use a public image, a custom image, or an Alibaba Cloud Marketplace image.

You can specify a partial public image ID instead of the complete ID. Examples:

  • If you enter ubuntu, the system matches it with the following ID: ubuntu16_0402_64_20G_alibase_20170818.vhd.
  • If you enter ubuntu_14, the system matches it with the following ID: ubuntu_14_0405_64_20G_alibase_20170824.vhd.
  • If you enter ubuntu*14*32, the system matches it with the following ID: ubuntu_14_0405_32_40G_alibase_20170711.vhd.
  • If you enter ubuntu_16_0402_32, the system matches it with the following ID: ubuntu_16_0402_32_40G_alibase_20170711.vhd.
SecurityGroupId String No No The ID of the security group to which the created ECS instance belongs. None
InstanceName String No No The name of the created ECS instance. The name must be 2 to 128 characters in length and can contain letters, digits, colons (:), underscores (_), and hyphens (-). The name must start with a letter but cannot start with http:// or https://.
Password String No No The password that is used to log on to the created ECS instance.

The password must be 8 to 30 characters in length

The password must contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters.

Special characters include ( ) ' ~ ! @ # $ % ^ & * - + = | { } [ ] : ; ‘ < > , . ? /.

If you set this property in the API request, you must use HTTPS to secure the API and protect your password.

DiskMappings List No No The data disks to be attached to the created ECS instance. You can attach up to 16 data disks.

For more information, see DiskMappings properties.

Tags List No Yes The tags of the created ECS instance. You can specify up to 20 tags in the [{"Key":"tagKey","Value":"tagValue"},{"Key":"tagKey2","Value":"tagValue2"}] format.

For more information, see Tags properties.

ZoneId String No No The zone ID of the created ECS instance. None
InstanceChargeType String No No The billing method of the created ECS instance. Default value: Postpaid. Valid values:
  • Prepaid
    Note If you set this property to Prepaid, make sure that you have sufficient balance in your account. Otherwise, the instance fails to be created.
  • Postpaid
Period Number No No The billing cycle of the created ECS instance. Valid values: 1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 24, and 36.

Unit: months.

This property is required if you set the InstanceChargeType property to Prepaid. This property is optional if you set the InstanceChargeType property to Postpaid.

KeyPairName String No Yes The name of the key pair that is used to connect to the created ECS instance.

For Windows instances, this property is empty by default.

For Linux instances, the Password property still takes effect even if you set this property. However, logon by password is disabled, and the value of this property is used by default.

RamRoleName String No No The RAM role name for the created ECS instance. For more information, see CreateRole and ListRoles.
SpotPriceLimit String No No The maximum hourly price of the created ECS instance. This property takes effect only if you set the SpotStrategy property to SpotWithPriceLimit. Up to three decimal places are allowed.
SpotStrategy String No No The bidding policy for pay-as-you-go instances. This property takes effect only if you set the InstanceChargeType property to Postpaid. Default value: NoSpot. Valid values:
  • NoSpot: applies to regular pay-as-you-go instances.
  • SpotWithPriceLimit: applies to preemptible instances with a maximum hourly price.
  • SpotAsPriceGo: applies to pay-as-you-go instances priced at the market price at the time of purchase.
InternetMaxBandwidthIn Integer No No The maximum inbound bandwidth from the Internet. Valid values: 1 to 200.

Unit: Mbit/s.

DeletionProtection Boolean No No The deletion protection property of the created ECS instance. This property specifies whether the instance can be released by using the ECS console or by calling the DeleteInstance operation. Default value: false. Valid values:
  • true
  • false

DiskMappings syntax

"DiskMappings": [
  {
    "Category": String,
    "DiskName": String,
    "Description": String,
    "Device": String,
    "SnapshotId": String,
    "PerformanceLevel": String,
    "Size": String
  }
]

DiskMappings properties

Property Type Required Editable Description Constraint
Size String Yes No The size of the data disk. Valid values: 20 to 500.

Unit: GB.

Category String No No The category of the data disk. Valid values:
  • cloud: basic disk
  • cloud_ssd: standard SSD
  • cloud_essd: enhanced SSD (ESSD)
  • cloud_efficiency: ultra disk
  • ephemeral_ssd: local SSD
For I/O optimized instances, the default value is cloud_efficiency. For non-I/O optimized instances, the default value is cloud.
DiskName String No No The name of the data disk. The name must be 2 to 128 characters in length and can contain letters, digits, colons (:), underscores (_), and hyphens (-). The name must start with a letter but cannot start with http:// or https://.
PerformanceLevel String No No The performance level of the ESSD that is used as the system disk. Default value: PL1. Valid values:
  • PL1: A single ESSD delivers up to 50,000 random read/write IOPS.
  • PL2: A single ESSD can deliver up to 100,000 random read/write IOPS.
  • PL3: A single ESSD can deliver up to 1,000,000 random read/write IOPS.
For more information about performance levels of ESSDs, see ESSDs.
Description String No No The description of the data disk. The description must be 2 to 256 characters in length.

By default, this property is empty.

Device String No No The mount target of the data disk. This property will be removed. We recommend that you use other properties to ensure future compatibility.
SnapshotId String No No The ID of the snapshot that is used to create the data disk. None

Tags syntax

"Tags": [
  {
    "Value": String,
    "Key": String
  }
]

Tags properties

Property Type Required Editable Description Constraint
Key String Yes No The tag key. The tag key must be 1 to 128 characters in length and cannot contain http:// or https://. The tag key cannot start with acs: or aliyun.
Value String No No The tag value. The tag value must be 0 to 128 characters in length and cannot contain http:// or https://. The tag value cannot start with acs: or aliyun.

Return values

Fn::GetAtt

  • InstanceId: the ID of the instance. The instance ID is a globally unique identifier (GUID) generated by the system for the instance.
  • PrivateIp: the private IP address of the VPC-type instance. This property takes effect only if you set the NetworkType property to VPC.
  • InnerIp: the private IP address of the classic network-type instance. This property takes effect only if you set the NetworkType property to Classic.
  • PublicIp: the list of public IP addresses of the classic network-type instance. This property takes effect only if you set the NetworkType property to Classic.
  • ZoneId: the zone ID of the instance.
  • HostName: the hostname of the instance.
  • PrimaryNetworkInterfaceId: the ID of the primary elastic network interface (ENI).
  • SecurityGroupIds: the IDs of security groups to which the created instance belongs.

Examples

JSON format

{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
    "BackendServerWeight": {
      "Type": "Number",
      "Description": "The weight of backend server of load balancer. From 0 to 100, 0 means offline. Default is 100.",
      "MinValue": 0,
      "MaxValue": 100,
      "Default": 100
    },
    "KeyPairName": {
      "Type": "String",
      "Description": "SSH key pair name."
    },
    "Description": {
      "Type": "String",
      "Description": "Description of the instance, [2, 256] characters. Do not fill or empty, the default is empty."
    },
    "DiskMappings": {
      "Type": "Json",
      "Description": "Disk mappings to attach to instance. Max support 16 disks.\nIf the image contains a data disk, you can specify other parameters of the data disk via the same value of parameter \"Device\". If parameter \"Category\" is not specified, it will be cloud_efficiency instead of \"Category\" of data disk in the image.",
      "MaxLength": 16
    },
    "ResourceGroupId": {
      "Type": "String",
      "Description": "Resource group id."
    },
    "ZoneId": {
      "Type": "String",
      "Description": "The ID of the zone to which the instance belongs. For more information, \ncall the DescribeZones operation to query the most recent zone list. \nDefault value is empty, which means random selection."
    },
    "InstanceChargeType": {
      "Type": "String",
      "Description": "Instance Charge type, allowed value: Prepaid and Postpaid. If specified Prepaid, please ensure you have sufficient balance in your account. Or instance creation will be failure. Default value is Postpaid.",
      "AllowedValues": [
        "Subscription",
        "PrePaid",
        "PrePay",
        "Prepaid",
        "PayAsYouGo",
        "PostPaid",
        "PayOnDemand",
        "Postpaid"
      ],
      "Default": "PostPaid"
    },
    "SecurityGroupId": {
      "Type": "String",
      "Description": "Security group to create ecs instance. For classic instance need the security group not belong to VPC, for VPC instance, please make sure the security group belong to specified VPC."
    },
    "Period": {
      "Type": "Number",
      "Description": "Prepaid time period. Unit is month, it could be from 1 to 9 or 12, 24, 36, 48, 60. Default value is 1.",
      "AllowedValues": [
        1,
        2,
        3,
        4,
        5,
        6,
        7,
        8,
        9,
        12,
        24,
        36,
        48,
        60
      ],
      "Default": 1
    },
    "DeletionProtection": {
      "Type": "Boolean",
      "Description": "Whether an instance can be released manually through the console or API, deletion protection only support postPaid instance ",
      "AllowedValues": [
        "True",
        "true",
        "False",
        "false"
      ]
    },
    "SourceInstanceId": {
      "Type": "String",
      "Description": "Source ecs instance used to copy properties to clone new ecs instance. It will copy the InstanceType, ImageId, InternetChargeType, InternetMaxBandwidthIn, InternetMaxBandwidthOut and the system disk and data disk configurations. If the instance network is VPC, it will also clone the relative properties. If specified instance with more than one security group, it will use the first security group to create instance. you can also specify the SecurityGroupId to override it."
    },
    "LoadBalancerIdToAttach": {
      "Type": "String",
      "Description": "After the instance is created. Automatic attach it to the load balancer."
    },
    "InstanceName": {
      "Type": "String",
      "Description": "Display name of the instance, [2, 128] English or Chinese characters, must start with a letter or Chinese in size, can contain numbers, '_' or '.', '-'"
    },
    "RamRoleName": {
      "Type": "String",
      "Description": "Instance RAM role name. The name is provided and maintained by Resource Access Management (RAM) and can be queried using ListRoles. For more information, see RAM API CreateRole and ListRoles."
    },
    "InternetMaxBandwidthIn": {
      "Type": "Number",
      "Description": "Max internet out band width setting, unit in Mbps(Mega bit per second). The range is [1,200], default is 200 Mbps.",
      "MinValue": 1,
      "MaxValue": 200,
      "Default": 200
    },
    "ImageId": {
      "Type": "String",
      "Description": "Image ID to create ecs instance."
    },
    "SpotPriceLimit": {
      "Type": "String",
      "Description": "The hourly price threshold of a instance, and it takes effect only when parameter InstanceChargeType is PostPaid. Three decimals is allowed at most. "
    },
    "Tags": {
      "Type": "Json",
      "Description": "Tags to attach to instance. Max support 20 tags to add during create instance. Each tag with two properties Key and Value, and Key is required.",
      "MaxLength": 20
    },
    "SpotStrategy": {
      "Type": "String",
      "Description": "The spot strategy of a Pay-As-You-Go instance, and it takes effect only when parameter InstanceChargeType is PostPaid. Value range: \"NoSpot: A regular Pay-As-You-Go instance\", \"SpotWithPriceLimit: A price threshold for a spot instance, \"\"SpotAsPriceGo: A price that is based on the highest Pay-As-You-Go instance. \"Default value: NoSpot.",
      "AllowedValues": [
        "NoSpot",
        "SpotWithPriceLimit",
        "SpotAsPriceGo"
      ]
    },
    "Password": {
      "Type": "String",
      "Description": "Password of created ecs instance. Must contain at least 3 types of special character, lower character, upper character, number."
    }
  },
  "Resources": {
    "InstanceClone": {
      "Type": "ALIYUN::ECS::InstanceClone",
      "Properties": {
        "BackendServerWeight": {
          "Ref": "BackendServerWeight"
        },
        "KeyPairName": {
          "Ref": "KeyPairName"
        },
        "Description": {
          "Ref": "Description"
        },
        "DiskMappings": {
          "Ref": "DiskMappings"
        },
        "ResourceGroupId": {
          "Ref": "ResourceGroupId"
        },
        "ZoneId": {
          "Ref": "ZoneId"
        },
        "InstanceChargeType": {
          "Ref": "InstanceChargeType"
        },
        "SecurityGroupId": {
          "Ref": "SecurityGroupId"
        },
        "Period": {
          "Ref": "Period"
        },
        "DeletionProtection": {
          "Ref": "DeletionProtection"
        },
        "SourceInstanceId": {
          "Ref": "SourceInstanceId"
        },
        "LoadBalancerIdToAttach": {
          "Ref": "LoadBalancerIdToAttach"
        },
        "InstanceName": {
          "Ref": "InstanceName"
        },
        "RamRoleName": {
          "Ref": "RamRoleName"
        },
        "InternetMaxBandwidthIn": {
          "Ref": "InternetMaxBandwidthIn"
        },
        "ImageId": {
          "Ref": "ImageId"
        },
        "SpotPriceLimit": {
          "Ref": "SpotPriceLimit"
        },
        "Tags": {
          "Ref": "Tags"
        },
        "SpotStrategy": {
          "Ref": "SpotStrategy"
        },
        "Password": {
          "Ref": "Password"
        }
      }
    }
  },
  "Outputs": {
    "PrimaryNetworkInterfaceId": {
      "Description": "Primary network interface ID of created instance.",
      "Value": {
        "Fn::GetAtt": [
          "InstanceClone",
          "PrimaryNetworkInterfaceId"
        ]
      }
    },
    "InnerIp": {
      "Description": "Inner IP address of the specified instance. Only for classical instance.",
      "Value": {
        "Fn::GetAtt": [
          "InstanceClone",
          "InnerIp"
        ]
      }
    },
    "ZoneId": {
      "Description": "Zone ID of created instance.",
      "Value": {
        "Fn::GetAtt": [
          "InstanceClone",
          "ZoneId"
        ]
      }
    },
    "PrivateIp": {
      "Description": "Private IP address of created ecs instance. Only for VPC instance.",
      "Value": {
        "Fn::GetAtt": [
          "InstanceClone",
          "PrivateIp"
        ]
      }
    },
    "InstanceId": {
      "Description": "The instance ID of created ecs instance",
      "Value": {
        "Fn::GetAtt": [
          "InstanceClone",
          "InstanceId"
        ]
      }
    },
    "PublicIp": {
      "Description": "Public IP address of created ecs instance.",
      "Value": {
        "Fn::GetAtt": [
          "InstanceClone",
          "PublicIp"
        ]
      }
    },
    "SecurityGroupIds": {
      "Description": "Security group ID list of created instance.",
      "Value": {
        "Fn::GetAtt": [
          "InstanceClone",
          "SecurityGroupIds"
        ]
      }
    },
    "HostName": {
      "Description": "Host name of created instance.",
      "Value": {
        "Fn::GetAtt": [
          "InstanceClone",
          "HostName"
        ]
      }
    }
  }
}

YAML format

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  BackendServerWeight:
    Default: 100
    Description: The weight of backend server of load balancer. From 0 to 100, 0 means
      offline. Default is 100.
    MaxValue: 100
    MinValue: 0
    Type: Number
  DeletionProtection:
    AllowedValues:
    - 'True'
    - 'true'
    - 'False'
    - 'false'
    Description: 'Whether an instance can be released manually through the console
      or API, deletion protection only support postPaid instance '
    Type: Boolean
  Description:
    Description: Description of the instance, [2, 256] characters. Do not fill or
      empty, the default is empty.
    Type: String
  DiskMappings:
    Description: 'Disk mappings to attach to instance. Max support 16 disks.

      If the image contains a data disk, you can specify other parameters of the data
      disk via the same value of parameter "Device". If parameter "Category" is not
      specified, it will be cloud_efficiency instead of "Category" of data disk in
      the image.'
    MaxLength: 16
    Type: Json
  ImageId:
    Description: Image ID to create ecs instance.
    Type: String
  InstanceChargeType:
    AllowedValues:
    - Subscription
    - PrePaid
    - PrePay
    - Prepaid
    - PayAsYouGo
    - PostPaid
    - PayOnDemand
    - Postpaid
    Default: PostPaid
    Description: 'Instance Charge type, allowed value: Prepaid and Postpaid. If specified
      Prepaid, please ensure you have sufficient balance in your account. Or instance
      creation will be failure. Default value is Postpaid.'
    Type: String
  InstanceName:
    Description: Display name of the instance, [2, 128] English or Chinese characters,
      must start with a letter or Chinese in size, can contain numbers, '_' or '.',
      '-'
    Type: String
  InternetMaxBandwidthIn:
    Default: 200
    Description: Max internet out band width setting, unit in Mbps(Mega bit per second).
      The range is [1,200], default is 200 Mbps.
    MaxValue: 200
    MinValue: 1
    Type: Number
  KeyPairName:
    Description: SSH key pair name.
    Type: String
  LoadBalancerIdToAttach:
    Description: After the instance is created. Automatic attach it to the load balancer.
    Type: String
  Password:
    Description: Password of created ecs instance. Must contain at least 3 types of
      special character, lower character, upper character, number.
    Type: String
  Period:
    AllowedValues:
    - 1
    - 2
    - 3
    - 4
    - 5
    - 6
    - 7
    - 8
    - 9
    - 12
    - 24
    - 36
    - 48
    - 60
    Default: 1
    Description: Prepaid time period. Unit is month, it could be from 1 to 9 or 12,
      24, 36, 48, 60. Default value is 1.
    Type: Number
  RamRoleName:
    Description: Instance RAM role name. The name is provided and maintained by Resource
      Access Management (RAM) and can be queried using ListRoles. For more information,
      see RAM API CreateRole and ListRoles.
    Type: String
  ResourceGroupId:
    Description: Resource group id.
    Type: String
  SecurityGroupId:
    Description: Security group to create ecs instance. For classic instance need
      the security group not belong to VPC, for VPC instance, please make sure the
      security group belong to specified VPC.
    Type: String
  SourceInstanceId:
    Description: Source ecs instance used to copy properties to clone new ecs instance.
      It will copy the InstanceType, ImageId, InternetChargeType, InternetMaxBandwidthIn,
      InternetMaxBandwidthOut and the system disk and data disk configurations. If
      the instance network is VPC, it will also clone the relative properties. If
      specified instance with more than one security group, it will use the first
      security group to create instance. you can also specify the SecurityGroupId
      to override it.
    Type: String
  SpotPriceLimit:
    Description: 'The hourly price threshold of a instance, and it takes effect only
      when parameter InstanceChargeType is PostPaid. Three decimals is allowed at
      most. '
    Type: String
  SpotStrategy:
    AllowedValues:
    - NoSpot
    - SpotWithPriceLimit
    - SpotAsPriceGo
    Description: 'The spot strategy of a Pay-As-You-Go instance, and it takes effect
      only when parameter InstanceChargeType is PostPaid. Value range: "NoSpot: A
      regular Pay-As-You-Go instance", "SpotWithPriceLimit: A price threshold for
      a spot instance, ""SpotAsPriceGo: A price that is based on the highest Pay-As-You-Go
      instance. "Default value: NoSpot.'
    Type: String
  Tags:
    Description: Tags to attach to instance. Max support 20 tags to add during create
      instance. Each tag with two properties Key and Value, and Key is required.
    MaxLength: 20
    Type: Json
  ZoneId:
    Description: "The ID of the zone to which the instance belongs. For more information,\
      \ \ncall the DescribeZones operation to query the most recent zone list. \n\
      Default value is empty, which means random selection."
    Type: String
Resources:
  InstanceClone:
    Properties:
      BackendServerWeight:
        Ref: BackendServerWeight
      DeletionProtection:
        Ref: DeletionProtection
      Description:
        Ref: Description
      DiskMappings:
        Ref: DiskMappings
      ImageId:
        Ref: ImageId
      InstanceChargeType:
        Ref: InstanceChargeType
      InstanceName:
        Ref: InstanceName
      InternetMaxBandwidthIn:
        Ref: InternetMaxBandwidthIn
      KeyPairName:
        Ref: KeyPairName
      LoadBalancerIdToAttach:
        Ref: LoadBalancerIdToAttach
      Password:
        Ref: Password
      Period:
        Ref: Period
      RamRoleName:
        Ref: RamRoleName
      ResourceGroupId:
        Ref: ResourceGroupId
      SecurityGroupId:
        Ref: SecurityGroupId
      SourceInstanceId:
        Ref: SourceInstanceId
      SpotPriceLimit:
        Ref: SpotPriceLimit
      SpotStrategy:
        Ref: SpotStrategy
      Tags:
        Ref: Tags
      ZoneId:
        Ref: ZoneId
    Type: ALIYUN::ECS::InstanceClone
Outputs:
  HostName:
    Description: Host name of created instance.
    Value:
      Fn::GetAtt:
      - InstanceClone
      - HostName
  InnerIp:
    Description: Inner IP address of the specified instance. Only for classical instance.
    Value:
      Fn::GetAtt:
      - InstanceClone
      - InnerIp
  InstanceId:
    Description: The instance ID of created ecs instance
    Value:
      Fn::GetAtt:
      - InstanceClone
      - InstanceId
  PrimaryNetworkInterfaceId:
    Description: Primary network interface ID of created instance.
    Value:
      Fn::GetAtt:
      - InstanceClone
      - PrimaryNetworkInterfaceId
  PrivateIp:
    Description: Private IP address of created ecs instance. Only for VPC instance.
    Value:
      Fn::GetAtt:
      - InstanceClone
      - PrivateIp
  PublicIp:
    Description: Public IP address of created ecs instance.
    Value:
      Fn::GetAtt:
      - InstanceClone
      - PublicIp
  SecurityGroupIds:
    Description: Security group ID list of created instance.
    Value:
      Fn::GetAtt:
      - InstanceClone
      - SecurityGroupIds
  ZoneId:
    Description: Zone ID of created instance.
    Value:
      Fn::GetAtt:
      - InstanceClone
      - ZoneId

To view more examples, visit InstanceClone.json and InstanceClone.yml.