ALIYUN::ECS::LaunchTemplate is used to create a launch template. You can use a launch template to create an Elastic Compute Service (ECS) instance.

Syntax

{
  "Type": "ALIYUN::ECS::LaunchTemplate",
  "Properties": {
    "LaunchTemplateName": String,
    "VersionDescription": String,
    "ImageId": String,
    "InstanceType": String,
    "SecurityGroupId": String,
    "NetworkType": String,
    "VSwitchId": String,
    "InstanceName": String,
    "Description": String,
    "InternetMaxBandwidthOut": Integer,
    "HostName": String,
    "ZoneId": String,
    "SystemDiskCategory": String,
    "SystemDiskSize": Number,
    "SystemDiskDiskName": String,
    "SystemDiskDescription": String,
    "IoOptimized": String,
    "InternetChargeType": String,
    "UserData": String,
    "KeyPairName": String,
    "RamRoleName": String,
    "AutoReleaseTime": String,
    "SpotStrategy": String,
    "SpotPriceLimit": String,
    "SecurityEnhancementStrategy": String,
    "DiskMappings": List,
    "NetworkInterfaces": List,
    "Tags": List,
    "TemplateTags": List,
    "TemplateResourceGroupId": String,
    "SecurityGroupIds": List,
    "ResourceGroupId": String,
    "SpotDuration": Integer,
    "ImageOwnerAlias": String,
    "Period": Integer,
    "Ipv6AddressCount": Integer,
    "PrivateIpAddress": String,
    "PasswordInherit": Boolean,
    "SystemDiskDeleteWithInstance": Boolean,
    "DeploymentSetId": String,
    "InstanceChargeType": String,
    "SystemDiskPerformanceLevel": String
  }
}

Properties

PropertyTypeRequiredEditableDescriptionConstraint
LaunchTemplateNameStringYesNoThe name of the launch template. 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://.
VersionDescriptionStringNoNoThe description of the launch template version. The description must be 2 to 128 characters in length. The description must start with a letter but cannot start with http:// or https://.
ImageIdStringNoNoThe ID of the image. None.
InstanceTypeStringNoNoThe instance type. None.
SecurityGroupIdStringNoNoThe ID of the security group. None.
NetworkTypeStringNoNoThe network type of the instance. Valid values:
  • classic: classic network
  • vpc: virtual private cloud (VPC)
VSwitchIdStringNoNoThe ID of the vSwitch. This property takes effect when you set the NetworkType property to vpc.
InstanceNameStringNoNoThe name of the instance. The name must be 2 to 128 characters in length. The name must start with a letter but cannot start with http:// or https://.
DescriptionStringNoNoThe description of the instance. The description must be 2 to 128 characters in length. The description must start with a letter but cannot start with http:// or https://.
InternetMaxBandwidthOutIntegerNoNoThe maximum outbound public bandwidth. Valid values: 0 to 100.

Unit: Mbit/s.

HostNameStringNoNoThe hostname of the instance.

The hostname cannot start or end with a period (.) or hyphen (-), or contain consecutive periods (.) or hyphens (-).

The hostname must meet the following requirements:
  • Windows instances: The hostname must be 2 to 15 characters in length, and can contain letters, digits, and hyphens (-). The hostname cannot contain only digits.
  • Other instances such as Linux instances: The hostname must be 2 to 64 characters in length, and can contain letters, digits, and hyphens (-).
ZoneIdStringNoNoThe ID of the zone to which the instance belongs. None.
SystemDiskCategoryStringNoNoThe category of the system disk. Valid values:
  • cloud: basic disk
  • cloud_efficiency: ultra disk
  • cloud_ssd: standard SSD
  • ephemeral_ssd: local SSD
SystemDiskSizeNumberNoNoThe size of the system disk. Valid values: 20 to 500.

Unit: GB.

SystemDiskDiskNameStringNoNoThe name of the system 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://.
SystemDiskDescriptionStringNoNoThe description of the system disk. The description must be 2 to 256 characters in length. The description cannot start with http:// or https://.
IoOptimizedStringNoNoSpecifies whether the instance is an I/O optimized instance. Valid values:
  • none: The instance is not an I/O optimized instance.
  • optimized: The instance is an I/O optimized instance.
InternetChargeTypeStringNoNoThe metering method for network usage. Valid values:
  • PayByBandwidth: pay-by-bandwidth
  • PayByTraffic: pay-by-data-transfer
UserDataStringNoNoThe user data of the instance. User data must be Base64-encoded. The maximum size of raw data is 16 KB.
KeyPairNameStringNoNoThe name of the key pair. This property is required only for Linux instances. By default, the password-based logon is disabled for Linux instances.
RamRoleNameStringNoNoThe name of the RAM role for the instance. None.
AutoReleaseTimeStringNoNoThe time at which the system automatically releases the instance. Specify the time in the ISO 8601 standard in the yyyy-MM-ddTHH:mm:ssZ format. The time must be in UTC.
SpotStrategyStringNoNoThe preemption policy for a pay-as-you-go instance.

This property takes effect when you set the InstanceChargeType property to PostPaid.

Valid values:

  • NoSpot: The instance is created as a pay-as-you-go instance.
  • SpotWithPriceLimit: The instance is created as a preemptible instance for which you specify the maximum hourly price.
  • SpotAsPriceGo: The instance is created as a preemptible instance whose price is based on the market price at the time of purchase. The market price can be equal to the price of a pay-as-you-go instance.
SpotPriceLimitStringNoNoThe maximum hourly price for the instance. The value of this property can contain up to three decimal places.
SecurityEnhancementStrategyStringNoNoSpecifies whether to enable security hardening. Valid values:
  • Active: enables security hardening.
  • Deactive: disables security hardening.
DiskMappingsListNoNoThe data disks. You can attach up to 16 data disks.

For more information, see DiskMappings properties.

NetworkInterfacesListNoNoThe elastic network interfaces (ENIs). You can attach up to eight ENIs.

For more information, see NetworkInterfaces properties.

TagsListNoNoThe tags of the instance, security group, disk, and ENI. You can specify up to 20 tags for the instance, security group, disk, or ENI.

For more information, see Tags properties.

TemplateTagsListNoNoThe tags of the launch template. You can add up to 20 tags.

For more information, see TemplateTags properties.

TemplateResourceGroupIdStringNoNoThe ID of the resource group to which the launch template belongs. None.
SecurityGroupIdsListNoNoThe IDs of one or more security groups to which you want to add the instance. The value of this property varies based on the maximum number of security groups to which you can add the instance.
Note You cannot specify both the SecurityGroupId and SecurityGroupIds properties.
ResourceGroupIdStringNoNoThe ID of the resource group to which the instance, Elastic Block Storage (EBS) device, and ENI belong. None.
SpotDurationIntegerNoNoThe retention period of the preemptible instance. Valid values: 0 to 6.

Default value: 1.

Unit: hours.

Note If you want to set the value to 2 to 6, you must submit a ticket.
ImageOwnerAliasStringNoNoThe source of the image. Valid values:
  • system: a public image provided by Alibaba Cloud
  • self: a custom image that you create
  • others: a shared image from another Alibaba Cloud account
  • marketplace: an Alibaba Cloud Marketplace image
PeriodIntegerNoNoThe subscription duration of the launch template. This property takes effect and is required when you set the InstanceChargeType property to PrePaid.

Valid values: 1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 24, 36, 48, and 60.

Unit: months.

Ipv6AddressCountIntegerNoNoThe number of IPv6 addresses that the system randomly generates for the primary ENI. Valid values: 1 to 10.
PrivateIpAddressStringNoNoThe private IP address of the instance. If you configure a private IP address for an ECS instance of the VPC type, you must select an idle IP address from the CIDR block of the vSwitch.
PasswordInheritBooleanNoNoSpecifies whether to use the preset password of the image. Valid values:
  • true
  • false
Note You must specify only one of the PasswordInherit and Password properties.
SystemDiskDeleteWithInstanceBooleanNoNoSpecifies whether to release the system disk when the instance is released. Default value: true. Valid values:
  • true
  • false
DeploymentSetIdStringNoNoThe ID of the deployment set. None.
InstanceChargeTypeStringNoNoThe billing method of the instance. Valid values:
  • PrePaid: subscription
  • PostPaid: pay-as-you-go
SystemDiskPerformanceLevelStringNoNoThe performance level (PL) of the enhanced SSD (ESSD) that is used as the system disk. Default value: PL0. Valid values:
  • PL0: An ESSD can deliver up to 10,000 random read/write IOPS.
  • PL1: An ESSD can deliver up to 50,000 random read/write IOPS.
  • PL2: An ESSD can deliver up to 100,000 random read/write IOPS.
  • PL3: An ESSD can deliver up to 1,000,000 random read/write IOPS.

DiskMappings syntax

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

DiskMappings properties

PropertyTypeRequiredEditableDescriptionConstraint
CategoryStringNoNoThe category of the data disk. Valid values:
  • cloud: basic disk
  • cloud_efficiency: ultra disk
  • cloud_ssd: standard SSD
  • ephemeral_ssd: local SSD
DiskNameStringNoNoThe 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://.
DescriptionStringNoNoThe description of the data disk. The description must be 2 to 256 characters in length. The name cannot start with http:// or https://.
SnapshotIdStringNoNoThe ID of the snapshot that is used to create the data disk. None.
SizeStringNoNoThe size of the system disk.

Valid values:

  • Valid values if you set the Category property to cloud: 5 to 2000.
  • Valid values if you set the Category property to cloud_efficiency: 20 to 32768.
  • Valid values if you set the Category property to cloud_ssd: 20 to 32768.
  • Valid values if you set the Category property to ephemeral_ssd: 5 to 800.

Unit: GB.

EncryptedBooleanNoNoSpecifies whether to encrypt the data disk. Valid values:
  • true
  • false
DeleteWithInstanceBooleanNoNoSpecifies whether to release the data disk when the instance is released. Valid values:
  • true
  • false
PerformanceLevelStringNoNoThe PL of the ESSD that is used as the data disk. Default value: PL0. Valid values:
  • PL0: An ESSD can deliver up to 10,000 random read/write IOPS.
  • PL1: An ESSD can deliver up to 50,000 random read/write IOPS.
  • PL2: An ESSD can deliver up to 100,000 random read/write IOPS.
  • PL3: An ESSD can deliver up to 1,000,000 random read/write IOPS.

NetworkInterfaces syntax

"NetworkInterfaces": [
  {
    "PrimaryIpAddress": String,
    "VSwitchId": String,
    "SecurityGroupId": String,
    "NetworkInterfaceName": String,
    "Description": String
  }
]

NetworkInterfaces properties

PropertyTypeRequiredEditableDescriptionConstraint
PrimaryIpAddressStringNoNoThe primary private IP address of the ENI. None.
VSwitchIdStringNoNoThe ID of the vSwitch to which the ENI belongs. None.
SecurityGroupIdStringNoNoThe ID of the security group to which the ENI belongs. None.
NetworkInterfaceNameStringNoNoThe name of the ENI. None.
DescriptionStringNoNoThe description of the ENI. The description must be 2 to 256 characters in length. The description cannot start with http:// or https://.

Tags syntax

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

Tags properties

PropertyTypeRequiredEditableDescriptionConstraint
KeyStringNoNoThe key of the tag. The key must be 1 to 128 characters in length, and cannot contain http:// or https://. The key cannot start with aliyun or acs:.
ValueStringNoNoThe value of the tag. The value can be up to 128 characters in length, and cannot contain http:// or https://. The value cannot start with aliyun or acs:.

TemplateTags syntax

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

TemplateTags properties

PropertyTypeRequiredEditableDescriptionConstraint
KeyStringNoNoThe key of the tag. The key must be 1 to 128 characters in length, and cannot contain http:// or https://. The key cannot start with aliyun or acs:.
ValueStringNoNoThe value of the tag. The value can be up to 128 characters in length, and cannot contain http:// or https://. The value cannot start with aliyun or acs:.

Return values

Fn::GetAtt

  • LaunchTemplateId: the ID of the launch template.
  • LaunchTemplateName: the name of the launch template.
  • DefaultVersionNumber: the default version number of the launch template.
  • LatestVersionNumber: the latest version number of the launch template.

Examples

  • YAMLformat

    ROSTemplateFormatVersion: '2015-09-01'
    Description: Test ECS LaunchTemplate
    Parameters:
      VSwitchId:
        Type: String
        AssociationProperty: ALIYUN::ECS::VSwitch::VSwitchId
      SecurityGroupId:
        AssociationProperty: ALIYUN::ECS::SecurityGroup::SecurityGroupId
        Type: String
    Resources:
      LaunchTemplate:
        Type: ALIYUN::ECS::LaunchTemplate
        Properties:
          LaunchTemplateName: mytest
          VersionDescription: Test create LaunchTemplate
          ImageId: centos_7
          InstanceType: ecs.c5.large
          SystemDiskCategory: cloud_essd
          SecurityGroupId:
            Ref: SecurityGroupId
          VSwitchId:
            Ref: VSwitchId
    Outputs: {}
  • JSONformat

    {
      "ROSTemplateFormatVersion": "2015-09-01",
      "Description": "Test ECS LaunchTemplate",
      "Parameters": {
        "VSwitchId": {
          "Type": "String",
          "AssociationProperty": "ALIYUN::ECS::VSwitch::VSwitchId"
        },
        "SecurityGroupId": {
          "AssociationProperty": "ALIYUN::ECS::SecurityGroup::SecurityGroupId",
          "Type": "String"
        }
      },
      "Resources": {
        "LaunchTemplate": {
          "Type": "ALIYUN::ECS::LaunchTemplate",
          "Properties": {
            "LaunchTemplateName": "mytest",
            "VersionDescription": "Test create LaunchTemplate",
            "ImageId": "centos_7",
            "InstanceType": "ecs.c5.large",
            "SystemDiskCategory": "cloud_essd",
            "SecurityGroupId": {
              "Ref": "SecurityGroupId"
            },
            "VSwitchId": {
              "Ref": "VSwitchId"
            }
          }
        }
      },
      "Outputs": {
      }
    }

For more examples, visit LaunchTemplate.json and LaunchTemplate.yml. In the examples, the ALIYUN::ECS::LaunchTemplate and ALIYUN::ECS::AutoProvisioningGroup resource types are used.