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(*args, **kwargs)

Bases: RuntimeTool, DockerTool

Main tool for managing the cloud environment using Terraform.

Deprecated since version 1.33.0: Deprecated class.

NAME = 'terraform'

The name of the logger for this tool. Must be redefined in children.

DESCRIPTION = 'Genvidtech Terraform Utility'

A description of the tool, used in the help parser. Must be redefined in children.

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.

property TF

The location of the Terraform executable.

property TFS3DIR

The location of the terraform-s3-dir executable.

property terraform_config

A dictionary of some of the Terraform output and variables.

Call refresh() to refresh them.


Print the status of all services and jobs.

Changed in version 1.20.0: Will now display the version of the bastion and cluster instance.


Refresh the terraform_config values.


Return the local IP address.


Returns the IP of the default Consul service.

This method will return the host part of the environment variable CONSUL_HTTP_ADDR if it is set.

If not and the GENVID_BASTION_URL environment variable is set, the host of the url will be used.

Otherwise it will default to the environment variable GENVID_DEFAULT_IP which defaults to

Changed in version 1.28.0: The returned value now depends on the environment variables CONSUL_HTTP_ADDR and GENVID_BASTION_URL in addition to GENVID_DEFAULT_IP. See description for details.

Changed in version 1.34.0: Raise a ValueError if CONSUL_HTTP_ADDR is malformed. In particular, it should failed if the scheme is included.


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.GENVID_SDK_FOLDER 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.


Add commands for the tool.

This method must be overridden. It allows the child class to add new commands using add_command(). The list of all existing commands and their parsers are available from commands.

run_command(command, options)

Run command with those options.

You must override this method.

  • command – The name of the command to run.

  • options – A argparse.Namespace object with the options pass in arguments.