VPC.Subnet
Element Description
The VPC.Subnet element is used to create a subnet on a Huawei VPC.
Element Properties
| 
        Property  | 
      
        Required  | 
      
        Descripiton  | 
     
|---|---|---|
| 
        dnsList  | 
      
        No  | 
      
        IP address set of the DNS server on the subnet. Use this field if you want to use more than two DNS servers. Type: ip Array Value Description: Must be an IP address array, for example, ["8.8.8.8", "4.4.4.4", "6.6.6.6"]. Value Constraint: The value must be an IP address array and contain the values of primaryDns and secondaryDns. Suggestion: If a DNS server is needed in a subnet, one of the primaryDns and dnsLists must be filled in; if primaryDns, secondaryDns and dnsLists are not filled in, the created subnet will not have a DNS server.  | 
     
| 
        vpcId  | 
      
        Yes  | 
      
        ID of the VPC to which the subnet 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 be in the CIDR format, for example, 192.168.0.0/16. Suggestion: 1. You are advised to use the get_input function to assign values so that you can select an existing VPC when creating a stack. 2. To obtain the VPC information about this template, you are advised to use the get_reference function. Such information is automatically generated when you use the designer to establish the relationship between the VPC and subnet. 3. You can obtain the created VPC ID on the VPC page (https://console.huaweicloud.com/vpc?&locale=en-us).  | 
     
| 
        name  | 
      
        Yes  | 
      
        Subnet name Type: string Value Description: Supports customization, for example, musubnet. Default: '' Value Constraint: The value contains 1 to 64 characters. This value is unique in a VPC. Only letters, digits, underscores (_), and hyphens (-) are allowed. Suggestion: Customize the value. If this parameter is left blank, the system automatically assigns a name.  | 
     
| 
        secondaryDns  | 
      
        No  | 
      
        IP address 2 of the DNS server on the subnet Type: ip Value Description: Must be in the IP address format, for example, 4.4.4.4. Value Constraint: The value must be an IP address.  | 
     
| 
        gateway  | 
      
        Yes  | 
      
        Subnet gateway Type: ip Value Description: Indicates the gateway address within the subnet CIDR address range. Default: 192.168.1.1 Value Constraint: The value must be an IP address and comply with the gateway IP address rule, for example, 192.168.1.1. Suggestion: Customize the value based on the IP address range as required.  | 
     
| 
        availabilityZone  | 
      
        No  | 
      
        AZ to which the subnet 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 Regions and Endpoints at https://developer-intl.huaweicloud.com/en-us/endpoint. Value Constraint: The value varies depending on the belonged region. For details, visit https://developer-intl.huaweicloud.com/en-us/endpoint. For the North China region, the value can be cn-north-1a or cn-north-1b. Suggestion: You are advised to use the get_input function to assign values so that you can select a value from the list when creating a stack.  | 
     
| 
        primaryDns  | 
      
        No  | 
      
        IP address 1 of the DNS server on the subnet Type: ip Value Description: Must be in the IP address format, for example, 8.8.8.8. Value Constraint: The value must be an IP address. Suggestion: If a DNS server is needed in a subnet, one of the primaryDns and dnsLists must be filled in; if primaryDns, secondaryDns and dnsLists are not filled in, the created subnet will not have a DNS server.  | 
     
| 
        dhcpEnable  | 
      
        Yes  | 
      
        Whether to enable DHCP for the VPC subnet Type: boolean Value Description: true: Enables the DHCP function. After an ECS using the VPC starts, the ECS automatically obtains an IP address using the DHCP protocol. false: Disables the DHCP function. After an ECS using this VPC starts, the ECS cannot automatically obtain an IP address. You must manually assign an IP address to the ECS. Default: True Value Constraint: The value is true or false. Suggestion: Set the value based on requirements. You are advised to enable the function.  | 
     
| 
        cidr  | 
      
        Yes  | 
      
        Range of available addresses in a subnet Type: string Value Description: Range: 10.0.0.0/8-10.255.255.0/24, 172.16.0.0/12-172.31.255.0/24, or 192.168.0.0/16-192.168.255.0/24. Default: 192.168.1.0/24 Value Constraint: The value must be in the CIDR format, for example, 192.168.0.0/16. The value must be within the VPC CIDR block. Suggestion: Customize the value based on the IP address range as required.  | 
     
Relationships Between Elements
| 
        Description  | 
      
        Target  | 
     
|---|---|
| 
        ContainedIn  | 
      
Return Value
| 
        Property  | 
      
        Type  | 
      
        Description  | 
     
|---|---|---|
| 
        neutron_network_id  | 
      
        string  | 
      
        OpenStack network ID  | 
     
| 
        vpcId  | 
      
        string  | 
      
        ID of the VPC to which the subnet belongs  | 
     
| 
        neutron_subnet_id  | 
      
        string  | 
      
        OpenStack subnet ID  | 
     
| 
        refName  | 
      
        string  | 
      
        Subnet name  | 
     
| 
        refID  | 
      
        string  | 
      
        Subnet ID  | 
     
Blueprint Example
tosca_definitions_version: huaweicloud_tosca_version_1_0
inputs:
  vpc-name:
    default: vpc
    type: string
  vpc-cidr:
    default: 192.168.0.0/16
    type: string
  subnet-name:
    type: string
    default: subnet
  subnet-cidr:
    default: 192.168.0.0/24
    type: string
  subnet-gateway:
    type: ip
    default: 192.168.0.1
  dhcenable:
    type: boolean
    default: true
  availabilityZone:
    description: Name of az
    label: ''
node_templates:
  my-vpc:
    type: HuaweiCloud.VPC.VPC
    properties:
      name:
        get_input: vpc-name
      cidr:
        get_input: vpc-cidr
  my-subnet:
    type: HuaweiCloud.VPC.Subnet
    properties:
      name:
        get_input: subnet-name
      cidr:
        get_input: subnet-cidr
      gateway:
        get_input: subnet-gateway
      dhcpEnable:
        get_input: dhcenable
      dnsList: [114.114.114.115,114.114.114.114]
      vpcId:
        get_attribute: [my-vpc,refID] 
      availabilityZone:
        get_input: availabilityZone
    requirements:
      - vpcId:
          node: my-vpc
          relationship: HuaweiCloud.Relationships.ContainedIn
 Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.