terraform-module-patterns_skill

This skill helps you design reusable Terraform modules with validation, outputs, composition, and Terratest testing for reliable infrastructure.
  • Python

5

GitHub Stars

2

Bundled Files

2 months ago

Catalog Refreshed

4 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstrat where the catalogue uses aiagentskills.

npx veilstrat add skill williamzujkowski/cognitive-toolworks --skill terraform-module-patterns

  • CHANGELOG.md816 B
  • SKILL.md10.3 KB

Overview

This skill guides design and delivery of reusable Terraform modules with strong variable validation, explicit output schemas, clear composition patterns, and automated testing using Terratest. It focuses on practical structure, registry-ready publishing, and CI/CD integration to ensure reliable, maintainable modules.

How this skill works

It inspects module requirements and enforces pre-checks such as Terraform version, module_type and provider capabilities, then generates a canonical module layout (main.tf, variables.tf, outputs.tf, versions.tf, examples, tests). It produces validated variable declarations, documented outputs, example usage, Terratest Go tests, and CI pipeline recommendations for linting, security scanning, testing, and release.

When to use it

  • When building a reusable module for network, compute, database, or composite infrastructure
  • When you need strict input validation and clear output contracts
  • When modules will be composed or used by other teams
  • When automated integration testing with Terratest is required
  • When preparing to publish a module to the Terraform Registry

Best practices

  • Use explicit type constraints and validation blocks for all required variables; include description and sensible defaults
  • Group related inputs into object types when many required variables exist
  • Document every output with description and mark sensitive outputs as sensitive = true
  • Break large modules into child modules if creating many resources; prefer composition and dependency injection
  • Include runnable examples (basic, complete, composition) and keep examples self-contained
  • Add CI stages for fmt/validate, security scanning (tfsec/checkov), Terratest execution, docs generation, and release tagging

Example use cases

  • AWS VPC module with CIDR validation and subnet_count limits
  • Reusable compute module that accepts instance configuration as an object and outputs instance_details
  • Composite stack composed of network and database child modules with dependency injection of network IDs
  • Terratest suite validating variable validation errors and successful deploy/destroy cycles
  • Publishing a provider-specific module to the Terraform Registry with semantic tags and README tables

FAQ

Use Terraform >= 1.0; recommended required_version = ">= 1.5" to use recent validation features.

How many tests are required?

Aim for at least three Terratest scenarios: minimal, complete, and error/validation cases to cover happy and failure paths.

When should I split into child modules?

If the module creates more than ~10 resources or has complex divergent responsibilities, break into child modules for reuse and maintainability.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational
terraform-module-patterns skill by williamzujkowski/cognitive-toolworks | VeilStrat