Skip to content

Cubtera configuration

Configuration file

  Cubtera configuration file is a config.toml file, which should be placed by default path ~/.cubtera/config.toml. This file contains all cubtera configuration parameters, which could be used to configure cubtera behavior. If you want to use custom configuration file, you can set it with environment variable CUBTERA_CONFIG.

Configuration parameters priority is as follows:

  1. Values from env variables
  2. Values from org lvl configuration
  3. Values from default lvl configuration

Example of config.toml file

config.toml
[ default ] # all parameters are optional, default values are shown
workspace_path = "example" # default => "~/.cubtera"
temp_folder_path = "example/.cubtera/tmp" # default => "~/.cubtera/tmp"
units_folder = "units" # default => "units"
modules_folder = "modules" # default => "modules"
inventory_folder = "inventory" # default => "inventory"
units_path = "example/units" # $workspace_path/$units_folder | override units_folder
modules_path = "example/modules" # $workspace_path/$modules_folder | override modules_folder
inventory_path = "example/inventory" # $workspace_path/$inventory_folder | override inventory_folder
dim_relations = "dome:env:dc" # default => "dome:env:dc" | Relations of base dimension's types (colon separated)
orgs = "cubtera:teracub" # default => "cubtera" | List of orgs (tenants) in inventory to work with (colon separated)
# Usefully for development and CI/CD
always_copy_files = true # default => "false" | Copy files to the runner's temp folder
clean_cache = false # default => "false" | Clean runner's temp folder after successful run
[ cubtera ] # optional, custom configuration for the org, overrides default parameters with the same key
# usefully for multiple orgs management in the same inventory
[cubtera.state.s3] # optional, global org configuration for the state backend of S3 type
bucket = "{{ org }}-example-state"
key = "{{ dim_tree }}/{{ unit_name }}.tfstate"
region = "us-east-1"
[cubtera.state.local] # optional, global org configuration for the state backend of local type
path = "~/.cubtera/state/{{ org }}/{{ dim_tree }}/{{ unit_name }}.tfstate" # default
[cubtera.runner.tf] # optional, custom configuration for the runner of Terraform type
state_backend = "s3" # default => "local"
[cubtera.runner.tofu] # optional, custom configuration for the runner of Terraform type
state_backend = "s3"
inlet_command = "echo Inlet command" # default => None, will run command before runner starts, in temp folder context
outlet_command = "echo Outlet command" # default => None, will run command after runner finishes successfully, in temp folder context
version = "1.7.0" # default => latest, will be ignored if runner_command is set, will be latest if both was not defined
# runner_command = "terraform" # default => None, if None -> will proceed with internal runner logic
# extra_params = "-json" # default => None, will add extra params to the runner_command
[cubtera.runner.bash]
runner_command = "./runner.sh"
## Org specific parameters, override defaults
[ teracub ] # optional, custom configuration for the org, overrides default parameters with the same key
dim_relations = "universe:environment:dc"
[teracub.state.s3] # optional, global org configuration for the state backend of S3 type
bucket = "{{ org }}-tfstates"
key = "{{ dim_tree }}/{{ unit_name }}.tfstate"
region = "us-west-2"
[teracub.runner.tf] # optional, custom configuration for the runner of Terraform type
state_backend = "s3" # default => "local"

Inventory parameters

  • workspace_path - path to your workspace, where all your terraform states will be stored, default is ~/.cubtera/workspace
  • module_path - path to your modules, where all your terraform modules will be stored, default is ~/.cubtera/workspace/modules. This modules folder will be symlinked to every terraform unit folder, so you can use modules in your units without any additional configuration, just install them in this folder, and they will be available in every unit by path ./modules
  • plugin_path - path to your plugins, where all your terraform plugins will be stored, default is ~/.cubtera/workspace/plugins. This plugins folder will be symlinked to every terraform unit folder, so you can use plugins in your units without any additional configuration, just install them in this folder, and they will be available in every unit by path ./plugins
  • inventory_path - path to your inventory, where all your terraform inventory will be stored, default is ~/.cubtera/workspace/inventory. This should contain all your terraform units, which will be used in your infrastructure. Every unit should be placed in separate folder, and should contain main.tf file with terraform code, and unit_manifest.json file with unit configuration.
  • temp_folder_path - path to your temp files, where all your terraform temp files will be stored, default is ~/.cubtera/temp

  Path could be set as absolute or relative to your current working directory, if you want to use relative path, you should start it with ./.

Dimension’s relations parameters

  • dim_relations - configure relations between base dimensions, default is dome:env:dc. String, with every dim_types separated by :. Elders first. For example, [dome:env:dc] means that domedimension is a parent of env, as well as env is a parent of dc.

  This relation’s definition will be used to provide a right variables set for a unit, depending on a used dimension. If unit uses dc dimension as a main, it will get all variables from dc dimension, and all variables from parent dimension of env type, and all variables from parent dimension of dome type.

  Dimension parent should be also defined in dc dimension .json file, for example, if you want to use env dimension as a parent for dc dimension, you should define which exactly env dimension is parent:

// inventory/dc/staging1-us-e2.json | dc:staging1-us-e2 dimension
{
...
"parent": "env:staging1",
...
}

  more about dimension’s json definition you can read here

Development parameters

  • clean_cache - cleaning cash after successful apply toggle, default is false.
  • always_copy_files - unit files copying to cache folder for every command, default is false. If enabled, all unit files will be copied to cache folder before every command, if disabled, files will be copied only for init command.

Deployment log parameters

  • dlog_db - configures mongo database connection string, if not set, deployment log will be disabled
  • dlog_job_user_name_env - configures environment variable name, which will be used to store job user name, if not set, will be used local host user name
  • dlog_job_number_env - configures environment variable name, which will be used to store job number, if not set, will be set to 0
  • dlog_job_name_env - configures environment variable name, which will be used to store job name, if not set, will be set to local

Overrides with env variables

  Cubtera can be configured using environment variables, which override configuration file parameters. All environment variables should:

  • Start with the CUBTERA_ prefix
  • Be in uppercase

  For example, to override the workspace_path parameter, set the environment variable CUBTERA_WORKSPACE_PATH.

  Additional configuration options:

  • To use a custom configuration file, set the CUBTERA_CONFIG environment variable.
  • In a multi-organization setup, switch organizations by setting the CUBTERA_ORG environment variable. This will be used to find your organization-related config parameters, units, and dimensions in the inventory.