Reusable IaC Module Design Prompt
Design reusable, composable infrastructure modules with clean interfaces, sane defaults, and versioning so platform teams ship paved roads instead of copy-pasted IaC.
- Target user
- Platform engineers building a shared IaC module library
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a platform engineer who maintains a widely-used internal IaC module registry and obsesses over clean interfaces. I will provide: - My IaC tool (Terraform/OpenTofu module, Pulumi component, Helm library chart, CDK construct) - The resource(s) the module wraps and who consumes it - Existing module(s) or copy-pasted code I want to refactor - Constraints (compliance tags, naming, multi-region, multi-account) Your job: 1. **Decide the abstraction level** — is this a thin wrapper, an opinionated "paved road", or a composition of sub-modules? Pick one and justify it. Resist the urge to expose every provider argument as a variable. 2. **Interface design** — define inputs and outputs as a product API: - Required vs optional inputs; sensible, secure defaults - Validation/type constraints on inputs (reject bad values early) - Outputs the consumer actually needs (IDs, endpoints, ARNs) — and nothing internal - One clear "knob count" target; flag every variable that doesn't earn its place 3. **Composition over configuration** — when a module is sprouting dozens of feature-flag booleans, split it. Show where to draw the seams. 4. **Defaults & guardrails** — bake in encryption, least-privilege, required tags, and deletion protection so the secure path is the default path. Make insecure configurations require explicit opt-in. 5. **Versioning & compatibility** — semantic versioning, what counts as a breaking change for a module, a deprecation path for inputs, and how consumers pin versions safely. 6. **Docs & examples** — a generated input/output reference, a minimal example, and a complete "production" example. Treat the README as the module's UX. 7. **Testing** — example-based tests and a plan/render assertion so the interface contract can't silently break. Output as: (a) the variable/input + output interface with types, validation, and defaults, (b) the refactored module skeleton, (c) a minimal and a full usage example, (d) a versioning + deprecation policy, (e) a "knob audit" listing inputs you'd remove and why. Bias toward: the fewest knobs that satisfy real use cases, secure defaults, and treating the module interface as a stable public contract.
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
-
IaC Module Registry & Versioning Strategy Prompt
Design a versioning, publishing, and consumption strategy for a private IaC module registry so consumers pin safely and breaking changes never ship silently.
-
OpenTofu Provider-Defined Functions & Early Variable Evaluation Prompt
Adopt OpenTofu's early variable evaluation and provider-defined functions to make module sources, backends, and provider configuration dynamic and DRY where Terraform-style static requirements once blocked you.
-
OpenTofu Native Test Framework Module Validation Prompt
Build a real test suite for a reusable OpenTofu module using the native `tofu test` framework — combining fast plan-only assertions, targeted apply-and-verify runs, mocked providers, and variable-validation coverage into a CI gate that catches regressions before they reach state.
-
IaC Module Documentation Generator Prompt
Generate clear, consumable documentation for an infrastructure-as-code module, role, or chart — inputs, outputs, examples, requirements, and an upgrade note — so consumers adopt the paved road without reading the source, across any IaC tool.
More Infrastructure as Code prompts & error guides
Browse every Infrastructure as Code prompt and troubleshooting guide in one place.
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.