Skip to content

Virtual Networks

Corey Melanson edited this page Jul 19, 2018 · 1 revision

Resource Parameters

The opennebula_vnet resource accepts the following parameters:

Parameter Optional Description
name Required Name of the new virtual machine
permissions Optional Chmod the VNET, defaults to the UMASK in OpenNebula
description Optional Description for the image (shows up in Sunstone)
reservation_vnet Required Create a reservation VNET from this parent VNET ID
reservation_size Required When creating a VNET reservation, request this many IPs from the parent VNET
security_groups Required Array of Security Group IDs which can be applied to the VNET and VMs created from it

Note: There are some other parameters available for creation of new VNETS, but they are not for VNET reservations and aren't documented here.

Examples

Allocate a new VNET from the parent VNET 394 and apply 3 security groups to it (which are also managed by Terraform).

resource "opennebula_vnet" "reservation" {
    name = "terravnetres"
    description = "my terraform vnet"
    reservation_vnet = 394
    reservation_size = 5
    security_groups = ["${opennebula_secgroup.mysecgroup.id}","${opennebula_secgroup.mysecgroup2.id}","${opennebula_secgroup.mysecgroup3.id}"]
}

Importing an Existing VNET

To import an existing VNET #1234 into Terraform, add this declaration to your .tf file (don't specify the reservation_size):

resource "opennebula_vnet" "importtest" {
    name = "importedvnet"
    reservation_vnet = 394
    # Security group "0" allows open access
    security_groups = ["0"]
}

And then you would execute:

terraform import opennebula_vnet.importtest 1234

And verify that Terraform doesn't want to make any changes (adjusting as necessary):

terraform plan
Clone this wiki locally