What is Infrastructure as Code and why is it better than creating resources by clicking in the cloud console?
What the interviewer wants to hear
- Infrastructure defined in version-controlled files
- Repeatable and consistent environments
- Code review and audit history
- Plan before apply; detect drift
- Declarative tools like Terraform, OpenTofu, Pulumi or CloudFormation
Model answer
Infrastructure as Code means we describe servers, networks, databases and permissions in files, for example Terraform or OpenTofu code, and a tool creates them for us. Because the files live in Git, every change goes through a pull request, gets reviewed, and has a history we can audit or revert. It makes environments repeatable: staging and production can be built from the same modules with different variables, so they do not slowly become different. Before applying, terraform plan shows exactly what will change, which reduces surprises. We can also detect drift when someone changes something by hand. Clicking in the console is fine for learning, but it is slow, error-prone, hard to reproduce after a disaster, and nobody knows why a setting was changed.
Can you answer it under time pressure?
Take a timed easy round and get scored on every answer.
More easy DevOps Engineer questions
- What does DevOps mean to you, and how is it different from a traditional operations team?
- Walk me through the stages of a typical CI/CD pipeline you would build for a web service.
- How is a container different from a virtual machine? When would you choose one over the other?
- Explain how a Deployment, a Service and an Ingress work together to expose a web app in Kubernetes.
- Compare trunk-based development with GitFlow. Which would you choose for a team that deploys several times a day, and why?
- Walk me through what happens when you run docker run -p 8080:80 nginx:1.27 on a fresh machine.
- What is the difference between monitoring and observability, and what are the main signals you would collect for a web service?
- How does a load balancer use health checks, and what makes a good health check endpoint?
- Terraform and Ansible are both called infrastructure as code. How do they differ, and when would you use each?