Complete AI Training

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

  1. Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
  2. Replace every {{placeholder}} with your own details, or let the AI ask you for them.
  3. Use the follow-ups below to go deeper.
Prompt

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

  1. Ask for any missing inputs, then confirm scope in two sentences.
  2. Produce the module files: resource definitions, variables or parameters with types and defaults, and outputs.
  3. Comment each block above the code: what it creates, why, and what changes if a caller overrides it.
  4. Show a minimal caller example with placeholder values.
  5. List inputs and outputs in a table with type, required or optional, and description.
  6. Flag anything that could force resource replacement or downtime on update.
  7. 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.