Terratest is a Go library that makes it easier to write automated tests for your infrastructure code. It provides a variety of helper functions and patterns for common infrastructure testing tasks, including:

  • Testing Terraform code
  • Testing Packer templates
  • Testing Docker images
  • Executing commands on servers over SSH
  • Working with AWS APIs
  • Working with Azure APIs
  • Working with GCP APIs
  • Working with Kubernetes APIs
  • Enforcing policies with OPA
  • Testing Helm Charts
  • Making HTTP requests
  • Running shell commands
  • And much more

Watch: “How to test infrastructure code”

Yevgeniy Brikman talks about how to write automated tests for infrastructure code, including the code written for use with tools such as Terraform, Docker, Packer, and Kubernetes. Topics covered include: unit tests, integration tests, end-to-end tests, dependency injection, test parallelism, retries and error handling, static analysis, property testing and CI / CD for infrastructure code.

This presentation was recorded at QCon San Francisco 2019:


Slides to the video can be found here: Slides: How to test infrastructure code.


Terratest was developed at Gruntwork to help maintain the Infrastructure as Code Library, which contains over 300,000 lines of code written in Terraform, Go, Python, and Bash, and is used in production by hundreds of companies.

See how to get started with Terratest Quick Start

Built by Gruntwork

Your entire infrastructure. Defined as code. In about a day.