Infrastructure as Code for DevOps Engineers
Infrastructure as code means defining servers, networks and services in versioned files instead of clicking in a console. Terraform and OpenTofu declare resources and track them in state, configuration management tools like Ansible configure machines, and policy and testing tools check the code before it changes real infrastructure.
Stage: Cloud and Infrastructure as Code · Part of the DevOps Engineer roadmap · Last reviewed 19 November 2026
What to learn in Infrastructure as Code
- Write Terraform resources, variables and outputs for a small environment
- Explain the plan and apply workflow and the role of state
- Store state remotely with locking for team use
- Use modules to reuse infrastructure patterns
- Write an Ansible playbook that is idempotent
- Check IaC with linting, policy rules and plan review
Infrastructure as Code interview questions
What is Terraform state and why does it matter?
State is a record mapping your configuration to real resources and their attributes. Terraform uses it to compute what to create, change or destroy. It should be stored remotely with locking and protected, since it can hold sensitive values.
What does idempotent mean for configuration management?
An idempotent operation gives the same result no matter how many times it is applied. Running an Ansible playbook twice should change nothing the second time, which makes automation safe to repeat and lets you detect drift.
Where Infrastructure as Code fits in the DevOps Engineer roadmap
Infrastructure as Code belongs to the Cloud and Infrastructure as Code stage (intermediate level), which takes about 1 hours. Provision repeatably.
Other units in this stage
Back to the full DevOps Engineer roadmap