DevOps Interview Questions

Infrastructure as Code (IaC) - Interview Guide

"What is Infrastructure as Code and how have you used it?"

Why Interviewers Ask This

IaC is essential for reproducible, auditable infrastructure. This tests whether you can manage infrastructure with the same rigor as application code.

How to Answer

  1. 1

    Define IaC and explain its benefits: versioning, reproducibility, automation.

  2. 2

    Discuss tools you have used: Terraform, CloudFormation, Pulumi, etc.

  3. 3

    Cover best practices: state management, modules, testing.

  4. 4

    Share a practical example.

Sample Answer

Infrastructure as Code means defining infrastructure through declarative configuration files rather than manual processes. This gives you version control, peer review, reproducibility, and automation. I primarily use Terraform with remote state in S3 and DynamoDB locking. I organize code into reusable modules — a VPC module, an ECS service module, a database module — each with its own tests. All changes go through PR review and plan output before apply. I also use Terragrunt for managing multiple environments with minimal duplication. In my current role, I migrated our entire AWS infrastructure from ClickOps to Terraform — 150+ resources across 3 environments. This reduced environment setup time from 2 days to 15 minutes and eliminated configuration drift.

Pro Tips

  • Mention state management — it is the trickiest part of Terraform.

  • Discuss drift detection and remediation.

  • Show you treat infrastructure code with the same quality standards as application code.

Frequently Asked Questions

Terraform vs CloudFormation?

Terraform is cloud-agnostic and has a larger community. CloudFormation is AWS-native with better AWS integration. Use CloudFormation if you are 100% AWS; Terraform if multi-cloud or wanting flexibility.

How do you test IaC?

Static analysis (tflint, checkov), plan review, integration tests that deploy to a temporary environment, and policy-as-code (OPA/Sentinel) for compliance checks.

How do you handle secrets in IaC?

Never store secrets in IaC files. Use AWS Secrets Manager, HashiCorp Vault, or SOPS. Reference secrets by ARN or path, not by value.

Worried About Going Blank in Your Interview?

HireMe AI listens to your interview in real-time, detects questions, and generates instant answer suggestions — so you never freeze up again.

Try HireMe AI Free