Skip to content

terraflex.yaml

terraflex.yaml is the main config file terraflex looks at.
This file must be at the root of where terraflex is being run at.

Tip

Checkout the examples section at Getting Started tab.

Models

ConfigFile

The configuration file for terraflex.

Attributes:

Name Type Description
version str

The version of the configuration file.

storage_providers dict[str, StorageProviderConfig]

The configuration for the storage providers.

transformers dict[str, TransformerConfig]

The configuration for the transformers.

stacks dict[str, StackConfig]

The configuration for the stacks.

Source code in terraflex/server/config.py
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
class ConfigFile(BaseModel):
    """The configuration file for terraflex.

    Attributes:
        version: The version of the configuration file.
        storage_providers: The configuration for the storage providers.
        transformers: The configuration for the transformers.
        stacks: The configuration for the stacks.
    """

    version: str = CONFIG_VERSION
    storage_providers: dict[str, StorageProviderConfig]
    transformers: dict[str, TransformerConfig]
    stacks: dict[str, StackConfig]

    @field_validator("version")
    @classmethod
    def validate_version(cls, value: str) -> str:
        current_version = semver.Version.parse(value, optional_minor_and_patch=True)
        config_version = semver.Version.parse(CONFIG_VERSION, optional_minor_and_patch=True)
        if current_version < config_version:
            raise ValueError(
                f"Unsupported version ({current_version} < {config_version}) - please upgrade the config file"
            )

        if current_version > config_version:
            raise ValueError(
                f"Unsupported version ({current_version} > {config_version}) - please check if there is a newer version of {PACKAGE_NAME}"
            )

        return value

StackConfig

Configuration for a terraform stack.

Attributes:

Name Type Description
state_storage StorageProviderUsageConfig

The storage provider configuration for the state file.

transformers list[str]

The list of transformers to apply to the data.

Source code in terraflex/server/config.py
85
86
87
88
89
90
91
92
93
94
class StackConfig(BaseModel):
    """Configuration for a terraform stack.

    Attributes:
        state_storage: The storage provider configuration for the state file.
        transformers: The list of transformers to apply to the data.
    """

    state_storage: StorageProviderUsageConfig
    transformers: list[str]

TransformerConfig

Base Transformer configuration.

Each transformer defines it's own unique configuration parameters - and the parameters will be passed through to the transformer.

Attributes:

Name Type Description
type str

The type of the transformer.

**kwargs str

Additional configuration for the transformer.

Source code in terraflex/server/config.py
70
71
72
73
74
75
76
77
78
79
80
81
82
class TransformerConfig(BaseModel):
    """Base Transformer configuration.

    Each transformer defines it's own unique configuration parameters -
    and the parameters will be passed through to the transformer.

    Attributes:
        type: The type of the transformer.
        **kwargs: Additional configuration for the transformer.
    """

    model_config = ConfigDict(extra="allow")
    type: str

StorageProviderConfig

Data struct that contains the configuration for a storage provider.

Each storage provider defines it's own unique configuration parameters - and the parameters will be passed through to the storage provider.

Attributes:

Name Type Description
type str

storage provider type as declared in the entrypoint.

**kwargs str

storage provider specific configuration parameters.

Example

In this example, the local storage provider has a folder parameter that is required. The storage provider will get a dict: {"folder": "/path/to/folder"} as the configuration.

type: local
folder: /path/to/folder
Source code in terraflex/server/config.py
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
class StorageProviderConfig(BaseModel):
    """Data struct that contains the configuration for a storage provider.

    Each storage provider defines it's own unique configuration parameters -
    and the parameters will be passed through to the storage provider.

    Attributes:
        type: storage provider type as declared in the entrypoint.
        **kwargs: storage provider specific configuration parameters.

    Example:
        In this example, the `local` storage provider has a `folder` parameter that is required.
        The storage provider will get a dict: `{"folder": "/path/to/folder"}` as the configuration.

        ```yaml
        type: local
        folder: /path/to/folder
        ```
    """

    model_config = ConfigDict(extra="allow")
    type: str

StorageProviderUsageConfig

Data struct that contains the parameters that link to a specific file in a given storage provider.

Each storage provider defines it's own unique usage parameters.

Please refer to your storage provider usage config for key specification.

Attributes:

Name Type Description
provider str

storage provider name defined in storage_providers section of the config file.

params Optional[dict[str, Any]]

storage provider specific usage parameters - each storage provider defines it's own params - and this dict will be processed and validated dynamically by each storage provider.

Example

This is an example of a local storage provider usage config:

provider: local
params:
    path: ./path/to/item.txt

Source code in terraflex/server/config.py
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
class StorageProviderUsageConfig(BaseModel):
    """Data struct that contains the parameters that link to a specific file in a given storage provider.

    Each storage provider defines it's own unique usage parameters.

    Please refer to your storage provider usage config for key specification.

    Attributes:
        provider: storage provider name defined in `storage_providers` section of the config file.
        params: storage provider specific usage parameters - each storage provider defines it's own params -
            and this dict will be processed and validated dynamically by each storage provider.

    Example:
        This is an example of a `local` storage provider usage config:
        ```yaml
        provider: local
        params:
            path: ./path/to/item.txt
        ```
    """

    provider: str
    params: Optional[dict[str, Any]] = None