Interview Prep/Terraform/Modules and Code Structure

Platform team wants each module tested before release. What's your approach?

IntermediateScenarioModules and Code Structure
Answer

Situation read → Modules are shared dependencies and need a test gate.

What I'd do →

  1. Static: fmt, validate, tflint, checkov on every PR.
  2. Plan-level tests with terraform test using command = plan and mock providers.
  3. Integration tests in a sandbox account for critical modules, applying and destroying.
  4. Run the examples folder in CI.

Why → Cheap checks run on every commit; expensive real-cloud tests run before release.

Interview tip → Mention cleanup: tag test resources and run a sweeper so failed runs don't leak cost.

All Terraform questions Roadmap: Terraform

More on Modules and Code Structure