← All Posts
DevOps6 min read

Infrastructure-as-Code with Terraform: A Practitioner's Guide for 2026

Afocal Solutions·

In March 2026, a supply chain attack compromised over 434,000 CI/CD pipelines across 2,500+ companies. The attack, orchestrated by threat actor Team PCP, exposed infrastructure credentials and cloud secrets at organizations including NVIDIA, AWS, Samsung, and Salesforce. The vector? Not Terraform itself — but the sprawling ecosystem of integrations, AI agents, and third-party services that now surround modern infrastructure-as-code workflows.

If you're an IT leader at an SMB, this should crystallize something: infrastructure-as-code with Terraform isn't just a technical practice anymore. It's a security boundary. And that boundary is getting harder to defend.

Why Terraform Still Dominates Infrastructure Automation in 2026

With over 70% market share in the sector, Terraform has become the de facto standard for managing cloud infrastructure. That dominance hasn't eroded despite the 2023 relicensing under the Business Source License (BUSL), which spawned the OpenTofu fork.

Both tools are production-ready in 2026. The decision is mostly organizational: no HashiCorp contract means OpenTofu is the default for many new projects; existing HCP Terraform or Sentinel users are not migrating today.

For SMBs, the practical reality is simpler: pick one and standardize. The provider ecosystem, community knowledge, and tooling maturity all favor Terraform if you're already operating in AWS, Azure, or GCP environments. OpenTofu is a legitimate option if you're starting fresh and want to avoid HashiCorp licensing entirely — but the switching costs mid-stream rarely justify ideological purity.

The current stable release is 1.15.2, released May 6, 2026. If you're running anything older than 1.12, you're missing meaningful security and functionality updates.

Terraform Security: Ephemeral Resources and State File Protection

The most significant security improvement in recent Terraform releases directly addresses one of the tool's oldest weaknesses: secrets in state files.

Ephemeral resources are used during a Terraform run but never written to state. The canonical example is a Vault-issued AWS credential that exists only for the duration of terraform apply. The credential never appears in terraform.tfstate. If your state file is compromised, temporary credentials from past runs are not exposed. This addresses a real attack surface with no clean prior solution.

If you're still storing static AWS keys or database passwords in your Terraform state, you now have a first-class alternative. The configuration is straightforward — ephemeral resources work like any other resource block but are never persisted.

Recent security patches include CVE-2026-14978, a Unicode normalization issue that could lead to files not being correctly excluded via .terraformignore from upload to Terraform Enterprise or HCP Terraform. It's the kind of edge case that only matters until it compromises your CI/CD pipeline.

State file encryption, remote backends, and proper RBAC remain non-negotiable. But ephemeral resources finally close the gap on credentials that have no business sitting in state.

The CI/CD Supply Chain Problem IaC Can't Solve Alone

The March 2026 supply chain attack affected approximately 434,000 CI/CD pipelines. CloudSEK's analysis found the exposure includes high-confidence matches associated with major organizations.

The scale of the potential exposure shows how quickly a compromise in an AI-adjacent development component can create a security investigation spanning cloud infrastructure, software repositories, Kubernetes environments, third-party services and AI systems. The impact of the incident reaches beyond developer tooling.

IaC scanning catches misconfigurations in your Terraform code. It doesn't catch compromised dependencies in your CI runner, poisoned provider binaries, or AI agents provisioning resources outside your code-controlled workflows.

The trouble in 2026 is that the assumption underneath IaC security — that infrastructure is created through code in repositories you control — is increasingly only partly true.

IaC security tools scan the code they're configured to scan. They have no visibility into infrastructure created outside that code — provisioned via web console, spun up via a SaaS-to-cloud integration, or created on the fly by an AI agent with cloud credentials.

The practical response: layer your defenses. IaC scanning in CI/CD (Checkov, tfsec, Sentinel) catches known misconfigurations. Cloud Security Posture Management (CSPM) catches drift between your code and reality. Runtime detection catches the rest. No single tool covers all three.

New Terraform Features Worth Your Attention

HashiCorp has continued shipping meaningful updates. Three capabilities warrant integration into your workflows:

Declarative Import: You can now remove resources from state without destroying them using the removed block with lifecycle { destroy = false }. This also applies to importing existing resources — the -generate-config-out flag writes HCL for existing resources during terraform plan. Generated configs need manual cleanup but significantly reduce the friction of bringing unmanaged resources into state.

Import Blocks in Modules: Import blocks are now supported inside modules, and providers can store planned private data preserved across plan and apply. This simplifies brownfield adoption — you can package import logic into reusable modules rather than running one-off state commands.

Terraform Stacks (Preview): Stacks orchestrate multiple deployments as a unit — useful for deploying one module across 12 environments in dependency order. As of early 2026, Stacks remain in preview via HCP Terraform. Evaluate this if you're managing multi-region or multi-account deployments with complex sequencing requirements.

Practical Steps for SMB DevOps Teams

If you're a 50-person company running infrastructure on AWS or Azure, here's what to prioritize:

1. Audit your state file exposure. Where is your terraform.tfstate stored? Who can read it? Migrate to a remote backend (S3 + DynamoDB, Azure Storage, or HCP Terraform) with encryption and access logging if you haven't already.

2. Implement ephemeral resources for credentials. If you're pulling secrets from Vault, AWS Secrets Manager, or Azure Key Vault, move those to ephemeral resources so credentials never persist.

3. Lock down your CI/CD runners. The March 2026 breach demonstrates that compromised pipelines lead to compromised infrastructure. Isolate Terraform execution environments, pin provider versions, and verify checksums.

4. Detect drift. Your IaC is only as good as your enforcement. Run terraform plan on a schedule (not just at PR time) to catch resources modified outside your codebase.

5. Plan for the HCP Terraform migration. HashiCorp says the legacy "Free (Legacy)" HCP Terraform plan ends March 31, 2026. Organizations still on the legacy plan will be automatically transitioned to the enhanced Free tier, which includes up to 500 managed resources at no charge. If you're above 500 resources, budget accordingly.

Key Takeaways

  • Terraform remains the dominant IaC tool, with 70%+ market share. OpenTofu is a viable alternative for new projects without HashiCorp dependencies.
  • Ephemeral resources solve a real security gap — credentials no longer need to persist in state files, reducing exposure from state file compromise.
  • IaC security tools only protect code they can see. CI/CD supply chain attacks and console-provisioned "shadow infrastructure" require layered detection.
  • Update your Terraform version. If you're below 1.12, you're missing critical security patches and productivity features like declarative import.

Managing infrastructure-as-code at scale requires more than good HCL — it requires operational discipline, security tooling, and someone who's done it before. Afocal's Managed DevOps team helps SMBs build Terraform workflows that survive contact with production.

Want to learn more about how Afocal can help your business?

Book a Free Audit

Your next breach is preventable.

Let's talk about your security posture. No commitment, just a conversation with a practitioner.