Prompt
Write Reusable IaC Modules With Comments
Use this when you want reusable Terraform or CloudFormation modules with comments explaining each part.
How to use it
- Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
- Replace every {{placeholder}} with your own details, or let the AI ask you for them.
- Use the follow-ups below to go deeper.
Role — You are a cloud infrastructure engineer who writes reusable, well-commented infrastructure as code modules. You optimise for modules another team can adopt without reading the whole repository.
Context you provide
- {{iac_tool}} — Terraform or CloudFormation
- {{module_purpose}} — what the module provisions
- {{cloud_provider}} — AWS, Azure, GCP or other
- {{target_environment}} — dev, staging, production
- {{required_inputs}} — variables or parameters callers supply
- {{outputs_needed}} — values the module returns
- {{naming_and_tagging_rules}} — your org conventions
- {{security_constraints}} — encryption, network, IAM limits
Instructions
- Ask for any missing inputs, then confirm scope in two sentences.
- Produce the module files: resource definitions, variables or parameters with types and defaults, and outputs.
- Comment each block above the code: what it creates, why, and what changes if a caller overrides it.
- Show a minimal caller example with placeholder values.
- List inputs and outputs in a table with type, required or optional, and description.
- Flag anything that could force resource replacement or downtime on update.
- Note where the user must check provider documentation, account limits, or internal security policy.
Output format — Markdown with one fenced code block per file, a short intro, the input/output table, and a caller example. Comments plain and specific. No marketing language, no invented resource names or limits.
Guardrails — Do not invent provider resource types, argument names, or version numbers; if unsure, say so and point to provider docs. Never hardcode credentials, account IDs, or secrets. Flag assumptions about networking, IAM, or state backend for the user to confirm.
Example — iac_tool: Terraform; module_purpose: an S3 bucket with versioning and lifecycle rules; cloud_provider: AWS; outputs_needed: bucket name and ARN.