Terraform Context
What
Display the currently active Terraform Workspace name.
Sample Configuration
- json
- yaml
- toml
Options
| Name | Type | Default | Description |
|---|---|---|---|
fetch_version | boolean | false | fetch the version information, see Version detection for the sources and their priority |
command | string | terraform | the command(s) to run, allows support for tofu |
Version detection
When fetch_version is enabled, the version is resolved from the first source
that yields a value, in this order:
- the tenv environment variable —
TFENV_TERRAFORM_VERSION(orTOFUENV_TOFU_VERSIONwhencommandistofu) - the tenv version file —
.terraform-version(or.opentofu-versionwhencommandistofu) - the
required_versiondeclared inversions.tformain.tf - the
terraform_versionstored interraform.tfstate
The tenv sources let the segment show the pinned version even when you don't use
main.tf / versions.tf. The environment variable and version file are only
used to read the version; a project file (a .terraform folder or one of the
files above) is still required for the segment to activate.
Template (info)
default template
{{ .WorkspaceName }}{{ if .Version }} {{ .Version }}{{ end }}
Properties
| Name | Type | Description |
|---|---|---|
.WorkspaceName | string | is the current workspace name |
.Version | string | terraform version (set fetch_version to true) |