Setting Up the Genvid Cluster in Azure

Set Up a Bastion Server

To create a cluster, you first need a Genvid bastion server running. You can set up and manage a bastion server using the genvid-bastion script. The following command will set up one with the minimal services required.

From your shell, run:

genvid-bastion install --bastionid mybastion --checkmodules --update-global-tfvars --loadconfig
--bastionid mybastion
A unique identifier for your bastion. It must:
  • Be between 3 and 64 characters.
  • Only contain lowercase letters, numbers, or hyphens.
  • Start with a letter.
Use this option to install new modules if none exist or update the ones already present.
Use this option to update the global Terraform variables.
Use this option to load the jobs and logs.


Due to limitations with the Windows file system directory length, system username and Bastion ID also factor into the max possible cluster name length. We’ve set a reasonably safe name length limit, but it’s technically possible for this limit to still cause issues if the user has an especially long username and/or Bastion ID.


The bastion is configured through a series of files available under ROOTDIR/bastion-services/.


This folder contains files loaded before launching the bastion job. The content is added to the key-value store, where each object describes a folder and each value is converted to a string and inserted as a key.

The folder location can be changed using GENVID_BASTION_INIT_FOLDER. For more information, see setup_jobs().

Configure the Cluster


Before configuring the cluster, make sure that azure account has been set up and you are logged in to azure. Also, the azure base images need to be created and configured. The information on how to login to Azure and configure images can be found here Creating a Cloud Environment.

The next step is to open the Bastion-UI to manage the Clusters.

  1. From your shell, run:

    genvid-bastion monitor
  2. Select the Terraform page.

  3. Click Add Config.

  4. Enter a unique ID.

  5. Select cluster as the category.


We are limiting the length of cluster id to 64 characters due to technical limitation.

Create a cluster

You can select another backend if needed. For now, you can stick with the default values. Some backends may require configuring variables.

After creating a cluster, its status is EMPTY. This means that the cluster needs a module. The cluster statuses are:

Cloning a Cluster

It is a good practice to use the cloning function when you want to create different clusters with similar configurations. You can do this using the Clone button on the Terraform configuration view.

Clone a cluster

Cluster Statuses

After creating a cluster, its status is EMPTY. This means that the cluster needs a module. The cluster statuses are:

  • VOID: The cluster doesn’t exist.
  • EMPTY: The cluster exists but has no modules.
  • DOWN: The cluster is initialized but resources are empty.
  • UP: The Terraform apply procedure succeeded.
  • BUSY: A command is currently running.
  • ERROR: An error occured when checking the cluster.
  • INVALID: The cluster is reporting an invalid or unknown status.

Initialize Cluster Using a Terraform Module

Before configuring the cluster, you must initialize it with a module. This copies the module template and downloads any providers and plugins it requires.

  1. Click on the name of your chosen ID.

  2. You can either select the SDK-{version}/basic/azurerm_basic_cluster or SDK-{version}/basic/azurerm_basic_cluster_alb_ssl modules. (The azurerm_basic_cluster_alb_ssl module supports load balancing, DNS, and SSL certificates)

  3. Click Import module.

Terraform module

You will see an initialization log appear. This step should last only a few seconds.

Build the Cluster Infrastructure

To build the cluster infrastructure, you apply a Terraform execution plan.

  1. Click Plan Apply to create an execution plan.

  2. Verify the changes match what you need.

  3. Click Apply to execute the plan.

Terraform Plan Apply
Terraform Apply


The module is using the compute instance type Standard_NV6 for the game machine. For some accounts, only the promo version of this instance type is available (Standard_NV6_Promo).

If the active account and location does not have the Standard_NV6, the Terraform output will show this error:

The requested size for resource 'XXXX-game-1' is currently not available in location 'XXXX'

As a workaround, you can go to your Terraform Settings page and change the instance_game_type to Standard_NV6_Promo, then go to the Commands page and try Plan apply and Apply again. If the promo type is not available either, connect on the Azure portal and see what other types are available. Look for another NV type of instance or any other that support NVidia graphics drivers.

You should see the log starting to appear.

If Terraform fails to build the infrastructure:
  • Check the error message.
  • Update the settings.
  • Apply again.

At the end of this step, there is a cluster running on the cloud. When you check All Configs on the Terraform page, the status is UP. This means that the infrastructure is up and ready for the Genvid MILE SDK.


When you have an existing cluster that you no longer need, there are specific commands used to clean them up. See Cleaning Up Unneeded Clusters for more information.


All resources created for a cluster have the following tags to identify them:

genvid:cluster-name: The name of the cluster. genvid:creator-service-id: The Bastion ID, when created through the Bastion UI.


Starting in v1.26, resources will no longer be provided a name. Identification will be handled by tags.
All numbered resources will also have their index offset removed, and will start counting from 0 instead of 1 to simplify logic:
encoding-1 -> encoding-0
game-1 -> game-0
internal-1 -> internal-0
public-1 -> public-0
server-1 -> server-0

Terraform Settings

Basic Terraform settings

Fig. 9 Bastion-UI settings for basic Azure cluster

Terraform settings with SSL, DNS, and application gateway

Fig. 10 Bastion-UI settings for Azure cluster with SSL, DNS, and application gateway (if azurerm_basic_cluster_alb_ssl is selected)

We use Terraform to build the cluster infrastructure, so the setting values configure the cluster infrastructure. Click the Settings sub link for your cluster and edit the settings.


For ease of use you can also download the settings on the page to a JSON file. You can drag and drop the edited file on the form to edit multiple settings at once or revert to a previous configuration. Please note that all unsaved configurations will be lost.

Details for cluster variables can be found here: Terraform Modules

Azure Cluster with SSL and DNS Settings

You can create an Azure cluster with both SSL and DNS features. To use this type of cluster, you need to have a registered domain in Azure DNS zones. It will automatically add two “A” record sets in your domain named web-{clustername} and leafs-{clustername}. For example, if your domain is and your cluster name is stream, your final endpoints for leaf and web will be and

You need to provide the required certificates to use the cluster. You can use either a wildcard certificate or two separate certificates for leaf and web services.

For some streaming services (like Twitch), your certificates must be valid but not self-signed. Certificates also need to have a password and be in .pfx format.

See the Terraform Configuration Documentation for more information on how to set up these variables globally or locally.

Availability Zone Examples:

  • 3 instances, azs: [] -> multi-az disabled
  • 3 instances, azs: [2] -> all 3 instances are created in zone 2
  • 3 instances, azs: [1, 2, 3] -> instance 1: zone 1, instance 2: zone 2, instance 3: zone 3
  • 3 instances, azs: [1, 3] -> instance 1: zone 1, instance 2: zone 2, instance 3: zone 1
  • 4 instances, azs: [1, 2] -> instance 1: zone 1, instance 2: zone 2, instance 3: zone 1, instance 4: zone 2


  • Availability zones are not available for Game Instances. Azure does not support zones for GPU instances.
  • Changing the number of Server instances specifically will force a rebuild of all instances. This causes the internal IP addresses to be updated, which the other services need to be reinitialized with.

Terraform Providers

Providers are specific to a cluster and, more specifically, to the module imported in that cluster. Thus, let us start by creating a new cluster and importing some module on it.


Fig. 11 On the first import, you will see the provider plugins being downloaded. It is a great way to know which providers are used by a specific module.

Every provider has its own set of arguments it recognizes. The best way to know how a specific provider can be customized is by visiting the Terraform Providers page and looking up the specific providers you are interested in.

Customizing Terraform Providers

(Global) Default Configuration

There are two levels at which providers configuration can be customized: at the global (bastion) level or on the cluster directly after importing a module. The global configuration is meant to give a default configuration to new clusters (or on a reimport of the module).


During the installation of the bastion, we set up such a configuration so that your clusters work out of the box with any of the modules we provide. The information is loaded from a file stored at bastion-services/terraform/providers/default.json.

When you import a module into a cluster, only the default configurations for providers that this module uses are applied. So it’s safe to add configurations for providers that aren’t used by every module.


To add a new default configuration for a provider:

  1. Open the Bastion UI page.

  2. Click Settings.

  3. Click Providers.

  4. Click + NEW PROVIDER.

  5. Enter a unique name for Provider and Alias to identify the provider you want to customize.


    The identifiers you use for Provider and Alias are checked when you import a module into a cluster. If they don’t match a provider used by that module, the default configuration won’t be applied.

  6. If you have one or more arguments you need to set for a provider, click + to add each.

  7. Click SAVE to save the provider configuration.

Per-Cluster Configuration

After importing a module on your cluster, you can go to the Provider tab (under Terraform) to see its current configuration.


Fig. 12 Like for the Settings tab, if you did not import a module yet, you will be invited to do so by going to the Commands page.

By default, the configuration should be empty, unless some providers have a global configuration which will be automatically applied by this point. Any further change made to the cluster’s providers will only affect that cluster.


If the cluster’s module is re-imported, the global configuration will override its configuration.


Fig. 13 As you can see in this example, Terraform variable interpolation is supported to specify values for the providers’ arguments.

Once your cluster is created and you know which providers you want to customize, you may go to Terraform, from the top menu, and then Provider under the cluster’s name from the left menu.

The process to customize providers is very similar to the global case. The + ADD PROVIDER button is used to add a configuration for a provider not yet listed. Otherwise, the edit button (the left Action button) can be used to customize existing configurations.


The changes to the providers configuration might not take effect until a Refresh command is issued.

Terraform Providers Arguments

You can give aliases to different provider configurations. The Terraform init phase considers the configurations, then the plan and apply phases use the arguments. Arguments vary between providers.


If you notice some arguments are ignored at the plan phase, try to issue a Refresh to update Terraform’s state with the new configuration.

Provider aliases might not be useful unless you write your own Terraform module. More information can be found on Terraform Provider Configuration page.

Terraform Provider Versions


Starting with Genvid MILE SDK version 1.28.0, you will no longer be able to directly change a provider version from the Bastion UI.

See Terraform Provider Requirements for a guide on specifying provider versions in your custom modules.

If you wish to manually modify a provider version on one of our supplied clusters, you can find the declarations in bastion-services/terraform/modules/basic/cluster/

When you change the Terraform files, refresh your modules in the Bastion UI for the changes to take effect. See Modules Section for more information.

Terraform Providers Toolbox Support

We offer subcommands in the Toolbox to help managing providers. The following table summarizes the commands available.

Command Description
genvid-bastion get-default-terraform-providers Display the current global providers configuration in JSON.
genvid-bastion set-default-terraform-providers Set the global providers configuration from a JSON file matching the format from get-default-terraform-providers.
genvid-bastion delete-default-terraform-providers Delete the existing global providers configuration.
genvid-clusters get-terraform-providers Display the current providers configuration of a specific cluster.
genvid-clusters set-terraform-providers Set the providers configuration of a specific cluster from a JSON file matching the format from get-terraform-providers.
genvid-clusters delete-terraform-providers Delete the existing providers configuration of a specific cluster.

While the easiest way to create a new providers configuration is to use the bastion UI and then the toolbox to redirect the configuration into a file, here is an example in case you want to write it by hand:

        "provider": "azurerm",
        "alias": null,
        "arguments": {
            "region": "East US"
        "provider": "template",
        "alias": null,
        "arguments": {}
        "provider": "tls",
        "alias": "myalias"
        "arguments": {}

Applying a Terraform Infrastructure

Terraform Apply is the operation that builds the cluster infrastructure.

  1. Click Plan Apply to create an execution plan.
  2. Verify the changes match what you need.
  3. After verifying the changes, click Apply to execute the plan.
Terraform Plan Apply
Terraform Apply

You should see the log starting to appear.

If Terraform fails to build the infrastructure:
  • Check the error message.
  • Update the settings.
  • Apply again.

At the end of this step, there is a cluster running on the cloud. When you check All Configs on the Terraform page, the status is UP. This means that the infrastructure is up, but the Genvid MILE SDK is not yet present in it.


Beginning in version 1.19.0, instances provision in the background after Terraform creates them. You need to wait until an instance registers as a Nomad client in the Cluster UI before using it. In particular, Windows instances may take up to 30 minutes before they are ready.


The public machine IP is not the same as the one used when setting up your AMI.

To access your game machine, use the IP from game_public_ips with the same password set during the AMI setup.

To retrieve the game_public_ips:

  1. Make sure the cluster is UP.
  2. Go to the Commands page of your cluster.
  3. Click the OUTPUT button.

You’ll find the game_public_ips listed in the JSON file.

Setting up the SDK on a Running Cluster

Once a cluster status is UP, you will need to set up the Genvid MILE SDK on it and run your project there.

Follow the SDK in the Cloud guide to do so.

Destroying a Terraform Infrastructure

The terraform destroy command removes all resources from the cluster configuration. You should only destroy a cluster’s Terraform infrastructure when you no longer need to run your project on that cluster. To destroy the Terraform infrastructure, click Plan destroy.

If you’re sure you want to destroy the current Terraform infrastructure, click the Destroy button to confirm.

See Destroy Infrastructure for more information.

Deleting a Cluster

To delete a cluster, you have to destroy the Terraform infrastructure first. Go to All Configs and click the Delete button.

Using Custom Repositories

You can add and remove individual Terraform repositories in the bastion. Each repository contains one or more modules that can be used to instantiate a cluster. Use the following command to list the current repositories:

genvid-clusters module-list

Use the following command to add a new module:

genvid-clusters module-add -u {URL} {name}
  • {URL} can be any source compatible with go-getter, including local files.
  • {name} is the destination folder to this repository on your bastion.

After the URL is cloned in the bastion repository, it will be available as a source under modules/module. See Terraform’s Module Configuration for more details on using modules.

Bastion remembers the origin of each module, so you can update them using the following command:

genvid-clusters module-update [name]

The name is optional. If you don’t provide a name, it will update all repositories.

You can remove a module using the following command:

genvid-clusters module-remove {name}

See also

Genvid Cluster-Management script documentation.
Bastion API for Terraform
Bastion API for Terraform.
Terraform’s Module Configuration
Documentation of Modules on Terraform.
A library for fetching URL in Go.