Terratest
ELI5 — The Vibe Check
Terratest is a Go library for testing your infrastructure code. Write Terraform? Test it with Terratest. It deploys your infrastructure to a real cloud environment, validates it works, then tears it down. It's like a test drive for your infrastructure — actually build it, check it, demolish it.
Real Talk
Terratest is a Go library for automated testing of infrastructure code. It deploys real infrastructure (Terraform, Packer, Docker, Kubernetes), validates behavior through HTTP requests, SSH commands, and API calls, then destroys resources. Provides retry logic and helper functions for cloud APIs.
Show Me The Code
func TestTerraform(t *testing.T) {
opts := &terraform.Options{
TerraformDir: "../modules/vpc",
}
defer terraform.Destroy(t, opts)
terraform.InitAndApply(t, opts)
vpcId := terraform.Output(t, opts, "vpc_id")
assert.NotEmpty(t, vpcId)
}
When You'll Hear This
"Terratest deploys a real VPC, validates the CIDR, then tears it down." / "Every Terraform module has Terratest coverage — we don't merge without it."
Related Terms
Infrastructure as Code
ClickOps means building your cloud infrastructure by clicking buttons in AWS console.
Packer
Packer builds machine images (AMIs, Docker images, VM images) from code. Define what you want installed, Packer builds the golden image.
Terraform
Terraform is a tool that lets you describe your entire cloud infrastructure in code files, then type one command to make it real.