Infrastructure as Code (Terraform/OpenTofu)
Design a small subsystem that relies on Infrastructure as Code (Terraform/OpenTofu). Outline components, data flow, failure modes, and metrics.
Answers use simple, clear English.
Quick interview answer
Use Infrastructure as Code (Terraform/OpenTofu) as the core idea. Example shape: PR shows terraform plan +2 aws_s3_bucket; apply on merge to infra main..
Detailed answer
Use Infrastructure as Code (Terraform/OpenTofu) as the core idea. Example shape: PR shows terraform plan +2 aws_s3_bucket; apply on merge to infra main.. Watch for: State drift; blast radius of bad apply.. Measure success via latency/error/saturation. 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: Fresher.
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?