Importing preserves existing resources and maps them into Terraform state, which is useful when legacy environments already exist in production. Rebuilding creates a cleaner design but usually requires more downtime, change control, and validation. The right choice depends on stability requirements, risk tolerance, and how much technical debt the current environment already carries.
Why This Matters for Security Teams
Choosing between importing resources into Terraform and rebuilding them from scratch is not just a tooling preference. It determines whether security teams inherit existing drift, hidden permissions, and undocumented dependencies, or whether they pay the cost of recreating a cleaner baseline with controlled cutover. In cloud environments, those tradeoffs directly affect incident risk, auditability, and rollback speed.
Import is often the safer first step when production already exists, but it can also freeze bad design into code if teams do not inspect what they are adopting. Rebuild can improve naming, tagging, policy alignment, and least-privilege structure, yet it exposes gaps in change control and application dependency mapping. The practical question is whether the environment is stable enough to absorb reconstruction without creating a second failure mode.
NHIMG research shows how quickly weak identity and access hygiene becomes operational debt: in the 2024 Non-Human Identity Security Report, 88.5% of organisations said their non-human IAM practices lag behind or merely match human IAM efforts. In practice, many teams discover the true shape of that debt only after a migration or rebuild has already started, rather than during an intentional design review.
How It Works in Practice
Importing means Terraform records an existing resource in state so it can manage future changes. The resource already exists in the provider, and the import step tells Terraform, “this object belongs here.” That makes import useful for legacy environments, brownfield cloud estates, and anything that cannot tolerate immediate recreation. It also means the team must reconcile the live resource with the code that describes it, because import does not automatically produce a clean or complete configuration.
Rebuilding from scratch means creating a new resource set from Terraform code, then switching traffic, data, or dependencies over once validation is complete. This is usually better when the current environment is inconsistent, over-permissioned, or too far from the desired architecture to justify preserving. It is also the better option when you need a clean security baseline, because import preserves what exists, including design flaws.
- Import when the resource is stateful, already in use, and risky to recreate immediately.
- Rebuild when the resource is disposable, easy to validate, or materially misconfigured.
- Always document drift before importing so code reflects reality, not assumptions.
- Use rebuilds to remove inherited secrets sprawl, weak defaults, and inconsistent naming.
For cloud identity and secret handling, this distinction matters because imported infrastructure can hide risky access paths that Terraform state will not expose on its own. NHIMG case research such as the Azure Key Vault privilege escalation exposure and the Snowflake breach show how secrets and access overreach often persist longer than teams expect when systems are left in place without a hard redesign. Current guidance suggests using import for continuity and rebuild for remediation, but there is no universal standard for when a brownfield system has crossed the line from “manageable drift” to “safer to replace.” These controls tend to break down when dependencies are undocumented, because the team cannot validate cutover impact before the old environment is retired.
Common Variations and Edge Cases
Tighter rebuild plans often increase downtime, testing overhead, and change-control burden, requiring organisations to balance cleaner architecture against operational continuity. That tradeoff becomes sharper in multi-account, multi-region, or regulated environments where even a small misstep can affect production access or compliance evidence.
One common edge case is partial import followed by selective refactoring. Teams may import only the resources that are too risky to recreate, then rebuild surrounding components incrementally. That can work well, but it demands discipline: if the imported objects are left unmanaged, they become permanent exceptions. Another edge case is using import to “bootstrap” Terraform on top of a live environment, then treating the result as finished. That is usually where technical debt gets codified instead of reduced.
For agentic or highly automated infrastructure workflows, this choice also affects governance. If autonomous tooling is making changes, the safer pattern is to keep changes small, reversible, and explicitly reviewed rather than attempting a broad rebuild in one move. For a broader view of identity debt in cloud estates, the 230 million AWS environment compromise is a reminder that scale amplifies the cost of hidden misconfiguration. Best practice is evolving, but the consistent rule is simple: import preserves reality, rebuild enforces intent.
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 and CSA MAESTRO address the attack and risk surface, while NIST CSF 2.0, NIST Zero Trust (SP 800-207) and NIST AI RMF set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP Non-Human Identity Top 10 | NHI-01 | Importing live cloud resources can preserve hidden NHI drift and excess privilege. |
| NIST CSF 2.0 | PR.AC-4 | Terraform migration choices directly affect least-privilege and access governance. |
| NIST Zero Trust (SP 800-207) | SC-7 | Rebuild decisions should reduce trust in legacy paths and implicit network access. |
| NIST AI RMF | Automation and refactoring decisions need governed risk assessment and accountability. | |
| CSA MAESTRO | Cloud automation must account for stateful dependencies and change safety. |
Inventory imported resources, validate state against reality, and remove unmanaged identity exposure.
Related resources from NHI Mgmt Group
- What is the difference between importing EKS resources into Terraform and reprovisioning them?
- What is the difference between hardware-based key storage and cloud-scale key management?
- What is the difference between runtime privileged access and traditional PAM in cloud environments?
- What is the difference between aligning Terraform code and reconciling production state?
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