tfenv
$ tfenv 社区开源 低风险tfenv 通过垫片(shim)与 .terraform-version 文件管理多个 Terraform 版本,可在本地或 CI 中自动下载、校验并切换版本;但仅支持纯文本输出,且仅管理 Terraform。
brew install tfenv 本地 Shell 垫片与版本切换工具;MCP 服务端无法管理 $PATH 垫片。
Agent 友好度体检单
当前为静态评估(本机尚未安装或尚未运行探针)。可在本地运行 npm run data:probe 并提交 data/probes/ 升级为实测证据。
FCRS-1.0 六维评分拆解
可通过 .terraform-version 与 TFENV_AUTO_INSTALL=true 非交互运行,但缺少 --json 输出,依赖 Bash 文本格式。
- Non-interactive install/use from
.terraform-version - No
--jsonoutput flag; plain-text line output only
存在 gpg 时可校验签名与哈希,且仅写入 ~/.tfenv 本地垫片目录,不触碰云资源。
- Local binary management only; no cloud infrastructure mutations
基于 Bash 实现,在 macOS 与 Linux 上开箱即用,但 Windows 需依赖 WSL 或 Git Bash。
- Requires Bash environment; macOS and Linux primary targets
Terraform 版本锁定稳定可靠,但同时使用 OpenTofu/Terragrunt 的团队更常转向 tenv。
- Scoped strictly to Terraform binaries
成熟的社区项目(tfutils/tfenv),MIT 协议,近年迭代节奏趋缓。
- Community repo
tfutils/tfenvunder MIT
单页 README 清晰记录了全部子命令、.terraform-version 与 TFENV_* 环境变量。
- README documents all subcommands and
TFENV_*env vars
安全边界、鉴权与放权指南
无需账号认证;下载公开 HashiCorp 发行版,可选读取 TFENV_NETRC_PATH 或代理环境变量。
MIT 开源免费;从 HashiCorp 官方仓库下载二进制。
# tfenv Agent Rules - Run `tfenv version-name` before `terraform` commands to confirm the active binary version. - Prefer `tfenv install` with `.terraform-version` rather than `tfenv install latest`. - Do not run `tfenv uninstall` without checking if other repos share that version.
Agent 高频安全命令配方
只读查询(安全推荐)
tfenv list
输出已安装的版本列表并标出当前激活版本。
tfenv version-name
解析 .terraform-version 或全局配置并打印当前选中的 Terraform 版本。
受控写入与预演
tfenv install && tfenv use
读取 .terraform-version 并以非交互方式安装和切换至指定版本。
核心优势
- + 配合
TFENV_AUTO_INSTALL=true可自动读取.terraform-version并切换版本。 - + 命令简洁直观(
tfenv list、tfenv install、tfenv use),无交互卡顿。 - + 支持对下载的二进制执行 PGP 签名校验。
注意事项与踩坑点
- ! 无 JSON 输出格式,Agent 需解析纯文本行。
- ! 基于 Bash 编写,原生不支持 Windows,且不支持 OpenTofu。