Terratest is a Go library for writing automated tests of infrastructure code. You write ordinary _test.go files, and
Terratest gives you the helpers that make infrastructure-as-code (IaC) testing practical. Once you know what the library
is for, it is easier to decide which helpers to reach for, and to understand why some packages are being trimmed over
time.
Terratest covers five workflows. Together, they let you test infrastructure from end to end.
tofu, terragrunt, packer, or docker from Go and capture their output.test_structure, and retry
with backoff to handle eventual consistency.tofu destroy and clean up with related helpers.Every IaC test leans on a handful of generic building blocks: unique IDs for resource names, file and fixture helpers,
shell execution, the TestingT interface, retry with backoff, and a small logging wrapper around the Logf method on
*testing.T. None of these are specific to infrastructure, but every Terratest test depends on them, so they ship with
the library in the random, files, shell, testing, retry, and logger packages.
Terratest is deliberately narrow in scope. It is not:
testing package already covers that.git, and the like) does not belong here.The rule of thumb: everything in Terratest should serve one of the five workflows above, or directly support them. Helpers that don’t (standard-library wrappers, standalone CLI tools, and anything unrelated to IaC testing) are candidates for removal.
As Terratest moves toward v2, packages that fall outside this scope are being deprecated and will eventually be removed.
A deprecated package carries a // Deprecated: note in its GoDoc that points to the recommended replacement, which is
usually the standard library. These packages keep working for the rest of v1, so you get a full release cycle to
migrate. If you need to stay on a specific release while you do, see
Pinning a Terratest version.
Your entire infrastructure. Defined as code. In about a day.
Explore Gruntwork.io