Update the Template

Using your preferred text editor open the Apache Web Server template you created in the previous tutorial Linux Apache Web Server.

Add the Network Selector

Add the following statements after the account_region_zone_selector: section to define the Network selector.

    ################################################################################################################################################
    # This defines the network_selector which allows the user to select the network and subnet
    ################################################################################################################################################            
    network_selector:                                                 # Define the section for the Network and Subnet selection boxes
      type: dcm.inputs.Network                                        # Input type is dcm.inputs.Network
      properties:
        accountRegionSelector: account_region_zone_selector           # Reference the Cloud, Region, and Datacenter selection

Upate the Firewall

Add the following statements to the firewall vm_firewall_rules section to associate the Firewall with the virtual private cloud Network.

requirements:                                                              # Define a requirement for the Firewall to the virtual private cloud network
  - network: int_network                                                   # Link this firewall to the vpc network section named int_network
    relationship_type: tosca.relationships.DependsOn                       # Define a DependsOn relationship to the vpc network

The finished Firewall should look like this:

###################################################################################################################################################
# This node_template defines a firewall which opens the HTTP port 80 for the Apache Web server
###################################################################################################################################################
vm_firewall_rules:
  type: dcm.nodes.FirewallGroup                                              # This is a firewall
  properties:                                                                # Retrieve the cloud properties from the "inputs"
    name: "fw-apache-server"                                                 # Define a name for the firewall (it will get prefixed with the stack name)
    cloud: { get_input: [account_region_zone_selector, cloud] }              # Retrieve the cloud from the AccountRegionSelector
    cloudAccountId: { get_input: [account_region_zone_selector, accountId] } # Retrieve the cloud account ID from the AccountRegionSelector
    region: { get_input: [account_region_zone_selector, region] }            # Retrieve the region from the AccountRegionSelector
    zone: { get_input: [account_region_zone_selector, zone] }                # Retrieve the zone from the AccountRegionSelector
    rules:
      - remote_ip_prefix: 0.0.0.0/0
        port: 80                                                             # Define a rule to open port 80  (HTTP)

  requirements:                                                              # Define a requirement for the Firewall to the virtual private cloud network
    - network: int_network                                                   # Link this firewall to the vpc network section named int_network
      relationship_type: tosca.relationships.DependsOn                       # Define a DependsOn relationship to the vpc network

Add the Network

Add the following statements to define the Network node section.

###################################################################################################################################################
# This node_template defines a Virtual Private Cloud Network
###################################################################################################################################################
int_network:                                                                 # Network section name is int_network
  type: dcm.nodes.Network                                                    # Type is dcm.nodes.Network
  properties:                                                                # Retrieve the properties from the region_selector and network_selector
    cloud: { get_input: [account_region_zone_selector, cloud] }              # Retrieve the cloud from the AccountRegionSelector
    cloudAccountId: { get_input: [account_region_zone_selector, accountId] } # Retrieve the cloud account ID from the AccountRegionSelector
    region: { get_input: [account_region_zone_selector, region] }            # Retrieve the region from the AccountRegionSelector
    zone: { get_input: [account_region_zone_selector, zone] }                # Retrieve the zone from the AccountRegionSelector
    networkId: { get_input: [network_selector, networkId] }                  # Retrieve the network ID from the network_selector
    subnetId: { get_input: [network_selector, subnetId] }                    # Retrieve the subnet ID from the network_selector

Add the Port

Add the following statements to define the Port node section. The Port links the launched server to the Network.

###################################################################################################################################################
# This node_template defines a Port
###################################################################################################################################################
port:
  type: dcm.nodes.Port                                            # Type is dcm.nodes.Port
  requirements:                                                   # Define a requirement to have the virtual machines launched in a vpc network
    - link: int_network                                           # Link this Port to the vpc network section with the label int_network
    - binding: web_vm                                             # Bind the virtual machine section with the label web_vm to to port