Terraform Generator#

class besser.generators.terraform.terraform_generator.TerraformGenerator(deployment_model: DeploymentModel, output_dir: str = None)[source]#

Bases: GeneratorInterface

TerraformGenerator is a class that implements the GeneratorInterface and is responsible for generating the Terraform models code based on the input B-UML model. :param deployement_model: The deployment model containing multiple public clusters. :type deployement_model: DeployementModel :param output_dir: The output directory where the generated code will be saved. Defaults to None. :type output_dir: str, optional

_abc_impl = <_abc._abc_data object>#
static convert_type(value)[source]#

Converts the input value to its underlying value if it is an instance of an enum class, otherwise converts it to a string. :param value: The value to convert, which can be of any type including enum instances.

Returns:

The underlying value if an enum instance, or the string representation of the value.

generate()[source]#

Generates Terraform code based on the provided B-UML model and saves it to the specified output directory. If the output directory is not specified, the generated code will be stored in the <current directory>/output folder.

Returns:

None, but stores the generated code as files with specified names.

static get_class_name(value)[source]#

Custom filter to get the class name of an object.

static get_template_to_file_map(provider)[source]#

Returns the template to file map based on the provider.

Parameters:

provider (str) – The cloud provider (e.g., ‘Google’, ‘AWS’).

Returns:

Mapping of template file names to output file names.

Return type:

dict

static set_dict_item(dictionary, key, value)[source]#
setup_environment()[source]#

Sets up the Jinja2 environment and adds custom filters.