What Is Infrastructure as Code (IaC)? Definition, Tools and DevOps Role

Ashish Dubey
Líder de Marketing
Published:
setembro 18, 2026
Updated:
novembro 17, 2026
What is infrastructure as code

Infrastructure as code (IaC) is the practice of defining and managing infrastructure, such as servers, networks, databases and access rules, in code files instead of clicking through a cloud console. In DevOps, IaC means infrastructure lives in Git, gets reviewed like application code, and is created by automated pipelines, so every environment can be rebuilt the same way.

The idea took off with tools like Chef and Puppet, then CloudFormation and Terraform. It is now standard practice for any team that runs in the cloud.

How does IaC work?

  1. Write: describe the resources you want in files, using HCL, YAML, JSON or a language like Python.
  2. Commit: store the files in Git and review changes in pull requests.
  3. Plan: the tool compares your code with what actually exists and shows exactly what will change.
  4. Apply: the tool creates, updates or deletes resources through the cloud provider's APIs.
  5. Track: a state file records what was built, and drift detection flags anyone who changed things by hand.
Infrastructure as code workflow

Declarative vs imperative IaC

Tools differ in how you describe the result.

ApproachYou writeExample toolsBest for
DeclarativeThe end state you wantTerraform, OpenTofu, CloudFormation, BicepProvisioning most infrastructure
ImperativeStep-by-step commandsAnsible playbooks, shell scriptsConfiguring servers and one-off tasks
ProgrammableInfrastructure in a general-purpose languagePulumi, AWS CDKTeams that want loops, tests and shared libraries

IaC in DevOps and CI/CD

IaC is what lets infrastructure follow the same path as application code. A typical pipeline looks like this:

  • A pull request changes the infrastructure code.
  • The pipeline runs a plan and shows the diff to reviewers.
  • Security and policy scanners, such as Checkov or Trivy, check the code before anything is built. This is the DevOps-plus-security habit, often called SecDevOps, and it catches open storage buckets and wide-open firewall rules early.
  • After approval, the pipeline applies the change. Secrets stay in a vault, never in the code.
  • A scheduled job checks for drift and alerts the team.

See how this works for services in our CI/CD setup guide.

Popular IaC tools

CategoryToolsWhat they do
ProvisioningTerraform, OpenTofu, CloudFormation, PulumiCreate and manage servers, networks, storage and databases
Configuration managementAnsible, Chef, PuppetInstall software and manage settings on servers
Cloud-nativeAWS CDK, Azure Bicep, CrossplaneDefine resources for one cloud, or manage them from Kubernetes
Security and policyCheckov, Trivy, Open Policy AgentScan IaC files for risky settings and enforce rules

Terraform's license changed to the Business Source License in 2023, which led to OpenTofu, an open-source fork under the Linux Foundation. HashiCorp is now part of IBM. Most teams treat Terraform and OpenTofu as interchangeable for everyday work.

Why teams use IaC

  • Repeatable: dev, staging and production are built from the same code.
  • Faster: a full environment takes minutes, not a ticket queue.
  • Auditable: Git history shows who changed what and why.
  • Recoverable: after an outage you can rebuild from code instead of memory.

IaC for AI infrastructure

AI workloads add GPU node pools, high-bandwidth networking and strict access rules. These are exactly the pieces teams define in Terraform or Pulumi, across multiple clouds where needed.

TrueFoundry runs on Kubernetes inside your own cloud account, so the clusters it uses can be provisioned the same way as the rest of your cloud architecture. On top, the AI Gateway centralizes model access, routing, governance and observability, including setups described in our on-prem AI Gateway guide.

Building AI infrastructure on your own cloud?

Provision the clusters with Terraform, then let TrueFoundry run your models and agents on top, with one gateway for access, routing and governance.

Book a demo →

Related: virtualization and middleware.

1. Lorem ipsum dolor sit amet
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, 
2. Lorem ipsum dolor sit amet
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, 
3. Lorem ipsum dolor sit amet
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, 
Table of Contents

Govern, Deploy and Trace AI in Your Own Infrastructure

Book a 30-min with our AI expert

Book a Demo
Grey wavy lines on white background, abstract wave pattern with multiple curved lines intersecting smoothly.

GenAI infra- simple, faster, cheaper

Trusted by Top Teams to Scale GenAI