Automation makes the most sense when the estate is large, the codebase is fragmented, or multiple teams own different stacks. Manual migration may work for a few workloads, but it does not scale well. Teams should automate assessment, compatibility checks, and code fixes when the cost of human review outweighs the risk of controlled automation.
Why This Matters for Security Teams
OpenTofu migration decisions are not just delivery choices, they are control decisions. A manual approach can be acceptable for a small number of tightly owned modules, but it becomes risky when Terraform estates are sprawling, inconsistent, or tied to shared CI/CD paths. The real issue is not whether code can be edited by hand, but whether the migration process can preserve state integrity, provider compatibility, and change traceability without introducing drift.
Security teams should also treat migration tooling as part of the attack surface. Scripts that rewrite configuration, update providers, or move state can expose secrets, widen permissions, or mis-handle backend credentials if they are not validated carefully. NHI Management Group’s research shows how often organizations struggle with this broader identity problem: only 5.7% of organisations have full visibility into their service accounts, according to Ultimate Guide to NHIs — The NHI Market. In practice, many teams discover migration risk only after provider drift or credential exposure has already slowed the release.
How It Works in Practice
The decision usually comes down to scope, repetition, and blast radius. Manual migration works best when a small set of stacks is well understood, modules are versioned cleanly, and platform owners can verify each change before it reaches production. Automation becomes more attractive when the estate contains repeated patterns, many repositories, or multiple teams with inconsistent IaC conventions. In that setting, the goal is to automate the predictable parts and leave humans to review exceptions.
A practical automation path usually includes:
- Inventory and classify modules, providers, and backends before any rewrite starts.
- Run compatibility checks against OpenTofu-supported versions and provider constraints.
- Detect syntax changes, deprecated arguments, and state migration requirements automatically.
- Use policy gates to block changes that touch sensitive resources, secrets, or privileged backends.
- Require human review for modules with custom providers, unusual dependencies, or unmanaged drift.
That operating model aligns with NIST guidance on control discipline and traceability in NIST SP 800-53 Rev. 5 Security and Privacy Controls, especially where change control, least privilege, and system integrity matter. It also fits the same pattern seen in credential exposure research such as Code Formatting Tools Credential Leaks, where automation only helps if it is constrained by guardrails and reviewable outputs. The best practice is to automate assessment, compatibility checks, and code fixes, then route anything that changes state, secrets handling, or cross-team ownership through an explicit approval path. These controls tend to break down when migrations depend on bespoke module logic or hand-maintained state files because the tool cannot safely infer intent.
Common Variations and Edge Cases
Tighter automation often increases coordination overhead, so organisations have to balance speed against confidence. There is no universal standard for when a migration must be manual, but current guidance suggests treating these cases as higher risk: heavily customised modules, mixed provider versions, embedded secrets, remote state with unclear ownership, and environments where the same stack is managed by several teams.
Some teams also underestimate the operational cost of partial automation. If assessment is automated but fixes are applied manually, bottlenecks move rather than disappear. If code rewriting is automated but state validation is not, the migration may complete quickly while leaving hidden inconsistencies behind. This is where platform and security teams should agree on a threshold model: automate when the same pattern repeats often enough that human review becomes routine, but keep manual control when the change could affect blast radius, access boundaries, or rollback reliability. NHIMG’s broader research on exposed credentials and limited visibility in Ultimate Guide to NHIs — The NHI Market reinforces that hidden dependencies are usually what make “simple” migrations fail. In practice, the hardest OpenTofu conversions are rarely the largest ones, but the ones with the least reliable inventory and the most undocumented exceptions.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
OWASP Non-Human Identity Top 10 address the attack and risk surface, while NIST CSF 2.0, NIST SP 800-63, NIST AI RMF and NIST Zero Trust (SP 800-207) set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP Non-Human Identity Top 10 | NHI-01 | Migration tooling often handles secrets and service account access during conversion. |
| NIST CSF 2.0 | PR.IP-3 | Automated migrations need controlled change management and documented procedures. |
| NIST SP 800-63 | Workload and operator identity assurance matters when automation touches sensitive infrastructure. | |
| NIST AI RMF | GOVERN | Decision criteria for automation should be governed, repeatable, and accountable. |
| NIST Zero Trust (SP 800-207) | PR.AC-4 | Migration jobs should receive only the access needed for each task. |
Inventory and protect all non-human identities involved in migration before automating any code rewrite.
Related resources from NHI Mgmt Group
- How should security teams decide whether to build authorization logic inside applications or externalize it to a centralized policy layer?
- Who should be accountable for workload identity security across platform, identity, and security teams?
- How do security teams decide whether to prioritise NHI governance, workload identity protection, or identity threat detection first?
- How should security teams automate authorization policy deployments in CI/CD pipelines?
Deepen Your Knowledge
Reviewed and updated by the NHIMG editorial team on August 28, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org