Generate a quality score for a Terraform codebase from structure, drift and coverage.
Infrastructure score blends four weighted signals: drift (30%, penalizing resources that diverge from state), plan/apply success rate (30%, reliability of the core workflow), apply time (15%, operational efficiency), and module reuse (25%, a proxy for consistency and maintainability). Each is normalized to 0-100 before weighting, mirroring the structure of the Git repository health score for a comparable DevOps maturity view.
score = drift_score × 0.30 + success_score × 0.30 + apply_time_score × 0.15 + reuse_score × 0.25
Both directly reflect whether your infrastructure-as-code can be trusted as the source of truth — high drift means your code lies about reality, and low success rate means the core workflow (plan/apply) itself is unreliable, undermining confidence in every other metric.
Divide resources provisioned through calls to shared/versioned modules by total managed resources — a high ratio indicates standardized, DRY infrastructure patterns rather than repeated inline resource blocks per environment.
Yes — apply time only carries 15% weight, so a fast but heavily drifted or unreliable (low success rate) configuration will still score low overall, correctly reflecting that speed doesn't offset trustworthiness issues.
Start with whichever sub-score is lowest: schedule drift remediation if drift is high, investigate flaky providers/modules if success rate is low, or invest in a shared module library if reuse is low.