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
Property | Type | Required | Editable | Description | Constraint |
---|---|---|---|---|---|
LaunchTemplateName | String | Yes | No | The 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:// .
|
VersionDescription | String | No | No | The 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:// .
|
ImageId | String | No | No | The ID of the image. | None. |
InstanceType | String | No | No | The instance type. | None. |
SecurityGroupId | String | No | No | The ID of the security group. | None. |
NetworkType | String | No | No | The network type of the instance. | Valid values:
|
VSwitchId | String | No | No | The ID of the vSwitch. | This property takes effect when you set the NetworkType property to vpc .
|
InstanceName | String | No | No | The 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:// .
|
Description | String | No | No | The 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:// .
|
InternetMaxBandwidthOut | Integer | No | No | The maximum outbound public bandwidth. | Valid values: 0 to 100.
Unit: Mbit/s. |
HostName | String | No | No | The 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:
|
ZoneId | String | No | No | The ID of the zone to which the instance belongs. | None. |
SystemDiskCategory | String | No | No | The category of the system disk. | Valid values:
|
SystemDiskSize | Number | No | No | The size of the system disk. | Valid values: 20 to 500.
Unit: GB. |
SystemDiskDiskName | String | No | No | The 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:// .
|
SystemDiskDescription | String | No | No | The description of the system disk. | The description must be 2 to 256 characters in length. The description cannot start
with http:// or https:// .
|
IoOptimized | String | No | No | Specifies whether the instance is an I/O optimized instance. | Valid values:
|
InternetChargeType | String | No | No | The metering method for network usage. | Valid values:
|
UserData | String | No | No | The user data of the instance. | User data must be Base64-encoded. The maximum size of raw data is 16 KB. |
KeyPairName | String | No | No | The name of the key pair. | This property is required only for Linux instances. By default, the password-based logon is disabled for Linux instances. |
RamRoleName | String | No | No | The name of the RAM role for the instance. | None. |
AutoReleaseTime | String | No | No | The 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.
|
SpotStrategy | String | No | No | The preemption policy for a pay-as-you-go instance. |
This property takes effect when you set the InstanceChargeType property to PostPaid. Valid values:
|
SpotPriceLimit | String | No | No | The maximum hourly price for the instance. | The value of this property can contain up to three decimal places. |
SecurityEnhancementStrategy | String | No | No | Specifies whether to enable security hardening. | Valid values:
|
DiskMappings | List | No | No | The data disks. | You can attach up to 16 data disks.
For more information, see DiskMappings properties. |
NetworkInterfaces | List | No | No | The elastic network interfaces (ENIs). | You can attach up to eight ENIs.
For more information, see NetworkInterfaces properties. |
Tags | List | No | No | The 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. |
TemplateTags | List | No | No | The tags of the launch template. | You can add up to 20 tags.
For more information, see TemplateTags properties. |
TemplateResourceGroupId | String | No | No | The ID of the resource group to which the launch template belongs. | None. |
SecurityGroupIds | List | No | No | The 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.
|
ResourceGroupId | String | No | No | The ID of the resource group to which the instance, Elastic Block Storage (EBS) device, and ENI belong. | None. |
SpotDuration | Integer | No | No | The 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.
|
ImageOwnerAlias | String | No | No | The source of the image. | Valid values:
|
Period | Integer | No | No | The 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. |
Ipv6AddressCount | Integer | No | No | The number of IPv6 addresses that the system randomly generates for the primary ENI. | Valid values: 1 to 10. |
PrivateIpAddress | String | No | No | The 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. |
PasswordInherit | Boolean | No | No | Specifies whether to use the preset password of the image. | Valid values:
Note You must specify only one of the PasswordInherit and Password properties.
|
SystemDiskDeleteWithInstance | Boolean | No | No | Specifies whether to release the system disk when the instance is released. | Default value: true. Valid values:
|
DeploymentSetId | String | No | No | The ID of the deployment set. | None. |
InstanceChargeType | String | No | No | The billing method of the instance. | Valid values:
|
SystemDiskPerformanceLevel | String | No | No | The performance level (PL) of the enhanced SSD (ESSD) that is used as the system disk. | Default value: PL0. Valid values:
|
DiskMappings syntax
"DiskMappings": [
{
"Category": String,
"DiskName": String,
"Description": String,
"SnapshotId": String,
"Size": String,
"Encrypted": String,
"DeleteWithInstance": String,
"PerformanceLevel": String
}
]
DiskMappings properties
Property | Type | Required | Editable | Description | Constraint |
---|---|---|---|---|---|
Category | String | No | No | The category of the data disk. | Valid values:
|
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:// .
|
Description | String | No | No | The description of the data disk. | The description must be 2 to 256 characters in length. The name cannot start with
http:// or https:// .
|
SnapshotId | String | No | No | The ID of the snapshot that is used to create the data disk. | None. |
Size | String | No | No | The size of the system disk. |
Valid values:
Unit: GB. |
Encrypted | Boolean | No | No | Specifies whether to encrypt the data disk. | Valid values:
|
DeleteWithInstance | Boolean | No | No | Specifies whether to release the data disk when the instance is released. | Valid values:
|
PerformanceLevel | String | No | No | The PL of the ESSD that is used as the data disk. | Default value: PL0. Valid values:
|
NetworkInterfaces syntax
"NetworkInterfaces": [
{
"PrimaryIpAddress": String,
"VSwitchId": String,
"SecurityGroupId": String,
"NetworkInterfaceName": String,
"Description": String
}
]
NetworkInterfaces properties
Property | Type | Required | Editable | Description | Constraint |
---|---|---|---|---|---|
PrimaryIpAddress | String | No | No | The primary private IP address of the ENI. | None. |
VSwitchId | String | No | No | The ID of the vSwitch to which the ENI belongs. | None. |
SecurityGroupId | String | No | No | The ID of the security group to which the ENI belongs. | None. |
NetworkInterfaceName | String | No | No | The name of the ENI. | None. |
Description | String | No | No | The 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
Property | Type | Required | Editable | Description | Constraint |
---|---|---|---|---|---|
Key | String | No | No | The 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: .
|
Value | String | No | No | The 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
Property | Type | Required | Editable | Description | Constraint |
---|---|---|---|---|---|
Key | String | No | No | The 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: .
|
Value | String | No | No | The 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
JSON
format
{
"ROSTemplateFormatVersion": "2015-09-01",
"Description": "Test the LaunchTemplate and AutoProvisioningGroup operations of ECS.",
"Parameters": {
"VSwitchZoneId": {
"AssociationProperty": "ALIYUN::ECS::Instance:ZoneId",
"Type": "String"
},
"VpcId": {
"Type": "String",
"AssociationProperty": "ALIYUN::ECS::VPC::VPCId"
},
"VSwitchId": {
"Type": "String",
"AssociationProperty": "ALIYUN::ECS::VSwitch::VSwitchId",
"AssociationPropertyMetadata": {
"ZoneId": "VSwitchZoneId",
"VpcId": "VpcId"
}
},
"SecurityGroupId": {
"AssociationProperty": "ALIYUN::ECS::SecurityGroup::SecurityGroupId",
"Type": "String",
"AssociationPropertyMetadata": {
"VpcId": "VpcId"
}
},
"LaunchTemplateName": {
"Type": "String",
"Default": "mytest"
},
"ImageId": {
"Type": "String",
"Default": "centos_7"
},
"InstanceType": {
"Type": "String",
"AssociationProperty": "ALIYUN::ECS::Instance::InstanceType",
"Default": "ecs.c5.large"
},
"SystemDiskCategory": {
"Type": "String",
"Description": "Category of system disk. Default is cloud_efficiency. support cloud|cloud_efficiency|cloud_ssd|cloud_essd|ephemeral_ssd.Old instances will not be changed.",
"AssociationProperty": "ALIYUN::ECS::Disk::SystemDiskCategory",
"AssociationPropertyMetadata": {
"ZoneId": "VSwitchZoneId",
"InstanceType": "InstanceType"
},
"Default": "cloud_essd"
},
"PayAsYouGoTargetCapacity": {
"Type": "String",
"Description": "The target capacity of pay-as-you-go instances in the auto provisioning group.",
"Default": "1"
},
"TotalTargetCapacity": {
"Type": "String",
"Description": "The total target capacity of the auto provisioning group. The target capacity consists\nof the following three parts:\nThe target capacity of pay-as-you-go instances specified by the PayAsYouGoTargetCapacity parameter\nThe target capacity of preemptible instances specified by the SpotTargetCapacity parameter\nThe supplemental capacity besides PayAsYouGoTargetCapacity and SpotTargetCapacity",
"Default": "2"
},
"SpotTargetCapacity": {
"Type": "String",
"Description": "The target capacity of preemptible instances in the auto provisioning group.",
"Default": "1"
},
"AutoProvisioningGroupName": {
"Type": "String",
"Description": "The name of the auto provisioning group to be created. It must be 2 to 128 characters\nin length. It must start with a letter but cannot start with http:// or https://.\nIt can contain letters, digits, colons (:), underscores (_), and hyphens (-).",
"Default": "mytest"
},
"SpotAllocationStrategy": {
"Type": "String",
"Description": "The scale-out policy for preemptible instances. Valid values:\nlowest-price: The cost optimization policy the auto provisioning group follows to select instance\ntypes of the lowest cost to create instances.\ndiversified: The distribution balancing policy the auto provisioning group follows to evenly create\ninstances across zones specified in multiple extended template configurations.\nDefault value: lowest-price",
"AllowedValues": [
"diversified",
"lowest-price"
],
"Default": "lowest-price"
},
"SpotInstancePoolsToUseCount": {
"Type": "Number",
"Description": "This parameter takes effect when the SpotAllocationStrategy parameter is set to lowest-price. The auto provisioning group selects instance types of the lowest cost to create\ninstances.",
"Default": null
},
"PayAsYouGoAllocationStrategy": {
"Type": "String",
"Description": "The scale-out policy for pay-as-you-go instances. Valid values:\nlowest-price: The cost optimization policy the auto provisioning group follows to select instance\ntypes of the lowest cost to create instances.\nprioritized: The priority-based policy the auto provisioning group follows to create instances.\nThe priority of an instance type is specified by the LaunchTemplateConfig.N.Priority parameter.\nDefault value: lowest-price",
"AllowedValues": [
"lowest-price",
"prioritized"
],
"Default": "lowest-price"
},
"MaxSpotPrice": {
"Type": "Number",
"Description": "The global maximum price for preemptible instances in the auto provisioning group.\nIf both the MaxSpotPrice and LaunchTemplateConfig.N.MaxPrice parameters are specified, the maximum price is the lower value of the two.",
"Default": 5
},
"DefaultTargetCapacityType": {
"Type": "String",
"Description": "The type of supplemental instances. When the total value of PayAsYouGoTargetCapacity and SpotTargetCapacity is smaller than the value of TotalTargetCapacity, the auto provisioning group will create instances of the specified type to meet\nthe capacity requirements. Valid values:\nPayAsYouGo: Pay-as-you-go instances.\nSpot: Preemptible instances.\nDefault value: Spot",
"AllowedValues": [
"PayAsYouGo",
"Spot"
],
"Default": "PayAsYouGo"
},
"AutoProvisioningGroupType": {
"Type": "String",
"Description": "The type of the auto provisioning group. Valid values:\nrequest: One-time delivery. After the auto provisioning group is started, it only attempts\nto create an instance cluster once. If the cluster fails to be created, the group\ndoes not try again.\nmaintain: The continuous delivery and maintain capacity type. After the auto provisioning group\nis started, it continuously attempts to create and maintain the instance cluster.\nThe auto provisioning group compares the real-time and target capacity of the cluster.\nIf the cluster does not meet the target capacity, the group will create instances\nuntil the cluster meets the target capacity.\nDefault value: maintain",
"AllowedValues": [
"maintain",
"request"
],
"Default": "maintain"
},
"ExcessCapacityTerminationPolicy": {
"Type": "String",
"Description": "The shutdown policy for excess preemptible instances followed when the capacity of\nthe auto provisioning group exceeds the target capacity. Valid values:\nno-termination: Excess preemptible instances are not shut down.\ntermination: Excess preemptible instances are to be shut down. The action to be performed on these\nshutdown instances is specified by the SpotInstanceInterruptionBehavior parameter.\nDefault value: no-termination",
"AllowedValues": [
"no-termination",
"termination"
],
"Default": "termination"
},
"TerminateInstances": {
"Type": "Boolean",
"Description": "Specifies whether to release instances of the auto provisioning group. Valid values:\ntrue\nfalse\nDefault: false",
"AllowedValues": [
true,
false
],
"Default": true
},
"TerminateInstancesWithExpiration": {
"Type": "Boolean",
"Description": "The shutdown policy for preemptible instances when the auto provisioning group expires.\nValid values:\ntrue: shuts down preemptible instances. The action to be performed on these shutdown instances\nis specified by the SpotInstanceInterruptionBehavior parameter.\nfalse: does not shut down preemptible instances.\nDefault: false",
"AllowedValues": [
true,
false
],
"Default": true
}
},
"Resources": {
"LaunchTemplate": {
"Type": "ALIYUN::ECS::LaunchTemplate",
"Properties": {
"LaunchTemplateName": {
"Ref": "LaunchTemplateName"
},
"VersionDescription": "Test create LaunchTemplate",
"ImageId": {
"Ref": "ImageId"
},
"InstanceType": {
"Ref": "InstanceType"
},
"SystemDiskCategory": {
"Ref": "SystemDiskCategory"
},
"SecurityGroupId": {
"Ref": "SecurityGroupId"
},
"VSwitchId": {
"Ref": "VSwitchId"
}
}
},
"AutoProvisioningGroup": {
"DependsOn": "LaunchTemplate",
"Type": "ALIYUN::ECS::AutoProvisioningGroup",
"Properties": {
"LaunchTemplateId": {
"Fn::GetAtt": [
"LaunchTemplate",
"LaunchTemplateId"
]
},
"LaunchTemplateVersion": "1",
"TotalTargetCapacity": {
"Ref": "TotalTargetCapacity"
},
"PayAsYouGoTargetCapacity": {
"Ref": "PayAsYouGoTargetCapacity"
},
"SpotTargetCapacity": {
"Ref": "SpotTargetCapacity"
},
"AutoProvisioningGroupName": {
"Ref": "AutoProvisioningGroupName"
},
"SpotAllocationStrategy": {
"Ref": "SpotAllocationStrategy"
},
"SpotInstancePoolsToUseCount": {
"Ref": "SpotInstancePoolsToUseCount"
},
"LaunchTemplateConfig": [
{
"Priority": 1,
"WeightedCapacity": 1,
"VSwitchId": {
"Ref": "VSwitchId"
},
"MaxPrice": 1
}
],
"Description": "Test AutoProvisioningGroup",
"PayAsYouGoAllocationStrategy": {
"Ref": "PayAsYouGoAllocationStrategy"
},
"MaxSpotPrice": {
"Ref": "MaxSpotPrice"
},
"DefaultTargetCapacityType": {
"Ref": "DefaultTargetCapacityType"
},
"AutoProvisioningGroupType": {
"Ref": "AutoProvisioningGroupType"
},
"ExcessCapacityTerminationPolicy": {
"Ref": "ExcessCapacityTerminationPolicy"
},
"TerminateInstances": {
"Ref": "TerminateInstances"
},
"TerminateInstancesWithExpiration": {
"Ref": "TerminateInstancesWithExpiration"
}
}
}
},
"Outputs": {
"AutoProvisioningGroupId": {
"Description": "The ID of the auto provisioning group.",
"Value": {
"Fn::GetAtt": [
"AutoProvisioningGroup",
"AutoProvisioningGroupId"
]
}
},
"LaunchTemplateId": {
"Value": {
"Fn::GetAtt": [
"LaunchTemplate",
"LaunchTemplateId"
]
}
},
"LaunchTemplateName": {
"Value": {
"Fn::GetAtt": [
"LaunchTemplate",
"LaunchTemplateName"
]
}
},
"DefaultVersionNumber": {
"Value": {
"Fn::GetAtt": [
"LaunchTemplate",
"DefaultVersionNumber"
]
}
},
"LatestVersionNumber": {
"Value": {
"Fn::GetAtt": [
"LaunchTemplate",
"LatestVersionNumber"
]
}
}
}
}
For more examples, visit LaunchTemplate.json and LaunchTemplate.yml. In the examples, the ALIYUN::ECS::LaunchTemplate and ALIYUN::ECS::AutoProvisioningGroup resource types are used.