Updated on 2023-08-11 GMT+08:00

ECS.CloudServer

Element Description

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

Element Properties

Table 1 Property Description

Property

Required

Descripiton

vpcId

Yes

ID of the VPC to which the ECS belongs

Type: HuaweiCloud.VPC.VPC.Id

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

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

Suggestion: 1. Use the get_input function to import this field. The value can be automatically selected on the AOS page. 2. Use the get_reference function to obtain the VPC.VPC element created by the stack. The element is automatically specified when you use the designer to establish the dependency relationship. 3. Obtain the created VPC ID on the VPC page (https://console.huaweicloud.com/vpc?&locale=en-us).

mountedVolumes

No

mount volumes

Type: ECS.MountedVolumes Array

Value Description: ECS.MountedVolumes array

Value Constraint: ECS.MountedVolumes

Suggestion: refer https://support.huaweicloud.com/eu/api-ecs/ecs_02_0307.html

imageId

Yes

ID of the image used by the ECS

Type: HuaweiCloud.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 support 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. 2. For the ECS documentation, visit https://support.huaweicloud.com/eu/api-ecs/en-us_topic_0020212668.html.

serverTags

No

Specifies the tags of an ECS.

Type: ECS.ServerTags Array

Value Constraint: One ECS supports up to 10 tags. The key contains a maximum of 36 Unicode characters. This field cannot be left blank. It cannot contain ASCII (0-31) or the following characters: "=*<>\,|/".The value can contain a maximum of 43 Unicode characters and can be left blank. It cannot contain ASCII (0-31) or the following characters: =*<>\,|/

instances

Yes

Number of created ECSs

Type: integer

Value Description: Supports 1-500.

Default: 1

Value Constraint: The value ranges from 1 to 500.

Suggestion: Set the value based on specifications and requirements.

securityGroups

No

Array of the security group ID used by the cloud server

Type: ECS.SecurityGroup Array

Value Description: Indicates the ECS.SecurityGroup type array.

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

Suggestion: For details, see the ECS documentation at https://support.huaweicloud.com/eu/api-ecs/en-us_topic_0020212668.html.

flavor

Yes

ECS specification

Type: HuaweiCloud.ECS.Flavor.Name

Value Description: Indicates the ID of the system flavor of the to-be-created ECS. For example, c1.medium indicates 1-core CPU and 1 G memory while c2.large indicates 2-core CPU and 4 G memory. For details about the available flavors, see Instances and Application Scenarios in the Elastic Cloud Server User Guide https://support.huaweicloud.com/eu/productdesc-ecs/en-us_topic_0035470096.html.

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

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. For the ECS documentation, visit https://support.huaweicloud.com/eu/api-ecs/en-us_topic_0020212668.html.

serverGroupId

No

ID of the cloud server group to which the host belongs

Type: HuaweiCloud.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: Indicates the ECS.NICS type array.

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

Suggestion: For details, see the ECS documentation at https://support.huaweicloud.com/eu/api-ecs/en-us_topic_0020212668.html.

rootVolume

Yes

System disk configuration of the ECS

Type: ECS.RootVolume

Value Description: Indicates the ECS.RootVolume type.

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

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

Suggestion: For details, see the ECS documentation at https://support.huaweicloud.com/eu/api-ecs/en-us_topic_0020212668.html

userData

No

User data during ECS creation. Texts, text files, or GZIP files can be injected. For more information about the user data to be injected, see https://support.huaweicloud.com/eu/usermanual-ecs/en-us_topic_0032380449.html.

Type: string

Value Description: Supports customization.

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 the value based on specifications and requirements,please visit

https://support.huaweicloud.com/eu/usermanual-ecs/en-us_topic_0032380449.html

availabilityZone

Yes

AZ to which the ECS belongs

Type: HuaweiCloud.ECS.AvailabilityZone.Name

Value Description: Indicates the AZ where the to-be-created ECS is located. The name of the AZ needs to be specified, for example, cn-north-1a. See the Regions and Endpoints.

Value Constraint: The value varies depending on the belonged region.

Suggestion: 1. Use the get_input function to import this field. The value can be automatically selected on the AOS page. 2. For details about the AZ of each region, visit https://developer-intl.huaweicloud.com/en-us/endpoint.

dataVolumes

No

Data disk configuration of the ECS

Type: ECS.DataVolume Array

Value Description: Indicates the ECS.DataVolume type array.

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

Suggestion: For details, see the ECS documentation at https://support.huaweicloud.com/eu/api-ecs/en-us_topic_0020212668.html.

name

Yes

ECS name

Type: string

Value Description: Supports customization, for example, myvm.

Value Constraint: The value contains 1 to 59 characters. This value is unique under a tenant, and must meet the following requirement: {"regex":"^[a-zA-Z][0-9a-zA-Z-_]*$","min_length":1,"max_length":59}.

Suggestion: Customize the value.

publicIP

No

Elastic IP address of the ECS

Type: ECS.PublicIP

Value Description: Indicates the ECS.PublicIP type.

Default: {}

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

Suggestion: For details, see the ECS documentation at https://support.huaweicloud.com/eu/api-ecs/en-us_topic_0020212668.html.

adminPwd

No

Specifies the 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, and the Windows administrator is Administrator. sshKey login and password login can only choose one of them.

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

Suggestion: 1. It is recommended to enter by Get_input Way

sshKeyName

No

SSH key pair

Type: HuaweiCloud.ECS.KeyPair.Name

Value Description: Must be created in advance on the ECS console.

Value Constraint: The value contains 1 to 64 characters. This value is unique under a tenant, and must meet the following requirement: {"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. Query information on the ECS page and then enter such information accordingly.

Relationships Between Elements

Table 2 Relationship description

Description

Target

ContainedIn

VPC.VPC

HostedOn

ECS.ServerGroup

Connected

VPC.SecurityGroup

DependsOn

SFS.FileSystem

Connected

VPC.Subnet

Connected

ECS.KeyPair

Connected

VPC.EIP

Connected

EVS.SharedVolume

Connected

EVS.NonSharedVolume

Return Value

Property

Type

Description

publicIps

string

List of all ECS instance publicIps

privateIps

string

List of all ECS instance privateIps

floatingIpIds

string

List of all ECS instance floatingIpIds

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:

  • Create a subnet under the existing VPCs and subnets.
    tosca_definitions_version: huaweicloud_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: HuaweiCloud.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}
  • Associate 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 object 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, the get_attribute function is used to obtain the response attribute refID of the created subnet (my-subnet).
    tosca_definitions_version: huaweicloud_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: HuaweiCloud.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
              relationship: HuaweiCloud.Relationships.ConnectsTo
      my-subnet:
        type: HuaweiCloud.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
              relationship: HuaweiCloud.Relationships.ContainedIn
      my-vpc:
        type: HuaweiCloud.VPC.VPC
        properties:
          name: {get_input: vpc-name}
          cidr: {get_input: vpc-cidr}