This chapter covers the core features and capabilities of the Terraform Module Registry.
| Module | Description | Inputs | Outputs |
|---|---|---|---|
vpc-network | VPC with public/private subnets, IGW, NAT Gateway, route tables, and optional flow logs | 13 | 10 |
s3-bucket | Hardened S3 bucket with versioning, encryption, lifecycle rules, and public access block | 11 | 4 |
iam-role | IAM role with trust policy, managed/inline policies, permissions boundary, instance profile | 11 | 5 |
security-group | VPC security group with dynamic ingress/egress rules and create-before-destroy lifecycle | 6 | 3 |
ecs-service | ECS Fargate service with task definition, CloudWatch logging, ALB integration, auto-scaling | 38 | 5 |
rds-instance | RDS database with subnet group, parameter group, encryption, backups, monitoring, alarms | 33 | 7 |
Each module includes:
main.tf β Resource definitions with production-ready defaultsvariables.tf β Input variables with type constraints and validation blocksoutputs.tf β Output values for cross-module wiringversions.tf β Terraform and provider version constraintsREADME.md β Usage examples and input/output reference tables| Script | Purpose |
|---|---|
scripts/registry.py | Offline CLI tool that scans modules, builds a registry.json index, and generates Markdown documentation |
The registry tool is Python 3.10+ stdlib-only β no external dependencies, no terraform binary required.
| Document | Content |
|---|---|
docs/architecture.md | Registry design, module composition patterns, CI/CD integration |
docs/usage-guide.md | Step-by-step guide to consuming modules in your projects |
docs/versioning.md | Semver policy, constraint syntax, upgrade strategy |
| Example | Content |
|---|---|
examples/dev-environment/ | Complete root module wiring vpc-network + security-group + rds-instance with terraform.tfvars |
# Scan all modules and see a summary
python3 scripts/registry.py --scan
# Build the registry index
python3 scripts/registry.py --scan --index
# Generate full Markdown documentation
python3 scripts/registry.py --scan --docscd examples/dev-environment
# Set the database password
export TF_VAR_db_password="your-secure-password"
# Initialize Terraform
terraform init
# Preview the infrastructure
terraform plan
# Deploy (when ready)
terraform applymodule "vpc" {
source = "./modules/vpc-network"
name_prefix = "myapp-prod"
vpc_cidr = "10.0.0.0/16"
tags = {
Environment = "production"
}
}| Need | Module | Why |
|---|---|---|
| Network foundation | vpc-network | VPC, subnets, routing, NAT β the base for everything |
| Object storage | s3-bucket | Encrypted, versioned, locked-down bucket |
| Service permissions | iam-role | Least-privilege roles for any AWS service |
| Firewall rules | security-group | Dynamic ingress/egress for any tier |
| Container workloads | ecs-service | Fargate service with auto-scaling |
| Managed database | rds-instance | PostgreSQL/MySQL with backups and monitoring |
This chapter explains the architecture and design philosophy of the Terraform Module Registry.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Terraform Module Registry β
β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Registry Tool (Python) β β
β β β β
β β registry.py βββΊ Scan βββΊ Parse βββΊ Index/Docs β β
β β β β
β β Input: modules/*.tf files β β
β β Output: registry.json, Markdown tables β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Module Collection β β
β β β β
β β βββββββββββββββ βββββββββββββββ βββββββββββββββ β β
β β β vpc-network β β s3-bucket β β iam-role β β β
β β β β β β β β β β
β β β VPC+Subnets β β Encrypted β β Trust+Pol. β β β
β β β IGW+NAT β β Versioned β β Inst.Prof. β β β
β β β Flow Logs β β Lifecycle β β Boundaries β β β
β β βββββββββββββββ βββββββββββββββ βββββββββββββββ β β
β β β β
β β βββββββββββββββ βββββββββββββββ βββββββββββββββ β β
β β βsecurity-grp β β ecs-service β βrds-instance β β β
β β β β β β β β β β
β β β Ingress/Eg. β β Fargate β β Multi-AZ β β β
β β β CIDR+SG ref β β AutoScale β β Encryption β β β
β β β Lifecycle β β CircuitBrk β β Monitoring β β β
β β βββββββββββββββ βββββββββββββββ βββββββββββββββ β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Example Compositions β β
β β β β
β β dev-environment/main.tf β β
β β Wires: vpc-network + security-group + rds-instance β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
terraform-module-registry/
βββ README.md # Product overview and quick start
βββ LICENSE # MIT License
β
βββ modules/ # Terraform module collection
β βββ vpc-network/ # VPC with subnets, IGW, NAT
β β βββ main.tf
β β βββ variables.tf
β β βββ outputs.tf
β β βββ versions.tf
β β βββ README.md
β βββ s3-bucket/ # Hardened S3 bucket
β β βββ (same structure)
β βββ iam-role/ # IAM role with policies
β β βββ (same structure)
β βββ security-group/ # VPC security group
β β βββ (same structure)
β βββ ecs-service/ # ECS Fargate service
β β βββ (same structure)
β βββ rds-instance/ # Managed RDS database
β βββ (same structure)
β
βββ scripts/ # Registry tooling
β βββ registry.py # Module scanner, indexer, docs generator
β
βββ examples/ # Example compositions
β βββ dev-environment/
β βββ main.tf # Root module wiring 3 modules
β βββ terraform.tfvars # Example variable values
β
βββ docs/ # Deep-dive documentation
β βββ architecture.md # Registry design and composition patterns
β βββ usage-guide.md # How to consume modules
β βββ versioning.md # Version and constraint policy
β
βββ guide/ # Product guide chapters
βββ 01_what-s-included.md
βββ 02_architecture-overview.md
βββ 03_cost-estimates.md
βββ 04_license.md
Each module is fully self-contained. It declares its own provider requirements,
validates its own inputs, and exposes a clean output interface. Modules never
reference each other internally β all composition happens in the consuming root
module.
Variables ship with secure, cost-effective defaults:
Every module uses Terraform's validation blocks to catch invalid inputs before
any API calls are made:
variable "vpc_cidr" {
type = string
default = "10.0.0.0/16"
validation {
condition = can(cidrhost(var.vpc_cidr, 0))
error_message = "vpc_cidr must be a valid CIDR block."
}
}The registry.py script parses .tf files as plain text using regex and
brace-counting. It requires:
terraform binaryGet the full Terraform Module Registry and unlock everything.
Get the complete guide with every chapter unlocked, including code samples, diagrams, and best practices.
Access all interactive tools with complete data, all workload profiles, and the full scenario library.
Downloadable source code, configuration files, and working examples from every chapter.
Free updates for life. Every new chapter, tool, and improvement included.