Skip to content
🎉 Launch sale:50% off everything over $22 — automatically applied at checkout· ends Aug 2Shop the sale →
DevOps AI ToolKit
Newsletter
All prompts
AI for Infrastructure as Code Difficulty: Advanced ClaudeChatGPT

Terratest Go Infrastructure Test Suite Prompt

Design a Terratest suite in Go that provisions real infrastructure, asserts on outputs and live behavior, and tears everything down cleanly even when assertions fail.

Target user
infrastructure engineers writing IaC and Go tests
Difficulty
Advanced
Tools
Claude, ChatGPT

The prompt

You are a senior infrastructure-as-code engineer who has built Terratest suites that catch real regressions in modules without leaking cloud resources or running up surprise bills.

I will provide:
- The module or stack under test and its inputs/outputs
- The behaviors that matter (outputs, reachability, IAM effect, idempotency)
- The CI and cloud-account context the tests run in

Your job:

1. **Structure the test** — lay out the Go test using `terraform.Options`, `InitAndApply`, output assertions, and table-driven cases for input variations.
2. **Guarantee cleanup** — make `defer terraform.Destroy` the first deferred call after apply so resources are torn down even on a failed assertion or panic, and explain the leak risk if it is not.
3. **Assert on live behavior** — go beyond output strings: poll real endpoints, check cloud-provider API state, and use `retry`/`http_helper` with bounded timeouts instead of fixed sleeps.
4. **Isolate test runs** — randomize names/prefixes (`random.UniqueId`) and use disposable, scoped accounts/regions so parallel runs and stale resources never collide.
5. **Control cost and time** — parallelize with `t.Parallel()` where safe, set timeouts, and identify expensive resources that should be mocked or limited.
6. **Make failures debuggable** — capture plan/apply logs and surface the failing assertion with context, not just a boolean.
7. **Define the CI gate** — specify credentials handling, what blocks merges, and how to prevent leaked resources from a killed CI job.

Output as: the Go test file(s), a cleanup-and-isolation checklist, and the CI invocation with cost/timeout guards.

Never run Terratest against a shared or production account — it applies real infrastructure, and a failed teardown leaves billable, possibly internet-exposed resources behind.

Run this prompt with AI

Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.

Related prompts

More Infrastructure as Code prompts & error guides

Browse every Infrastructure as Code prompt and troubleshooting guide in one place.

Free download · 368-page PDF

Reading prompts? Get all 500 in one free PDF

500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.

  • 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
  • Instant PDF download — yours free, forever
  • Plus one practical AI-workflow email a week (no spam)

Single opt-in · unsubscribe anytime · no spam.