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

VPC.Subnet

Element Description

The VPC.Subnet element is used to create a subnet on a VPC.

Element Properties

Table 1 Property Description

Property

Mandatory

Descripiton

dnsList

No

IP address set of the DNS server on the subnet. Set this field if you want to use more than two DNS servers.

Type: ip array

Value Description: It 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, set at least one of the primaryDns and dnsLists parameters. If primaryDns, secondaryDns and dnsLists are not set, the created subnet will not have a DNS server.

vpcId

Yes

ID of the VPC to which the subnet 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 be in the CIDR format, for example, 192.168.0.0/16.

Suggestion: 1. You are advised to use the get_input function to set 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. 3. Obtain the ID of the created VPC from the VPC console.

name

Yes

Subnet name

Type: string

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

Default: ""

Value Constraint: The value contains 1 to 64 characters. The 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: It 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: 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: 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: You are advised to use the get_input function to set 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: It 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, set at least one of the primaryDns and dnsLists parameters. If primaryDns, secondaryDns and dnsLists are not set, the created subnet will not have a DNS server.

dhcpEnable

Yes

Whether to enable DHCP for the VPC subnet

Type: boolean

Value Description: true: Enabling the DHCP function. After an ECS using the VPC starts, the ECS automatically obtains an IP address using the DHCP protocol. false: Disabling 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 can be 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

Table 2 Relationship description

Description

Target

ContainedIn

VPC.VPC

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: cloud_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: Cloud.VPC.VPC
    properties:
      name:
        get_input: vpc-name
      cidr:
        get_input: vpc-cidr
  my-subnet:
    type: Cloud.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