building-terraform-modules
Execute this skill empowers AI assistant to build reusable terraform modules based on user specifications. it leverages the terraform-module-builder plugin to generate production-ready, well-documented terraform module code, incorporating best practices for sec... Use when appropriate context detected. Trigger with relevant phrases based on skill purpose.
- License 许可
- MIT
- 最近更新
- 2026-05-26
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- building-terraform-modules
- author
- Jeremy Longshore <jeremy@intentsolutions.io>
- license
- MIT
- version
- 1.0.0
- description
- Execute this skill empowers AI assistant to build reusable terraform modules based on user specifications. it leverages the terraform-module-builder plugin to generate production-ready, well-documented terraform module code, incorporating best practices for sec... Use when appropriate context detected. Trigger with relevant phrases based on skill purpose.
- allowed-tools
- Read, Write, Edit, Grep, Glob, Bash(cmd:*)
- compatible-with
- claude-code, codex, openclaw
02 资源文件 4
- 资产文件assets/README.md451 B
- 资产文件assets/validation_rules.json3.6 KB
- 参考文档references/README.md68 B
- 脚本scripts/README.md507 B
03 SKILL.md 正文
Building Terraform Modules
Overview
Build reusable, production-ready Terraform modules with proper variable definitions, outputs, validation rules, documentation, and examples. Generate modules following HashiCorp's standard module structure for AWS, GCP, and Azure resources with security best practices, tagging conventions, and lifecycle management.
Prerequisites
- Terraform 1.0+ installed (
terraform version) - Cloud provider credentials configured for the target platform
- Understanding of the infrastructure resources the module will manage
- Familiarity with HCL syntax and Terraform module conventions
terraform-docsinstalled for automated documentation generation (optional)
Instructions
- Define the module scope: determine which cloud resources the module manages and its input/output contract
- Create the standard module file structure:
main.tf,variables.tf,outputs.tf,versions.tf,locals.tf - Write
versions.tfwithrequired_versionandrequired_providersblocks pinned to stable versions - Define input variables in
variables.tfwith descriptions, types, defaults, and validation rules - Implement resources in
main.tfusing variables for all configurable values; uselocalsfor computed values - Add meaningful outputs in
outputs.tffor resource IDs, ARNs, endpoints, and connection strings - Implement security defaults: encryption enabled, public access blocked, least-privilege IAM, logging enabled
- Create an
examples/directory with at least one complete usage example showing module invocation - Generate documentation with
terraform-docs markdown table . > README.md - Validate the module with
terraform init && terraform validateand test withterraform planusing the example
Output
- Module files:
main.tf,variables.tf,outputs.tf,versions.tf,locals.tf - Example usage in
examples/basic/main.tfwith realistic variable values - Auto-generated
README.mdwith inputs, outputs, and usage documentation .terraform-docs.ymlconfiguration for documentation generation- Optional: test files using Terratest or
terraform test(HCL-based)
Error Handling
| Error | Cause | Solution |
|---|---|---|
variable validation failed |
Input value does not meet validation rule | Check the validation block in variables.tf; adjust the value or the validation regex |
provider not found |
Missing or wrong provider source in versions.tf |
Add the provider to required_providers with correct source and version constraint |
circular dependency |
Resources referencing each other in a loop | Refactor to break the cycle; use depends_on or separate into sub-modules |
output references undeclared resource |
Typo in resource name or resource removed | Verify resource names in main.tf match output references exactly |
module source not found |
Incorrect module path or registry reference | Verify the source path is relative (e.g., ./modules/vpc) or a valid registry address |
Examples
- "Build a Terraform module for an AWS VPC with configurable CIDR, public/private subnets across 3 AZs, NAT gateway, and flow logs."
- "Create a GCP Cloud Run module with custom domain, IAM bindings, and auto-scaling configuration as input variables."
- "Generate a Terraform module for an S3 bucket with versioning, encryption, lifecycle rules, and access logging, with all settings as optional variables with secure defaults."
Resources
- Terraform module registry: https://registry.terraform.io/
- Module structure guide: https://developer.hashicorp.com/terraform/language/modules/develop/structure
- terraform-docs: https://terraform-docs.io/
- Module best practices: https://developer.hashicorp.com/terraform/language/modules/develop
04 同仓库更多 Skills
zustand-store-ts
Create Zustand stores with TypeScript, subscribeWithSelector middleware, and proper state/action separation. Use when building React state management, creating global stores, or implementing reactive state patterns with Zustand.
zustand-store-creator
Zustand Store Creator - Auto-activating skill for Frontend Development. Triggers on: zustand store creator, zustand store creator Part of the Frontend Development skill category.
zero-trust-config-helper
Zero Trust Config Helper - Auto-activating skill for Security Advanced. Triggers on: zero trust config helper, zero trust config helper Part of the Security Advanced skill category.
zapier-integration-helper
Zapier Integration Helper - Auto-activating skill for Business Automation. Triggers on: zapier integration helper, zapier integration helper Part of the Business Automation skill category.
zai-cli
Execute z.AI CLI providing vision, search, reader, and GitHub exploration via CLI and MCP. Use when user needs image/video analysis, OCR, UI-to-code conversion, error diagnosis, real-time web search, web page to markdown extraction, or GitHub code exploration. Trigger with phrases like "analyze this image", "search the web for", "read this page", "explore this repo", or "use zai". Requires Z_AI_API_KEY.
yt-research
Research competitor YouTube channels, niches, and trending topics for your content strategy. Use this skill whenever the user says "research channels", "analyze competitors", "find trending topics", "niche analysis", "competitive research", "what are other creators doing", "scrape YouTube channels", or wants to understand the competitive landscape for a specific tool or topic area. Use when working with yt research. Trigger with 'yt', 'research'.