dlab_deployment.infrastructure.terraform

Module Contents

BASE_COMMAND = terraform[source]
INIT_COMMAND[source]
VALIDATE_COMMAND[source]
OUTPUT_COMMAND[source]
APPLY_COMMAND[source]
DESTROY_COMMAND[source]
LC_ERR_TF_PROVISIONING_ERROR_TEMPLATE = Exception raised while {}[source]
TF_INIT_SUCCESS_MSG = Terraform has been successfully initialized![source]
TF_VALIDATE_SUCCESS_MSG = Success![source]
ACTIONS = actions[source]
TF_PARAMETER = tf_param[source]
INITIAL_TYPE = initial_type[source]
INITIAL_VALUE = initial_value[source]
ACTION_APPLY = 1[source]
ACTION_DESTROY = 2[source]
ACTION_OUTPUT = 4[source]
COMMANDS_ACTION_CODES[source]
generate_tf_vars(variables)[source]
TERRAFORM_PARAMS[source]
exception TerraformException[source]

Bases: dlab_core.domain.exceptions.DLabException

validate_tf_result(check_phrase, error_msg)[source]
Parameters:
  • check_phrase (str) – String that should be included to output
  • error_msg (str) – Error message string
Returns:

fn execution

:raise TerraformException if check phrase not in execution result

class Terraform(command_executor, **kwargs)[source]

Bases: object

command_executor[source]

:rtype BaseCommandExecutor :return: CLI executor

initialize(self)[source]

Initialize terraform :raise TerraformException: if initialization was not succeed

validate(self)[source]

Validate terraform

Raises:TerraformException – if validation status was not succeed
apply(self)[source]

Apply terraform

destroy(self)[source]

Destroy terraform

output(self)[source]

Extract terraform output

build_tf_command(self, command)[source]

Build terraform options string Iterate through available tf options. Get terraform presentations of each parameter if value is not false and terraform parameter suits to selected action type

static set_tf_parameter(arg, expected)[source]
Parameters:
  • arg – terraform argument
  • expected – dict with corresponding default value and expected

type :return: default or actual value if passed :raise: DLabException if type doesn’t match to expected