Contents

Chapter 1

What's Included

This chapter covers the core features and capabilities of the Terraform Module Registry.

What's Included

Terraform Modules (6)

ModuleDescriptionInputsOutputs
vpc-networkVPC with public/private subnets, IGW, NAT Gateway, route tables, and optional flow logs1310
s3-bucketHardened S3 bucket with versioning, encryption, lifecycle rules, and public access block114
iam-roleIAM role with trust policy, managed/inline policies, permissions boundary, instance profile115
security-groupVPC security group with dynamic ingress/egress rules and create-before-destroy lifecycle63
ecs-serviceECS Fargate service with task definition, CloudWatch logging, ALB integration, auto-scaling385
rds-instanceRDS database with subnet group, parameter group, encryption, backups, monitoring, alarms337

Each module includes:

  • main.tf β€” Resource definitions with production-ready defaults
  • variables.tf β€” Input variables with type constraints and validation blocks
  • outputs.tf β€” Output values for cross-module wiring
  • versions.tf β€” Terraform and provider version constraints
  • README.md β€” Usage examples and input/output reference tables

Registry Tool (1 script)

ScriptPurpose
scripts/registry.pyOffline 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.

Documentation (3)

DocumentContent
docs/architecture.mdRegistry design, module composition patterns, CI/CD integration
docs/usage-guide.mdStep-by-step guide to consuming modules in your projects
docs/versioning.mdSemver policy, constraint syntax, upgrade strategy

Examples (1)

ExampleContent
examples/dev-environment/Complete root module wiring vpc-network + security-group + rds-instance with terraform.tfvars

Quick Start

1. Explore Available Modules

bash
# 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 --docs

2. Try the Example Environment

bash
cd 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 apply

3. Use a Module in Your Project

hcl
module "vpc" {
  source = "./modules/vpc-network"

  name_prefix = "myapp-prod"
  vpc_cidr    = "10.0.0.0/16"

  tags = {
    Environment = "production"
  }
}

Module Selection Guide

NeedModuleWhy
Network foundationvpc-networkVPC, subnets, routing, NAT β€” the base for everything
Object storages3-bucketEncrypted, versioned, locked-down bucket
Service permissionsiam-roleLeast-privilege roles for any AWS service
Firewall rulessecurity-groupDynamic ingress/egress for any tier
Container workloadsecs-serviceFargate service with auto-scaling
Managed databaserds-instancePostgreSQL/MySQL with backups and monitoring
Chapter 2

Architecture Overview

This chapter explains the architecture and design philosophy of the Terraform Module Registry.

Architecture Overview

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    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      β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

File Structure

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

Design Principles

1. Module Isolation

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.

2. Production Defaults

Variables ship with secure, cost-effective defaults:

  • Encryption is always on (AES-256 for S3, storage encryption for RDS)
  • Public access is blocked by default (S3 public access block, RDS not publicly accessible)
  • Deletion protection defaults vary by environment intent (off for dev modules, configurable for prod)
  • Tags are propagated to all taggable resources

3. Validation at Plan Time

Every module uses Terraform's validation blocks to catch invalid inputs before

any API calls are made:

hcl
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."
  }
}

4. Offline-First Tooling

The registry.py script parses .tf files as plain text using regex and

brace-counting. It requires:

  • Python 3.10+ (stdlib only)
  • No terraform binary
  • No internet connectivity
  • No external Python packages

Requirements

  • Terraform >= 1.5.0 for module deployment
  • AWS CLI v2 with configured credentials
  • AWS Provider >= 5.0, < 6.0 (hashicorp/aws)
  • Python 3.10+ for the registry tool (stdlib only)
Chapter 3
πŸ”’ Available in full product

Cost Estimates

Chapter 4
πŸ”’ Available in full product

04_License

You’ve reached the end of the free preview

Get the full Terraform Module Registry and unlock everything.

All Chapters

Get the complete guide with every chapter unlocked, including code samples, diagrams, and best practices.

Full Tool Suite

Access all interactive tools with complete data, all workload profiles, and the full scenario library.

Source Files

Downloadable source code, configuration files, and working examples from every chapter.

Lifetime Updates

Free updates for life. Every new chapter, tool, and improvement included.

Buy Now — $49 →
πŸ“¦ Free sample included — download another copy for the full product.
Terraform Module Registry v1.0.0 β€” Free Preview