Short Answer Infrastructure as code (IaC) means setting up servers, networks and storage by writing a text file instead of clicking through screens. A tool reads the file and builds everything for you. Because the file can be saved and reused, you get the same setup every time, with fewer mistakes and quicker rebuilds.
What is Infrastructure as Code?
Infrastructure is everything an app needs to run: servers, networks, storage and databases. In the past, IT staff set these up by hand. They logged in to each machine or clicked through a cloud console, the cloud provider’s control screens, one setting at a time.
Infrastructure as code, or IaC, replaces that manual work with a file. The file describes what you want, such as “two servers, one database and a private network”. An IaC tool reads the file and creates it all. This process of creating and setting up resources is called provisioning.
Think of it like a recipe. A cook who follows the same written recipe gets the same dish every time. A cook who works from memory gets something a little different each time. IaC gives your IT setup that written recipe.
Key Words to Know
- Server: a computer that runs apps and stores data for other computers to use.
- Template or configuration file: the text file that describes the setup.
- Version control: a system, such as Git, that saves every change to a file and who made it.
- Provisioning: creating and setting up the parts of the setup, such as servers.
- Automation: letting software do a task that people used to do by hand.
How Does Infrastructure as Code Work?
Most teams follow the same four steps.
- Write the file: An engineer describes the setup they want in a template.
- Save it in version control: The file goes into a shared store, such as Git, so every change is tracked.
- Review and test: A teammate checks the change, and automatic tests look for errors and risky settings.
- Build it: The IaC tool reads the file and creates or updates the servers and other parts to match.

Steps 3 and 4 often run inside an automated line of checks, called a CI/CD pipeline. It tests each change and then puts it live. So a small edit to the file can update the real setup quickly, with a full record of what changed.
How is Infrastructure as Code Used in the Cloud?
IaC is most common in the cloud, where every resource can be created by software. Each big cloud provider has its own IaC tool.
- AWS: AWS (Amazon Web Services), one of the big cloud providers, has a tool called AWS CloudFormation. It reads templates written in YAML or JSON. These are simple text formats that people and computers can both read. It then creates the servers, storage and other parts as one group called a stack.
- Azure: Azure, Microsoft’s cloud, has two tools for the same job: Azure Resource Manager (ARM) templates and Bicep. Bicep is a shorter, easier language that turns into an ARM template behind the scenes.
With IaC, a team can build a copy of its whole cloud setup for testing, then remove it when the test is done. It can also rebuild the same servers and networks in another region, a separate area of the world, if one goes down. The data itself still needs its own backups. Renting servers, storage and networks from a cloud provider is called infrastructure as a service (IaaS). IaC is how many teams manage it.
Why is Infrastructure as Code Important?
IaC solves problems that come from doing setup work by hand.
- Same setup every time: Test and live setups come from the same file, so they are built the same way, even when their sizes differ.
- Fewer manual mistakes: People are less likely to skip a step or type a wrong setting late at night.
- Faster rebuilds: If something breaks, you can rebuild it from the file instead of setting it up again by hand.
- A clear history: Version control shows who changed what, and when.
- Easier growth: Adding ten more servers can mean changing one number in the file.
IaC also helps stop drift. Drift happens when someone changes a live setting by hand, so the real setup no longer matches the file. IaC tools can spot these gaps. You then update the file or run it again to bring the setup back in line.
Many teams start by moving their most repeated tasks into code. You can see how we automate infrastructure provisioning for clients, step by step.
What Does Infrastructure as Code Look Like?
An IaC file is plain text. Here is a tiny AWS CloudFormation template. It asks for one storage bucket, which is a folder in the cloud for files. It also sets the type of encryption, which scrambles the files so outsiders cannot read them.
Resources:
ReportsBucket:
Type: AWS::S3::Bucket
Properties:
BucketEncryption:
ServerSideEncryptionConfiguration:
- ServerSideEncryptionByDefault:
SSEAlgorithm: AES256
Even without knowing the tool, you can read what it does. “ReportsBucket” is the name. “Type” says it is a storage bucket. The lines under “Properties” set the encryption, and the last line picks which kind to use. Real files are longer, but they follow the same idea: you list what you want, line by line.
What is the Difference Between Declarative and Imperative IaC?
There are two ways to write IaC. They differ in whether you describe the result or the steps.
Declarative IaC describes the end result you want. You say “I want three servers”, and the tool works out how to get there. If the file already built two servers, it adds only one. The example above is declarative.
Imperative IaC lists the exact steps to follow, in order. You say “create a server, then another, then another”. If you run it twice, you might end up with six servers, unless the steps first check what already exists.

| Aspect | Declarative | Imperative |
|---|---|---|
| What you write | The end result you want | The steps to get there |
| Who works out the steps | The tool | You |
| Running it twice | Same result, no extra copies | May repeat the steps unless you add checks |
| Examples | AWS CloudFormation, Bicep | Scripts that call cloud commands one by one |
| Best for | Most cloud setups | One-off tasks that need exact control |
The “same result when run twice” idea has a name: idempotent. It is one reason most teams prefer declarative tools.
Talk to an ExpertStill building your cloud setup by hand? Talk to our team about moving it into code.How is It Different From Configuration Management?
The two are closely linked but do different jobs. IaC creates the infrastructure itself, such as servers, networks and storage. Configuration management sets up what runs inside those servers, such as software, updates and settings.
A simple way to picture it: IaC builds the house, and configuration management fits the furniture and keeps it tidy. Many teams use both. An IaC tool creates the servers, then a configuration management tool installs and updates the software on them. Some tools can do a bit of both.
Is Infrastructure as Code Part of DevOps?
Yes. IaC is one of the core practices of DevOps. DevOps is a way of working where the people who build and run software share tools and goals. DevOps aims to ship changes quickly and safely. IaC helps by treating the setup like app code. Each change is saved, reviewed, tested and put live the same way.
A related idea is GitOps. In GitOps, the files in Git are the one true record of how the setup should look. Any change to the live setup starts as a change to those files. A tool watches the files and keeps changing the live setup until it matches them.
What is Infrastructure as Code Security?
IaC security means checking IaC files for risky settings before they go live. A single wrong line can leave stored files open to the public, or leave an open door from the internet into your network. Because the setup is written down, these mistakes can be caught early, before anything is built.
Teams use scanning tools that read the files and flag problems, such as missing encryption or passwords typed straight into a file. These scans often run in the pipeline, so a risky change is blocked automatically. Moving security checks early like this is part of DevSecOps, which adds security checks to the DevOps way of working.
Good habits include keeping passwords and other secrets out of IaC files and reviewing every change. Also limit who can use the tool to change live systems. An infrastructure as code checklist covers these steps. If you are still picking a tool, read about choosing infrastructure as code tools.
Frequently Asked Questions
Is infrastructure as code hard to learn?
What language is infrastructure as code written in?
What is configuration drift?
Can infrastructure as code be used outside the cloud?
What is a template in infrastructure as code?
Does infrastructure as code replace IT staff?
What is idempotent in infrastructure as code?
Who uses infrastructure as code?
References
- The AWS tool: AWS CloudFormation User Guide, What is CloudFormation?
- The Azure tool: Microsoft Learn, What is Bicep?
- IaC in DevOps: Microsoft Learn, What is Infrastructure as Code (IaC)?
Get the Latest Terms & Insights.
New encyclopedia terms, threat intelligence, and architecture decisions, by email.
