Infrastructure as Code (Terraform/OpenTofu)
As a Architect engineer, explain Infrastructure as Code (Terraform/OpenTofu). What problem does it solve and how would you describe it in an interview?
Answers use simple, clear English.
Quick interview answer
At Architect depth: start with the problem, then mechanism, then a short example. Declare cloud resources in code; plan/apply with state.
Detailed answer
At Architect depth: start with the problem, then mechanism, then a short example. Declare cloud resources in code; plan/apply with state. Modules, workspaces/envs, remote state locks. Idempotent infra changes reviewed in PR. Core: Declare cloud resources in code; plan/apply with state. Modules, workspaces/envs, remote state locks. Idempotent infra changes reviewed in PR. Real-time example: PR shows terraform plan +2 aws_s3_bucket; apply on merge to infra main. Pros: Reviewable, repeatable environments. Cons: State drift; blast radius of bad apply. Common mistakes: Manual console changes causing drift; secrets in state. Best practices: Remote state + lock; policy as code (OPA); no drift culture. Audience level: Architect.
Full explanation
Declare cloud resources in code; plan/apply with state. Modules, workspaces/envs, remote state locks. Idempotent infra changes reviewed in PR.
Real example & use case
PR shows terraform plan +2 aws_s3_bucket; apply on merge to infra main.
Pros & cons
Pros: Reviewable, repeatable environments. Cons: State drift; blast radius of bad apply.
Common mistakes
Manual console changes causing drift; secrets in state.
Best practices
Remote state + lock; policy as code (OPA); no drift culture.
Follow-up questions
- How would you test Infrastructure as Code (Terraform/OpenTofu)?
- What metrics prove Infrastructure as Code (Terraform/OpenTofu) is healthy in prod?
- How does Infrastructure as Code (Terraform/OpenTofu) change at 10× traffic?