Skip to content

BaseResource

laktory.models.resources.BaseResource ¤

Parent class for all Laktory models deployable as one or multiple cloud core resources. This BaseResource class is derived from pydantic.BaseModel.

PARAMETER DESCRIPTION
lookup_existing

Lookup resource instead of creating a new one.

TYPE: ResourceLookup | VariableType DEFAULT: None

resource_options

Deployed resource options (name, provider, enabled flag, dependencies, etc.).

TYPE: ResourceOptions | VariableType DEFAULT: ResourceOptions(variables={}, name=None, is_enabled=True, depends_on=[], provider=None, ignore_changes=None, import_=None, moved_from=None)

METHOD DESCRIPTION
resource_options_compat

Backward compatibility for options field.

ATTRIBUTE DESCRIPTION
core_resources

List of core resources to be deployed with this laktory model:

resource_key

Resource key used to build default resource name. Equivalent to

TYPE: str

resource_type_id

Resource type id used to build default resource name. Equivalent to

TYPE: str

self_as_core_resources

Flag set to True if self must be included in core resources

core_resources property ¤

List of core resources to be deployed with this laktory model: - class instance (self)

resource_key property ¤

Resource key used to build default resource name. Equivalent to name properties if available. Otherwise, empty string.

resource_type_id property ¤

Resource type id used to build default resource name. Equivalent to class name converted to kebab case. e.g.: SecretScope -> secret-scope

self_as_core_resources property ¤

Flag set to True if self must be included in core resources

resource_options_compat(data) classmethod ¤

Backward compatibility for options field.

Source code in laktory/models/resources/baseresource.py
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
@model_validator(mode="before")
@classmethod
def resource_options_compat(cls, data: Any) -> Any:
    """Backward compatibility for `options` field."""
    if not isinstance(data, dict):
        return data

    # options → resource_options (only when no native Terraform "options" field exists)
    if "options" in data and "resource_options" not in data:
        if "options" not in cls.model_fields:
            warnings.warn(
                "Field `options` is deprecated and will be removed in the next major version. "
                "Use `resource_options` instead.",
                DeprecationWarning,
                stacklevel=2,
            )
            data["resource_options"] = data.pop("options")

    return data

laktory.models.resources.baseresource.ResourceOptions ¤

Bases: BaseModel

Resource options for deployment.

PARAMETER DESCRIPTION
depends_on

Explicit list of resource dependencies.

TYPE: list[str | VariableType] | VariableType DEFAULT: []

ignore_changes

Declare that changes to certain properties should be ignored during a diff.

TYPE: list[str | VariableType] | VariableType DEFAULT: None

import_

Bring an existing cloud resource into Laktory management.

TYPE: str | VariableType DEFAULT: None

is_enabled

If False, resource is not passed to the IaC backend and is not deployed. May be used for deploying resources to specific stack environments only or for disabling resources when debugging.

TYPE: bool | VariableType DEFAULT: True

moved_from

Declare that a resource was moved from another address.

TYPE: str | VariableType DEFAULT: None

name

Name of the resource in the context of infrastructure as code. If None, a default name is derived from the resource type and key.

TYPE: str | VariableType DEFAULT: None

provider

Explicit declaration of resource provider.

TYPE: str | VariableType DEFAULT: None


laktory.models.resources.baseresource.ResourceLookup ¤

Bases: BaseModel