Module Structure
Learn how Patterned Designs modules are organized and structured.
This page explains the standard structure and organization of Patterned Designs modules.
File Layout
Every module follows a consistent file structure:
module-name/
├── main.tf # Core resources
├── variables.tf # Input variables
├── outputs.tf # Output values
├── versions.tf # Provider version constraints
├── data.tf # Data sources (if needed)
├── locals.tf # Local values (if needed)
└── examples/
├── simple/ # Minimal usage example
└── complete/ # Full-featured example
Input Variables
Variables follow these conventions:
- Explicit types - Always declared with a type constraint
- Safe defaults - Sensible defaults where possible
- Validation - Input validation for allowed values
- Documentation - Clear descriptions for each variable
variable "name" {
type = string
description = "Name for the resource"
}
variable "enable_logging" {
type = bool
default = true
description = "Enable CloudWatch logging"
}
Outputs
Outputs expose only what consumers need:
- Resource IDs and ARNs
- Computed values
- Connection information
output "id" {
value = aws_resource.main.id
description = "The resource ID"
}
Examples
Each module includes at least two examples:
- Simple - Minimal configuration with defaults
- Complete - Full configuration showing all options
Next Steps
- Versioning - Understand version management
- Browse Modules - Explore available modules