Infrastructure as code (IaC) is the practice of defining servers, networks, databases and other infrastructure in machine-readable files that are versioned, reviewed and applied by tools instead of configured by hand.

Definition
Infrastructure as code treats infrastructure the way developers treat application code. Instead of clicking through a cloud console to create a network, a database and a set of servers, an engineer writes files that describe them. A tool reads those files and creates, updates or removes real resources to match. The files live in version control, so every change has an author, a review and a history.
Popular tools include Terraform and OpenTofu, which work across many providers, AWS CloudFormation and Azure Bicep for their own clouds, Pulumi, which uses general-purpose programming languages, and configuration management tools such as Ansible for what runs inside servers. The aim is the same in each case: environments that can be recreated reliably, changed safely and understood by reading the code.

How it works
Most modern IaC tools are declarative. You describe the end state, for example “a private network with two subnets, a managed PostgreSQL database and a load balancer,” rather than the steps to build it. The tool compares that description with what currently exists, which it tracks in a state file or by querying the provider, and works out a plan of what to create, change or delete.
A typical workflow runs through the same review process as application code. An engineer changes a file and opens a pull request. A pipeline runs a plan and shows exactly which resources will be affected. After review, the change is merged and the pipeline applies it. Policy checks can block risky changes, such as opening a database to the internet, before they reach production.
Shared building blocks are packaged as modules, so a standard network or service setup can be reused across projects and environments. Development, staging and production can be created from the same code with different settings, which keeps them consistent and makes it straightforward to rebuild an environment after a failure.
Keep learning
Put it into practice
CI/CD pipelines, infrastructure as code, observability and automation that make releases frequent, safe and routine.
Explore serviceCloud architecture, migration and modernization on AWS and Azure, planned for reliability, security and controlled cost.
Explore serviceCloud security architecture, posture management, identity controls and container security for AWS, Azure and Kubernetes environments.
Explore serviceFAQ
Declarative IaC describes the desired end state and lets the tool work out the steps, as Terraform and CloudFormation do. Imperative IaC lists the steps to perform in order, as a script would. Declarative approaches are easier to reason about for cloud resources, while imperative or procedural tools are often used for configuring software inside servers.
No. Even a small team benefits from being able to rebuild its environment from code, review changes and avoid one person holding all the setup knowledge. The tooling is free or low cost to start with, and starting early is easier than converting a large, hand-built environment later.
It makes configuration visible and reviewable before it is applied. Security teams can scan files for misconfigurations, enforce policies automatically in the pipeline and see exactly when and why a setting changed. It also makes it faster to apply a fix across every environment that uses the same module.
Talk to a solution architect about where it fits in your roadmap.
