Create a model through Terraform templates
What is Terraform
Hashicorp Terraform is an open source IaC (Infrastructure-as-Code) tool for configuring and deploying cloud infrastructure. It codifies infrastructure in configuration files that describe the desired state for your topology. Terraform enables the management of any infrastructure such as public and private clouds.
What is a Terraform template
A Terraform Template is a declarative code set written in HashiCorp Configuration Language (HCL), acting as a blueprint to define specific infrastructure resources. This approach ensures efficient and consistent configuration.
Templates are usually composed of multiple files, each dedicated to specific aspects of the overall template. This organization allows grouping diverse resource types, from networks to operating systems, facilitating flexible and scalable infrastructure design.
VM template
This module is a template for the creation of the particular resources of each instance we are going to deploy, such as the VM, Network Interfaces, OS image, caching and storage type of the OS disk, and more.
The VM resource that you wish to instantiate must have the label "vdi_instance". Otherwise, it will not be recognized as a VDI Resource.
resource "aws_instance" "vdi_instance" {
ami = var.ami
instance_type = var.instance_type
network_interface {
network_interface_id = aws_network_interface.my_nic.id
device_index = 0
}
tags = {
Name = var.vmname
}
}
Multiple instantiation
Manually deploying each VM instance can be time consuming and prone to configuration errors, that's why Cloud Manager offers a solution by automating the provisioning process using Terraform's iterative capabilities.
Begin by defining the configuration for your VM instance in your VM Template. Configure the necessary parameters such as Instance Type, OS image, Networking settings, etc.
Use the for_each construct to iterate over a list of VM configurations. This list needs to use the variable vdi_instances. This will allow you to dynamically create multiple instances based on the specified parameters. The variable vdi_instances can be directly used in resource configurations or other parts of the Terraform code, referencing it as var.vdi_instances.
//Definition of "vdi_instances" in variables.tf
variable "vdi_instances" {
type = list(string)
default = ["vm1","vm2"]
}
//Example use based on Microsoft Azure
resource "azurerm_windows_virtual_machine" "vdi_instance" {
for_each = toset(var.vdi_instances)
name = each.value
admin_username = var.admin_username
admin_password = var.admin_password
location = var.location
resource_group_name = var.resource_group
...
}
Shared template
Consider utilizing a Shared template or module for provisioning shared resources across multiple instances. This approach allows you to define and manage common infrastructure components such as Network Security Groups, Virtual Networks, Subnets, and more. These resources will be linked to the Main module via output variables, customized according to the specific requirements of the Cloud Provider.
//Example output.tf based on Microsoft Azure
output "subnet_id" {
value = azurerm_subnet.my_terraform_subnet.id
}
output "security_group_id" {
value = azurerm_network_security_group.my_terraform_nsg.id
}
//Example output.tf based on Microsoft Azure
//Connect the security group to the network interface
resource "azurerm_network_interface_security_group_association" "example" {
for_each = toset(var.vdi_instances)
network_interface_id = azurerm_network_interface.my_terraform_nic[each.value].id
network_security_group_id = var.security_group_id
}
//Create network interface
ip_configuration {
name = "my_nic_configuration"
subnet_id = var.subnet_id
private_ip_address_allocation = "Dynamic"
public_ip_address_id = azurerm_public_ip.my_terraform_public_ip[each.value].id
}
Creating a Model
Once your Terraform templates are created, you are ready to use them to create a model.
Log in to Thinfinity® Workspace.
Click on your profile picture to display a menu in which Cloud Manager should appear as an option.

Next, click on + Add > VDI/DaaS Model to initiate the Wizard.
Select your Cloud Provider. We will authenticate through Azure for this example.
Select Custom when prompted by the Wizard.

Select your existing cloud provider credentials or enter them if you haven't done so in the Credentials tab. Give them an identifying Name and Description and click Next.

Enter your Configuration parameters and click Next. Remember that these configuration parameters are Cloud specific.

Next, in Provisioning Options, select a connection mode and a pool mode.
Public IP
Assigns a public IP address, allowing direct internet access.
Private IP
Assigns a private IP address, restricting access to within the virtual network.
Breadth-First
Distributes new connections evenly across available hosts in a pool.
Depth-First
Assigns new connections to a single host until capacity is reached, then moves to the next.
None
Instances are not part of a pool, operating independently without load balancing.
Then select a Deployment mode.
On demand
Will trigger a deployment whenever an access profile is opened
Scheduled
Instances are automatically deployed at specific times according to a predefined schedule
Configure the Power options.
On demand
Manually set a fixed number of minutes to turn an instance off after disconnecting from it.
Scheduled
Instances automatically turn on and off at specific times according to a predefined schedule.
Both
You have the flexibility to either manually control the instances power state or let them operate on a schedule, depending on your requirements.
Configure how instances are destroyed.
Never
Instances will persist indefinitely unless manually deleted.
Scheduled
Instances are automatically destroyed at specific times according to a predefined schedule.
To finish, enter an identifying name and description for your new model.
If the model was created successfully, the Wizard will display a message confirming the creation of the model.
Last updated