# 使用 Homebrew, MacPorts, Nix 安装 tfmigrate

查看 tfmigrate 的安装路径、可执行文件、元数据以及面向 AI 代理工作流的安全说明。

## 安装

```sh
sudo av install brew:tfmigrate
```

其他安装命令:

### macOS

- Homebrew (100%):

```sh
brew install tfmigrate
```

  证据: local Homebrew formula metadata

- MacPorts (94%):

```sh
sudo port install tfmigrate
```

  证据: MacPorts ports tree: sysutils/tfmigrate/Portfile from https://api.github.com/repos/macports/macports-ports/git/trees/master?recursive=1

### Linux

- Nix (92%):

```sh
nix profile install nixpkgs#tfmigrate
```

  证据: nixpkgs package indexes: pkgs/by-name/tf/tfmigrate/package.nix from https://api.github.com/repos/NixOS/nixpkgs/git/trees/master?recursive=1

## 软件包事实

- **软件包键:** brew:tfmigrate
- **软件包管理器:** Homebrew
- **版本:** 0.4.5
- **来源摘要:** Terraform/OpenTofu state migration tool for GitOps
- **主页:** <https://github.com/minamijoyo/tfmigrate>
- **仓库:** <https://github.com/minamijoyo/tfmigrate>
- **最后更新:** 2026-07-26T00:50:39+02:00
- **已生成:** 2026-08-03T19:37:03+00:00

## 可执行文件

- tfmigrate (别名)

## 安装行为

- Bottle: 不可用

## 版本和新鲜度

- 页面生成时间: 2026-08-03
- 管理器版本: 0.4.5
## 项目历史与用法

tfmigrate is a Terraform and OpenTofu state migration tool for GitOps. Its README frames Terraform state operations as code: write state moves, removals, imports, and related operations in HCL, review them in git, then plan and apply them in sequence.

### 项目历史

The project was created to address a common production Terraform problem: state manipulations are unavoidable during refactoring, but raw `terraform state` commands are error-prone and do not fit well into pull-request and CI/CD workflows. tfmigrate's README explicitly argues that state operations should be committed to git.

The tool wraps Terraform or OpenTofu under the hood rather than reimplementing their state mechanics. It supports dry-run planning with temporary local state, migration history, local/S3/GCS storage for applied migration records, monorepo-style state splits and merges, and migration files written as HCL.

Recent release notes show continuing maintenance for the changing Terraform ecosystem, including support for OpenTofu versions, Terraform 1.11 through 1.15, Terragrunt CLI redesign handling, configurable environment injection into `.tfmigrate.hcl`, and GitHub Actions and Go toolchain updates.

### 采用历史

The repository shows more than a thousand GitHub stars and is packaged by Homebrew, MacPorts, and Nix in the input metadata. That adoption profile fits a tool used by infrastructure teams with long-lived Terraform states and CI-based review.

tfmigrate's appeal is strongest for teams that already use GitOps: it lets state migrations travel with the configuration change they support, instead of being performed manually before or after a merge.

### 使用方式

The documented workflow is to write a migration file such as `state_mv.hcl`, run `tfmigrate plan` to verify the state operation against Terraform plan output without updating remote state, and then run `tfmigrate apply` to push the migrated state when the plan is clean.

tfmigrate can invoke `terraform`, `tofu`, or Terragrunt via `TFMIGRATE_EXEC_PATH`, and the README recommends trying the included sandbox before using the tool on production state.

### 为什么软件包爱好者会关心

tfmigrate is important in package metadata because it solves a lifecycle problem that plain Terraform intentionally leaves low-level. It turns one-off state surgery into reviewable, repeatable migration files.

As a package-manager tool, it is most useful when installed in CI images and developer machines beside Terraform/OpenTofu, making the same state migration command available during local rehearsal and automated review.

### 时间线

- 2025: v0.4.2 release notes add OpenTofu 1.9, Terraform 1.11, Terragrunt CLI redesign handling, and environment injection into `.tfmigrate.hcl`.
- 2025: v0.4.3 release notes add OpenTofu 1.10 and Terraform 1.12 support.
- 2025: v0.4.4 release notes add OpenTofu 1.11 and Terraform 1.14 support.
- 2026: v0.4.5 is listed as the latest release and includes Terraform 1.15 support.

### Related projects

- Terraform and OpenTofu are the execution engines tfmigrate invokes.
- Terragrunt is supported through `TFMIGRATE_EXEC_PATH` with version-specific guidance.
- Digger is mentioned in recent release notes as an integration example.

### 来源

- <https://github.com/minamijoyo/tfmigrate>
- <https://github.com/minamijoyo/tfmigrate/releases>
- source_facts.package-manager


## 安全说明

narrow executable package without higher-risk signals.

- **Geiger 风险:** 绿色 / 低
- narrow executable package without higher-risk signals


## Configuration and credential file locations

These source-backed paths show where this package keeps local settings or durable credentials. Automic Vault can use them as review targets for secret scanning, migration, and command approval.


## Configuration files

- Unix: .tfmigrate.hcl
## 其他软件包管理器记录

- Nix - tfmigrate: normalized package name match | nixpkgs package indexes: pkgs/by-name/tf/tfmigrate/package.nix from https://api.github.com/repos/NixOS/nixpkgs/git/trees/master?recursive=1
- MacPorts - tfmigrate: normalized package name match | MacPorts ports tree: sysutils/tfmigrate/Portfile from https://api.github.com/repos/macports/macports-ports/git/trees/master?recursive=1


## Combined YAML source

View the package source record on GitHub. [combined/tfmigrate.yml](https://github.com/mxcl/pkgdb/blob/main/combined/tfmigrate.yml)


## 来源

- pkg.so package database
- Geiger risk classifier
- curated configuration and credential file locations
- curated package history
- pkgdb category and tag curation
- external package-manager database matches
- cross-ecosystem install command graph
