A common mistake is assuming import alone creates clean infrastructure-as-code. In practice, imported resources often need refactoring, variable extraction, and dependency cleanup before they are maintainable. Teams also underestimate the effort required to align live cloud state with desired state, which can leave hidden drift and inconsistent module boundaries.
Why This Matters for Security Teams
Importing cloud resources into Terraform is often treated like a documentation exercise, but the security impact is larger: import can expose unmanaged drift, stale permissions, and hidden dependencies that were never encoded as code. If the imported state is accepted as-is, teams can preserve insecure defaults while gaining only the appearance of control. NIST’s NIST Cybersecurity Framework 2.0 emphasizes asset visibility and governance, which is exactly where naive import workflows fail.
The same pattern shows up in NHIMG research on the 230M AWS environment compromise and the Snowflake breach, where identity, exposure, and weak operational hygiene mattered more than whether a resource existed in code. Imported infrastructure is only trustworthy if the team can prove that its live configuration, identity bindings, and dependencies match intended control boundaries. In practice, many security teams discover the real risk only after a rushed import has already been promoted into a shared module without review.
How It Works in Practice
A safe import workflow starts by separating three problems: state capture, code normalization, and security validation. Terraform import can map a live cloud resource into state, but it does not infer clean module design, variable boundaries, or least-privilege relationships. The imported resource must still be reviewed for configuration drift, secret references, attached policies, network exposure, and hidden links to other resources.
For security and platform teams, the practical sequence is usually:
- Import the resource into state, then immediately inspect the full diff against the desired design.
- Extract hard-coded values into variables or data sources so the module can be reused safely.
- Check dependencies such as IAM roles, security groups, KMS keys, and DNS records that may not be obvious in the import.
- Validate that the imported object does not inherit over-permissive access or legacy exceptions.
- Run policy checks before merging, not after deployment, so drift is caught while it is still cheap to fix.
This matters because imported infrastructure often carries the same identity problems seen in broader NHI failures. NHIMG has documented how exposed credentials and mis-scoped access can turn routine cloud changes into major incidents, including the Codefinger AWS S3 ransomware attack and Azure Key Vault privilege escalation exposure. For controls, teams should combine Terraform review with runtime governance and identity checks, using guidance from NIST CSF 2.0 and the NHIMG Ultimate Guide to NHIs to keep state, access, and ownership aligned.
These controls tend to break down when imports are done at scale across accounts, because teams stop reconciling each resource against its original design intent and begin accepting drift as normal.
Common Variations and Edge Cases
Tighter import controls often increase delivery overhead, requiring organisations to balance speed against the cost of cleaning up legacy infrastructure before it becomes shared code. That tradeoff is real, especially in brownfield environments where hundreds of resources were created manually, by different teams, or by older pipelines.
Current guidance suggests treating some imports as temporary bridging work, not immediate module standardisation. For example, a production database or object store may be imported first for visibility, then refactored later into a maintainable module after ownership, backup policy, and access patterns are understood. Best practice is evolving here: there is no universal standard for how much refactoring must happen before an import can be considered “done.”
Edge cases usually appear when resources have hidden side effects, such as provider-managed defaults, cross-account IAM trust, or out-of-band changes made by another platform tool. Imported state can also look clean while still masking dangerous dependencies if the team only reviews Terraform plan output and not the underlying cloud control plane. NHIMG’s ASP.NET machine keys RCE attack shows how long-lived secrets and assumptions about “known” configuration become liabilities once systems are operationally complex. The practical rule is simple: if the resource cannot be explained, owned, and recreated from code with confidence, the import is not finished even if Terraform accepted it.
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, OWASP Agentic AI Top 10 and CSA MAESTRO address the attack and risk surface, while NIST CSF 2.0 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-03 | Importing resources often exposes weak secret and credential handling. |
| OWASP Agentic AI Top 10 | A2 | Automated infrastructure changes need guardrails against unsafe tool-driven actions. |
| CSA MAESTRO | MAE-03 | Covers governance for automated infrastructure operations and tool access. |
| NIST CSF 2.0 | ID.AM-1 | Asset management is central when reconciling live cloud state to code. |
| NIST AI RMF | GOVERN | Governance is needed when automation can change infrastructure without clear oversight. |
Inventory imported resources and rotate any embedded or inherited NHI secrets immediately.
Related resources from NHI Mgmt Group
- What do security teams get wrong about combining governance and cloud security in one platform?
- What do security teams get wrong about workload identity in cloud and CI/CD environments?
- What do security teams get wrong about sovereign cloud?
- What do security teams get wrong about authentication platform selection?
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