Write a Terraform module
Writes a reusable Terraform module with typed, validated variables, secure defaults, documented outputs and an example. Use when wrapping cloud resources for other teams to consume.
A Terraform module is an API. Its variables are the inputs other teams depend on and its outputs are the contract they build on, so changing either later is a breaking change. Generated modules usually fail in the same ways: untyped any variables, hard-coded regions and account IDs, provider blocks inside the module, count where for_each belongs, and insecure defaults such as public access or wildcard IAM. The target here is a module a platform team would publish to its internal registry.
Write a reusable Terraform module for that does this: Only if [CONSTRAINTS] is given: Honour these constraints:
- If the goal leaves open a decision that changes the design (single or multi-region, public or private, whether data must survive
terraform destroy), ask up to 3 questions and stop. If the gap is a detail, choose the safe default and record it under Assumptions. - Draw the boundary: one cohesive purpose. Take shared things (VPC or network IDs, KMS keys, DNS zones) as inputs instead of creating them.
- Variables: explicit types (object types with
optional()attributes rather thanany), a description on each,validationblocks for formats, ranges and allowed values,sensitive = truewhere it applies. Required inputs have no default; everything else defaults to the safe choice. - Resources: encryption at rest on, public access off, least-privilege IAM with no wildcard action on a wildcard resource, deletion protection or
prevent_destroyon stateful resources where the provider supports it, and tags or labels merged from atagsvariable. - Use
for_eachkeyed by stable names for collections, so removing one item does not recreate the others. - Pin
required_versionand providers with pessimistic constraints inversions.tf. Never put aproviderorbackendblock in the module. - Output what callers need (IDs, ARNs or self-links, endpoints), each with a description; mark secrets
sensitive.
- Use only resources and arguments that exist in the current provider. If you are unsure an argument exists in the pinned version, say so under Assumptions instead of guessing silently.
- No hard-coded account IDs, regions, CIDRs, image IDs or names. They come from variables or data sources.
- No provisioners or
local-execunless the goal cannot be met otherwise; explain why if you use one. - The code must pass
terraform fmtandterraform validate. You cannot run them here, so do not claim they pass. - Do only what was asked. If you notice something else worth changing, mention it in one line at the end instead of changing it.
- Keep the change as small as it can be while still being correct.
Assumptions
Bullets: each default you chose and why. "None" if the goal settled everything.
Files
One fenced hcl block per file, headed by its path: versions.tf, variables.tf, main.tf, outputs.tf, examples/basic/main.tf.
README
An inputs table (name, type, default, description), an outputs table, and a short usage paragraph.
Verify
The commands to run (terraform fmt -check, terraform validate, terraform plan on the example, plus a static scanner such as tflint or checkov) and what to look for in the plan.
1 required value still a placeholder; the assistant will ask for it.
details
- kind
- Prompt: a task you run by name to get one finished thing back
- domain
- Software engineering
- category
- DevOps
- level
- Intermediate
- made for
- DevOps / platform engineer, Site reliability engineer, Software engineer
- risk
- read-only
- version
- v1.0.0 · incubating
- reviewed
- 2026-10-02
- works in
- Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Antigravity, OpenCode, Windsurf, Zed, Continue, AGENTS.md, ChatGPT, claude.ai
use in
npx @hermes-hq/hodios install write-terraform-module --target claude-codenpx skills add hermes-hq/hodios-dist --skill write-terraform-module -a claude-codeclaude plugin marketplace add hermes-hq/hodios-distclaude plugin install hodios-software-engineering@hodiosThe plugin brings every entry in this domain at once.
pairs well with
All of DevOpsReview an infrastructure plan before apply
Reviews a Terraform, OpenTofu or other IaC plan for destructive changes, security exposure, cost surprises and changes outside the stated intent. Use before running apply, especially in production.
review-iac-planDesign a deployment strategy
Chooses and specifies a deployment strategy (rolling, blue-green, canary or feature-flagged) with health gates, automated rollback triggers and database-change ordering. Use when deploys feel risky.
design-deployment-strategyReview a Dockerfile
Reviews a Dockerfile for security, image size, build cache use and runtime correctness, and returns ranked findings with a corrected file. Use before shipping a new or changed container image.
review-dockerfileWrite a Docker Compose dev environment
Writes a Docker Compose local development setup that mirrors production dependencies, with health checks, named volumes, seed data, env files and a one-command start. Use when onboarding developers.
write-docker-composeWrite a GitHub Actions workflow
Writes a secure, cached and least-privilege GitHub Actions workflow that fits the repository's real build and test commands. Use when adding CI, a release job or a scheduled task.
write-github-actions-workflowDevOps engineer
Acts as a DevOps engineer who automates the second time, keeps pipelines fast and reproducible, and makes every change reversible. Use for CI/CD, infrastructure and release work.
devops-engineer