Skip to content

EnvVar

EnvVar storage providers allows to read environment variables and pass them around to consumer - like a transformer.

Notice

This storage provider can not be used to manage terraform state files.

Tip

This provider was mainly developed to serve encryption providers - like age.

Initialization

EnvVarStorageProviderInitConfig

Initialization params required to initialize EnvVar storage provider.

EnvVar storage provider currently have no initialization params required.

Source code in terraflex/plugins/envvar_storage_provider/envvar_storage_provider.py
28
29
30
31
32
class EnvVarStorageProviderInitConfig(BaseModel):
    """Initialization params required to initialize EnvVar storage provider.

    EnvVar storage provider currently have no initialization params required.
    """

ItemKey

EnvVarStorageProviderItemIdentifier

Bases: ItemKey

Params required to reference an item in EnvVar storage provider.

Attributes:

Name Type Description
key str

The name of the environment variable to read.

Source code in terraflex/plugins/envvar_storage_provider/envvar_storage_provider.py
14
15
16
17
18
19
20
21
22
23
24
25
class EnvVarStorageProviderItemIdentifier(ItemKey):
    """Params required to reference an item in EnvVar storage provider.

    Attributes:
        key: The name of the environment variable to read.
    """

    key: str

    @override
    def as_string(self) -> str:
        return self.key

Example

terraflex.yaml
storage_providers:
  git-storage: # Initialize new storage provider - name can be anything
    type: git # In this case we use `git` storage provider
    origin_url: git@github.com:IamShobe/tf-state.git

  envvar-example: # Initialize new storage provider - name can be anything
    type: envvar # In this case we use `envvar` storage provider

transformers:
  encryption: # Initialize new transformer - Name can be anything, we use `encryption` for semantics.
    type: encryption # In this case we use `encryption` transformer
    key_type: age # We use `age` as the encryption provider
    import_from_storage:
      provider: envvar-example # Make sure name is matching your storage provider
      params:
        key: AGE_KEY # The environment variable name to use for the encryption key

stacks:
  my-stack: # Initialize new stack - Name can be anything
    transformers: # List of transformers to use in this specific stack
      - encryption # Make sure name is matching your transformer
    state_storage: # Terraform state storage configuration
      provider: git-storage # In this case we use our git storage provider
      params:
        path: terraform.tfstate # The path to the state file inside our repository