Terratest

What is terratest?

Terratest is a Go library that is commonly used for testing infrastructure code. It’s particularly popular in the DevOps and infrastructure-as-code (IaC) communities. With Terratest, developers can write automated tests to validate infrastructure components such as cloud resources, networking configurations, and server deployments.

Terratest provides a set of helper functions and utilities for writing tests in Go that interact with real infrastructure components. It supports various cloud providers like AWS, Google Cloud Platform (GCP), Azure, as well as other tools and platforms such as Docker and Kubernetes.

By using Terratest, developers can ensure that their infrastructure code behaves as expected, helping to catch bugs and issues early in the development process and improving the overall reliability and stability of their infrastructure deployments.

What are the parts that normally form a terraform test?

  • Setup creating the terraform options, setting up the terraform code to test and variables
  • Delayed destroy operation, so that when the function ends, terratest can dispose of the resources created by the test
  • Initialize and apply the terraform code to provision the infrastructure
  • Validate the infrastructure

Reference