Updated on 2022-02-22 GMT+08:00

ECS.CloudServer

Element Description

The ECS.CloudServer element is used to deploy an ECS at the IaaS layer. It consists of CPUs, memory, images, and EVS disks.

Element Properties

Table 1 Property Description

Property

Mandatory

Descripiton

vpcId

Yes

ID of the VPC to which the ECS belongs

Type: Cloud.VPC.VPC.Id

Value Description: Use the ID of an existing VPC or a new VPC. To use a new VPC ID, you need to define the VPC object in the template and establish the dependency. You are advised to drag the object to the VPC to automatically establish the dependency.

Value Constraint: The value must satisfy the UUID rule and contain a maximum of 64 characters.

Suggestion: 1. Use the get_input function to set this field, and then the value can be automatically selected on the AOS console. 2. Use the get_reference function to obtain the VPC.VPC element created by the stack. 3. Obtain the created VPC ID on the VPC console.

mountedVolumes

No

A shared disk can be attached to multiple ECSs, but a non-shared disk can be attached to only one ECS.

Type: ECS.MountedVolumes Array

Value Description: ECS.MountedVolumes array

Value Constraint: ECS.MountedVolumes

imageId

Yes

ID of the image used by the ECS

Type: Cloud.ECS.Image.Id

Value Description: Indicates the system image of the to-be-created ECS. The ID of the created image must be specified. The ID format is UUID.

Value Constraint: The value must satisfy the UUID rule and contain a maximum of 64 characters.

Suggestion: 1. You are advised to use the get_input function to assign values so that you can select a value when using the template. Search for the information in the ECS service documentation.

serverTags

No

Tags of an ECS

Type: ECS.ServerTags array

Value Constraint: One ECS can have up to 10 tags. The key of a tag can contain only uppercase and lowercase letters, digits, underscores (_), and hyphens (-). The value of a tag can contain only uppercase and lowercase letters, digits, underscores (_), hyphens (-), and periods (.).

instances

Yes

Number of created ECSs

Type: integer

Value Description: The value ranges from 1 to 500.

Default: 1

Value Constraint: The value ranges from 1 to 500.

Suggestion: Set the value based on the live environment.

securityGroups

No

Array of the security group ID used by the cloud server

Type: ECS.SecurityGroup array

Value Description: ECS.SecurityGroup type array.

Value Constraint: The value must meet the definition of the ECS.SecurityGroup type.

flavor

Yes

ECS specifications

Type: Cloud.ECS.Flavor.Name

Value Description: ID of the system specifications of the cloud server to be created

Value Constraint: The definition of the flavor format is met.

Suggestion: You are advised to use the get_input function to set values so that you can select a value when using the template. Alternatively, you can obtain the value through ECS documentations.

serverGroupId

No

ID of the cloud server group to which the host belongs

Type: Cloud.ECS.ServerGroup.Id

Value Description: Existing cloud server group ID of the current account

Value Constraint: Existing cloud server group ID of the current account

Suggestion: If you are adding this server to an existing cloud server group, specify the server group ID. If you are adding this server to a cloud server group created together with this server in the same template, use the get_reference function to automatically obtain the value.

nics

Yes

Information about the NIC of the ECS

Type: ECS.NICS array

Value Description: ECS.NICS type array

Value Constraint: The value must comply with the definition of the ECS.NICS type. The minimum length of the array is 1 and the maximum is 12.

rootVolume

Yes

System disk configuration of the ECS

Type: ECS.RootVolume

Value Description: ECS.RootVolume type

Default: {u'volumeType': u'unset', u'size': 40}

Value Constraint: The value must meet the definition of the ECS.RootVolume type.

userData

No

User data to be injected during ECS creation. Texts, text files, or GZIP files are supported.

Type: string

Value Description: Customize the value.

Value Constraint: The content to be injected must be encoded using base64. The maximum size of the content to be injected before encoding is 32 KB. If key_name is not specified, the data injected by user_data is the password of the root user for logging in to the ECS by default. This parameter is mandatory when you create a Linux ECS using the password authentication mode. Its value is the initial password of the root user.

Suggestion: Set this parameter based on live network. For more information about user data to be injected, see section "Injecting User Data into ECSs" of Elastic Cloud Server User Guide.

availabilityZone

Yes

AZ to which the ECS belongs

Type: Cloud.ECS.AvailabilityZone.Name

Value Description: AZ where the to-be-created ECS is located. The name of the AZ needs to be specified.

Value Constraint: The value varies depending on regions.

Suggestion: Use the get_input function to set this field, and then the value can be automatically selected on the AOS console.

dataVolumes

No

Data disk configuration of the ECS

Type: ECS.DataVolume array

Value Description: ECS.DataVolume type array

Value Constraint: The value must meet the definition of the ECS.DataVolume type.

name

Yes

ECS name

Type: string

Value Description: Customize the value, for example, myvm.

Value Constraint: The value contains 1 to 64 characters. This value is unique under an account, and must meet regular expression {"regex":"^[a-zA-Z][0-9a-zA-Z-_]*$","min_length":1,"max_length":64}.

Suggestion: Customize the value.

publicIP

No

Elastic IP address of the ECS

Type: ECS.PublicIP

Value Description: ECS.PublicIP type

Default: {}

Value Constraint: The value must meet the definition of the ECS.PublicIP type.

adminPwd

No

Initial login password of the administrator account for logging in to an ECS using password authentication.

Type: password

Value Description: The Linux administrator is root. The Windows administrator is Administrator. Set either a login key or login password.

Value Constraint: 1. Enter 8 to 26 characters. The password must contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters !@$%^-_=+[{}]:,./?. 2. The password cannot contain the username or the username in reverse. 3. The Windows ECS password cannot contain the username, the username in reverse, or more than two consecutive characters in the username.

Suggestion: It is advised to set this parameter using the get_input function.

sshKeyName

No

SSH key pair for login

Type: Cloud.ECS.KeyPair.Name

Value Description: It must be created in advance on the ECS console. Set either a login key or login password.

Value Constraint: The value contains 1 to 64 characters. This value is unique under an account, and must meet regular expression {"regex":"^[a-zA-Z][0-9a-zA-Z-_]*$","min_length":1,"max_length":64}.

Suggestion: 1. You are advised to use the get_input function to assign values so that you can select a value when using the template. 2. Obtain the information on the ECS console and then enter the information accordingly.

Relationships Between Elements

Table 2 Relationship description

Description

Target

Inclusion

VPC.VPC

Connected

VPC.SecurityGroup

Dependency

SFS.FileSystem

Connected

VPC.Subnet

Connected

ECS.KeyPair

Connected

VPC.EIP

Return Value

Property

Type

Description

publicIps

string

Elastic IP address array of an ECS instance

privateIps

string

Private IP address array of an ECS instance

floatingIpIds

string

Elastic IP address ID array of an ECS instance

refID

Array

List of all ECS instance IDs

refName

Array

List of all ECS instance names

Blueprint Example

The following uses the CloudServer resource orchestration blueprint as an example:

  • Creating a subnet under the existing VPCs and subnets.
    tosca_definitions_version: cloud_tosca_version_1_0
    inputs:
      ecs-name:
        default: "my-cloudserver"
      ecs-image:
        default: "327946b5-e954-42c3-949a-3312688c9269"
      ecs-flavor:
        default: "c2.large"
      vpc-id:
        default: "ba6e4347-99d2-4649-b114-85c28d3d71b0"
      az:
        default: "az1.dc1"
      subnet-vpcid:
        default: "3be61f68-9bfc-41bf-8f5e-66c57122f270"
      ecs-volumetype:
        default: "SATA"
      ecs-sshKeyName:
        default: "KeyPair-magento"
    node_templates:
      my-ecs:
        type: Cloud.ECS.CloudServer
        properties:
          name: {get_input: ecs-name}
          instances: 2
          imageId: {get_input: ecs-image}
          flavor: {get_input: ecs-flavor}
          vpcId: {get_input: vpc-id}
          availabilityZone: {get_input: az}
          nics:
            - subnetId: {get_input: subnet-vpcid}
          rootVolume: 
            volumeType: {get_input: ecs-volumetype}
          dataVolumes:
            - volumeType: SATA
              size: 100
          sshKeyName: {get_input: ecs-sshKeyName}
  • Associating with a VPC and subnet. CloudServer is automatically created under the newly created VPC and subnet.

    If you have not created a VPC or subnet, or you do not need to use an existing VPC or subnet, you can create a blueprint file and create a VPC, subnet, and CloudServer at the same time. When you create CloudServer, it can be automatically associated with the created VPC and subnet. The following is an example:

    • Add the dependency requirements to the desired subnet. In this manner, the objects on which the subnet depends will be created during blueprint execution.
    • For the vpcId property and its value on a subnet, use the get_attribute function to obtain the response attribute refID of the created VPC (my-vpc).
    • For the subnetId property and its value in vpcId and nics on CloudServer, use the get_attribute function to obtain the response attribute refID of the created subnet (my-subnet).
    tosca_definitions_version: cloud_tosca_version_1_0
    inputs:
      ecs-name:
        default: "my-cloudserver"
      ecs-image:
        default: "327946b5-e954-42c3-949a-3312688c9269"
      ecs-flavor:
        default: "c2.large"
      ecs-volumetype:
        default: "SATA"
      az:
        default: "az1.dc1"
      subnet-name:
        default: "my-ecs-subnet2"
      subnet-cidr:
        default: "192.168.1.0/24"
      subnet-gateway:
        default: "192.168.1.1"
      vpc-name:
        default: "my-ecs-vpc2"
      vpc-cidr:
        default: "192.168.0.0/16"
    node_templates:
      my-ecs:
        type: Cloud.ECS.CloudServer
        properties:
          name: {get_input: ecs-name}
          instances: 1
          imageId: {get_input: ecs-image}
          flavor: {get_input: ecs-flavor}
          vpcId: {get_attribute: [my-vpc, refID]}
          availabilityZone: {get_input: az}
          nics:
            - subnetId: {get_attribute: [my-subnet, refID]}
          rootVolume: 
            volumeType: {get_input: ecs-volumetype}
          dataVolumes:
            - volumeType: SATA
              size: 100
        requirements:
          - nics.subnetId:
              node: my-subnet
        my-subnet:
        type: Cloud.VPC.Subnet
        properties:
          name: {get_input: subnet-name}
          cidr: {get_input: subnet-cidr}
          gateway: {get_input: subnet-gateway}
          dnsList: [114.114.114.115,114.114.114.114]
          vpcId: {get_attribute: [my-vpc, refID]}
          availabilityZone: {get_input: az}
        requirements:
          - vpcId:
              node: my-vpc
      my-vpc:
        type: Cloud.VPC.VPC
        properties:
          name: {get_input: vpc-name}
          cidr: {get_input: vpc-cidr}