This module has been deprecated. Although the code is still working for our oldest model, it is not expected to work with the new Bastion API. Please use the new genvid-bastion tool.

class genvid.toolbox.TerraformTool(**kwargs)

Bases: genvid.toolbox.runtime.RuntimeTool, genvid.toolbox.docker.DockerTool

Main tool for managing the cloud environment using Terraform.

NAME = 'terraform'
DESCRIPTION = 'Genvidtech Terraform Utility'
ARTIFACTS_URL_TEMPLATE = '{images_domain_name}/'

The template for the base URL for loading the Docker images. It is formatted with the information inside the terraform_config property.

SERVER_CLASSES = ('server', 'public_worker', 'internal_worker')

The list of server node classes.


The location of the Terraform executable.


The location of the terraform-s3-dir executable.


A dictionary of some of the Terraform output and variables.

Call refresh() to refresh them.


Refresh the terraform_config values.


Returns the SSH command line parameters to connect to the main server.

Uses the first server IP if None is passed.

ssh(*cmd, ip=None)

Run cmd on the server designated by IP using SSH.

Uses the first server IP if None is passed.

run_nomad_fs(*args, ip=None, **kwargs)

Run nomad fs on the server using SSH.

This allows nomad fs to run on nodes which are only available through a reverse proxy.


Return the list of the private IPs of all nodes on the cluster.

If public is True it returns the public IPs instead.


Update all Docker images in the Terraform configuration.

run_tf(*args, cwd=None, **kwargs)

Run Terraform with the passed arguments.

Note that the cwd is set to self.ROOTDIR when not specified.

plan_cluster(*args, **kwargs)

Run Terraform plan.

apply_cluster(*args, **kwargs)

Run Terraform apply.

destroy_cluster(*args, **kwargs)

Run Terraform destroy.

output_cluster(*args, check=False, **kwargs)

Run Terraform output.

show_cluster(*args, **kwargs)

Run Terraform show.


Add all the commands available from TerraformTool.

Run from add_commands() to add all the commands available from Terraform to the parser. See RuntimeTool.add_runtime_commands() for other commands available from TerraformTool.

run_terraform_command(command, options)

Detect if the command is a Terraform command and execute it.

Call from run_command() to handle Terraform commands. Terraform commands are added with the help of add_terraform_commands().


handled, result: A tuple with a boolean saying if the
command was handled and its result if it was.
run_command(command, options)