runway.env_mgr.tfenv module

Terraform version management.

runway.env_mgr.tfenv.download_tf_release(version: str, versions_dir: Path, command_suffix: str, tf_platform: Optional[str] = None, arch: Optional[str] = None)None[source]

Download Terraform archive and return path to it.

runway.env_mgr.tfenv.get_available_tf_versions(include_prerelease: bool = False)List[str][source]

Return available Terraform versions.

runway.env_mgr.tfenv.get_latest_tf_version(include_prerelease: bool = False)str[source]

Return latest Terraform version.

runway.env_mgr.tfenv.load_terraform_module(parser: ModuleType, path: Path)Dict[str, Any][source]

Load all Terraform files in a module into one dict.

  • parser (Union[hcl, hcl2]) – Parser to use when loading files.

  • path – Terraform module path. All Terraform files in the path will be loaded.

class runway.env_mgr.tfenv.VersionTuple(major: int, minor: int, patch: int, prerelease: Optional[str] = None, prerelease_number: Optional[int] = None)[source]

Bases: tuple

Terraform version tuple.


Major release version number.




Minor release version number.




Patch release version number.




Prerelease identifier (e.g. beta2).



Create new instance of VersionTuple(major, minor, patch, prerelease, prerelease_number)

major: int

Alias for field number 0

minor: int

Alias for field number 1

patch: int

Alias for field number 2

prerelease: Optional[str]

Alias for field number 3

prerelease_number: Optional[int]

Alias for field number 4


Format as string.

count(value, /)

Return number of occurrences of value.

index(value, start=0, stop=9223372036854775807, /)

Return first index of value.

Raises ValueError if the value is not present.

class runway.env_mgr.tfenv.TFEnvManager(path: Optional[Path] = None)[source]

Bases: runway.env_mgr.EnvManager

Terraform version management.

Designed to be compatible with

Initialize class.

property backend

Backend config of the Terraform module.

property terraform_block

Collect Terraform configuration blocks from a Terraform module.

property version

Terraform version.

property version_file

Find and return a “.terraform-version” file if one is present.


Path to the Terraform version file.


Get the defined minimum required version of Terraform.


The minimum required version as defined in the module.

get_version_from_file(file_path: Optional[Path] = None)Optional[str][source]

Get Terraform version from a file.


file_path – Path to file that will be read.

install(version_requested: Optional[str] = None)str[source]

Ensure Terraform is available.

list_installed()Generator[Path, None, None][source]

List installed versions of Terraform.

Only lists versions of Terraform that have been installed by an instance if this class or by tfenv.

set_version(version: str)None[source]

Set current version.

Clears cached values as needed.


version – Version string. Must be in the format of <major>.<minor>.<patch> with an optional -<prerelease>.

classmethod get_version_from_executable(bin_path: Union[Path, str], *, cwd: Optional[Union[Path, str]] = None, env: Optional[Dict[str, str]] = None)Optional[VersionTuple][source]

Get Terraform version from an executable.

  • bin_path – Path to the Terraform binary to retrieve the version from.

  • cwd – Current working directory to use when calling the executable.

  • env – Environment variable overrides.

classmethod parse_version_string(version: str)runway.env_mgr.tfenv.VersionTuple[source]

Parse version string into a VersionTuple.


version – Version string to parse. Must be in the format of <major>.<minor>.<patch> with an optional -<prerelease>.

property bin

Path to the version binary.



property command_suffix

Return command suffix based on platform.system.

property env_dir

Return the directory used to store version binaries.

uninstall(version: Union[str, Tuple[typing.Any, ]])bool

Uninstall a version of the managed binary.


version – Version of binary to uninstall.


Whether a version of the binary was uninstalled or not.

property versions_dir

Return the directory used to store binary.

When first used, the existence of the directory is checked and it is created if needed.