A matrix strategy solves a practical CI problem: one workflow can validate the same Terraform code across multiple engines, versions, or tests without duplicating jobs. GitHub Actions expands each listed combination into an independent execution. section 7.7.3 section 9.3.6
A matrix names dimensions such as engine, version, experimental status, and test. GitHub Actions combines their values, while include adds selected combinations outside the default set. fail-fast: false lets all combinations finish, and continue-on-error can allow experimental combinations to fail without failing the workflow. section 7.7.3 section 9.3.6
Testing engines, versions, and individual tests
A Terratest workflow can define engine: ["opentofu", "terraform"], several supported versions, and test: [BasicTest, LambdaTest, ECSTest, Ec2Test]. Each test then runs independently for every selected engine and version. Conditional installation steps choose the matching OpenTofu or Terraform setup action, while an experimental version can use continue-on-error. section 9.3.6
Use matrix strategies to:
- Check compatibility across OpenTofu and Terraform without locking a reusable module to one vendor or version. section 7.7.3
- Split long-running infrastructure tests into parallel jobs instead of running examples sequentially. section 9.3.6
- Pass a selected test or filter through a Makefile or test command so each matrix job targets one test. section 9.3.6 section 9.4.6
- Keep version lists accurate: remove unsupported versions and distinguish stable combinations from explicitly experimental ones. section 7.7.3 section 9.4.6
