| inclusion | manual |
|---|
When creating a fully implemented OpenTofu module, follow this workflow.
- Ask: "What should this module do?" — get a description of AWS resources and behavior
- Ask for a module name (kebab-case, validate against
^[a-z][a-z0-9]*(-[a-z0-9]+)*$, no conflicts with existingmodules/dirs) - Create all 5 files in
modules/{name}/ - Run
tofu fmton the module directory - Ask if deployment wiring is needed
- Use the standard provider pinning block from opentofu.md steering
- All variables needed for the resources
- Always include
tagsvariable (map(string), default{}) - Add
validationblocks for constrained inputs (CIDRs, enums, ranges) - Use snake_case with descriptive prefixes
- Real, production-ready resource definitions (not placeholders)
- Use
thisas resource name for single-resource modules - Apply
var.tagsto ALL taggable resources usingmerge(var.tags, { Name = "..." }) - Prefer
for_eachovercountfor collections - Use
localsfor computed/derived values - Follow AWS best practices: encryption at rest, least-privilege IAM, logging where appropriate
- Meaningful outputs consumers would need (IDs, ARNs, endpoints, names)
- Include
descriptionfor every output
- Title-cased module name as heading
- Purpose description from user input
<!-- BEGIN_TF_DOCS -->/<!-- END_TF_DOCS -->markers
- Ask for target account and region (verify
live/{account}/{region}/env.hclexists) - Add module variables to
env.hcllocals (prefixed with module context) - Add module to
skip_modulemap (snake_case form, valuefalse) - Create
live/{account}/{region}/{module-name}/terragrunt.hcl:source = "../../../../modules/{name}"- Include
root.hcl - Include
env.hclwithexpose = true,merge_strategy = "no_merge" - Map inputs from
include.env.locals.* - Always pass
tags = include.env.locals.tags - Add
excludeblock referencingskip_module.{snake_case_name}
- Never use wildcard
*in IAM policy Resource fields — scope to specific ARNs - If the module creates IAM roles, always add a
permissions_boundaryvariable (optional, default null) - If creating S3 buckets, enable versioning and SSE by default
- If creating security groups, use separate
aws_security_group_ruleresources (not inline rules)