IaC (Infrastructure as Code)
IaC (Infrastructure as Code) is an approach in which the configuration of servers, networks, databases and other IT resources is defined in code files, rather than by clicking through panels or typing commands on each machine individually. Infrastructure is treated like software: stored in version control, subjected to code review and deployed automatically. It is one of the foundational practices of DevOps culture.
How IaC works
Instead of documenting configuration in instructions an administrator follows by hand, it is described in files readable by both humans and machines. Two models exist. In the declarative approach you describe the desired end state and the tool determines the necessary steps. In the imperative approach you provide a sequence of commands to execute. A key trait of good IaC is idempotency — re-running the configuration introduces no changes once the target state has been reached, letting you safely repeat deployments.
Popular tools include Ansible, Terraform, Puppet and Chef — some focus on provisioning infrastructure, others on managing the configuration of existing servers.
Practical application
IaC eliminates 'configuration drift', where production and test environments gradually diverge through manual changes. Because everything is described in code, an identical environment can be rebuilt in minutes — invaluable when scaling, recovering from a disaster or building a high availability architecture. IaC is also the basis of CI/CD pipelines and the GitOps approach, where a Git repository is the single source of truth for the infrastructure's state.
Adopting IaC brings benefits beyond automation itself: the infrastructure code acts as always-current documentation, every change goes through review and is recorded in version history, and a faulty configuration can be rolled back like an ordinary commit. This increases the repeatability and safety of environments, and knowledge of the infrastructure is no longer locked inside one administrator's head.
Powiązane pojęcia
Najczęstsze pytania
What's the difference between the declarative and imperative approach in IaC?
In the declarative approach you describe the desired end state of the infrastructure (for example, 'there should be 3 servers with this configuration'), and the tool works out which steps to take. In the imperative approach you specify the commands one by one. Declarative is usually safer because it supports idempotency.
What does idempotency mean in IaC?
It's the property whereby running the same configuration multiple times produces the same result and causes no unintended changes. If the infrastructure is already in the target state, the tool changes nothing. Idempotency lets you safely re-run scripts without the risk of duplicating resources.
