GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com β€” GitHub - matthew-dresden/terraform-modules: Reusable AWS Terraform module library

BranchesTags
Open more actions menu

Latest commit

 

History

183 Commits
183 Commits

Folders and files

NameName
Last commit message
Last commit date
.devcontainer
.devcontainer
 
 
.github
.github
 
 
aws-nuke-config
aws-nuke-config
 
 
docs
docs
 
 
generics
generics
 
 
policies/opa
policies/opa
 
 
providers
providers
 
 
scripts
scripts
 
 
security-scripts
security-scripts
 
 
skeletons/generic-skeleton
skeletons/generic-skeleton
 
 
tests/opa
tests/opa
 
 
.gitignore
.gitignore
 
 
.pre-commit-config.yaml
.pre-commit-config.yaml
 
 
.tool-versions
.tool-versions
 
 
CHANGELOG.md
CHANGELOG.md
 
 
LICENSE
LICENSE
 
 
Makefile
Makefile
 
 
README.md
README.md
 
 
VERSION
VERSION
 
 
monorepo-config.json
monorepo-config.json
 
 
pyproject.toml
pyproject.toml
 
 
requirements.txt
requirements.txt
 
 

Repository files navigation

Terraform Modules Monorepo

πŸš€ Welcome to the Caylent Terraform Module Hub

Your one-stop shop for production-grade, security-hardened, and fully tested Terraform modulesβ€”purpose-built for AWS and the modern cloud.


πŸ‘₯ Who This Repo Is For

Whether you're a platform engineer, DevOps specialist, cloud architect, or developer β€” this repo is built to help you:

  • πŸš€ Deliver faster: Instantly adopt proven modules for AWS and common integrations like GitHub, and more to come.
  • πŸ” Ship with confidence: Every module is policy-enforced, security-audited, and functionally tested.
  • πŸ”Œ Integrate seamlessly: Built for AWS-first platforms, but extensible to broader cloud-native and SaaS ecosystems.
  • ⚑ Start fast: Browse, copy, and apply modules with minimal setup. See Getting Started to dive in.

Most users simply consume modulesβ€”no customization required.


Ready to move? Jump to Getting Started or explore the Module Types.


πŸ“¦ How to Use: Sourcing & Importing Modules

To use any module from this repo, reference it directly in your Terraform configuration using the Git source and a version tag:

module "generic_skeleton" {
  source = "git::https://github.com/caylent-solutions/terraform-modules.git//skeletons/generic-skeleton?ref=skeletons/generic-skeleton/v1.0.0"
  # ...module inputs...
}
  • Replace the module path (skeletons/generic-skeleton) with the one you need.
  • Replace the version (v1.0.0) with the exact tag to pin the module version.
    ⚠️ Pinning is required β€” Terraform’s git source does not support version ranges.

Coming Soon: Caylent Public Terraform Registry

You’ll soon be able to consume modules directly via a public Caylent registry:

  • Native support for version constraints (e.g., ~> 1.2)
  • No authentication required
  • Backed by this GitHub repo
  • Fully audited, tested, and production-ready modules

Stay tuned for release announcements.


πŸ“‹ Table of Contents

  • Who This Repo Is For
  • How to Use: Sourcing & Importing Modules
  • Coming Soon: Caylent Public Terraform Registry
  • Repository Structure
  • Governance
  • Security
  • Repository Principles and Strategy
  • Module Types
  • Terraform Provider Strategy
  • Module Structure
  • Testing Requirements
  • Configuration
  • Getting Started
  • Workflow Development and Testing
  • Repository Health Checks
  • CI/CD Workflows Overview
  • Contribution Process
  • Documentation

🧱 Repository Structure

A clear, logical structure for all modules and supporting files:

.
β”œβ”€β”€ generics
β”‚   └── utilities/            # Terraform modules
β”œβ”€β”€ providers
β”‚   β”œβ”€β”€ aws/
β”‚   β”‚   β”œβ”€β”€ collections/      # Terraform modules
β”‚   β”‚   β”œβ”€β”€ primitives/       # Terraform modules
β”‚   β”‚   └── references/       # Terraform modules
β”‚   └── github/
β”‚       β”œβ”€β”€ collections/      # Terraform modules
β”‚       β”œβ”€β”€ primitives/       # Terraform modules
β”‚       └── references/       # Terraform modules
└── skeletons                 # Terraform modules
    └── generic-skeleton/

πŸ” Governance

This repository implements governance policies to ensure consistent and maintainable code:

  1. Single Module Policy: PRs must change only one Terraform module at a time
  2. Separation Policy: PRs must either modify exactly one module OR only non-module files (not both)
  3. Empty PR Policy: PRs must contain at least one file change
  4. Module Type Policies: Each module type has specific content requirements
  5. Module Structure Policies: All modules must follow a standardized structure
  6. File Organization Policies: Terraform declarations must be in specific files

These policies are enforced using Open Policy Agent (OPA) in the CI/CD pipeline.

Security

This repository implements comprehensive security controls:

  1. GitHub Actions Security: All third-party actions are SHA-pinned to prevent supply chain attacks
  2. External Contributor Protection: External contributors cannot modify workflow files
  3. Automated Security Scanning: CodeQL analysis runs on all pull requests
  4. Terraform Security Scanning: tfsec scans every Terraform module change for security issues
  5. Environment Isolation: External contributor tests run in protected environments
  6. Manual Approval Gates: Multiple approval points ensure code quality and security
  7. Action Allowlist: Only pre-approved GitHub Actions can be used in workflows

Security is managed through automated scripts in the security-scripts/ directory. Use make github-actions-security to update action allowlists.

🧭 Repository Principles and Strategy

This monorepo is governed by the following principles, which guide all module and service development:

Self-Contained Repository Deployment Principle

Each module or service in this monorepo is designed to be self-contained, including everything necessary to deploy, test, and validate itself in isolation. This ensures autonomy, reproducibility, and a complete SDLC for every module. See Self-Contained Repository Deployment Principle for details.

Single Purpose Repository Principle

Every module or service is focused on a single responsibility, producing a single, environment-agnostic artifact or service. This aligns with the Single Responsibility Principle and supports modular, maintainable, and scalable infrastructure. See Single Purpose Repository Principle for details.

Terraform Module Strategy

  • All cloud, SaaS, and stateful resources are managed via Terraform modules in this monorepo.
  • Module types include: Primitive, Utility, Reference, and Client Wrapper modules (see below).
  • Modules must be client- and application-agnostic unless explicitly a client wrapper.
  • All modules must be created using the latest skeleton and follow all OPA policies, structure, and testing requirements defined in this repo.
  • All modules must be semantically versioned and released via CI/CD.
  • Use official Terraform providers unless a fork is required for missing features/bugfixes (see CONTRIBUTING.md for provider forking strategy).

Terragrunt Usage

Terragrunt may be used in downstream consumer repositories to orchestrate deployments of modules from this monorepo. However, all Terraform code and module logic must reside in this repo, and Terragrunt HCL should only be used for orchestration, not for defining resource logic.

🧱 Module Types

This repository supports several types of Terraform modules, each with a specific purpose and scope:

  1. Primitive Modules:
    • Manages a single major resource type from a provider (e.g., S3, ECS, EC2).
    • These modules are the most complex and where most raw development occurs.
  2. Utility Modules:
    • Adds opinionated functionality (e.g., naming/tagging) or provides data-only structures (such as resource naming constraints for every AWS resource).
  3. Collection Modules:
    • A composition of primitive modules and/or other collection modules.
    • They provide an opinionated, specialized set of resources to support a use case (e.g., EKS cluster integrated with SumoLogic or Datadog).
    • They do not provide a full reference architecture.
  4. Reference Modules:
    • Provides a fully baked, production-ready service that is secure, observable, follows best practices, and modern architecture patterns.
  5. Client Wrapper Modules:
    • Client-specific wrapper that imports reference modules and adds custom logic. Must live in the client’s repo and follow the same structure/testing standards.

All modules must:

  • Use the latest skeleton
  • Pass all OPA policies and CI/CD checks
  • Be fully tested (rego and Terratest)
  • Be semantically versioned and released via CI/CD
  • Use Apache 2.0 license unless client-specific

πŸ“¦ Terraform Provider Strategy

  • Always use the latest stable official provider for all resources.
  • If a required feature/bugfix is missing, fork the provider, follow best practices for forking, and upstream changes when possible. See CONTRIBUTING.md for the full provider forking workflow.

πŸ“ Module Structure

All modules must follow a standardized structure:

  • Required files in the root directory (main.tf, variables.tf, etc.)
  • Examples directory with at least one example implementation
  • Tests directory with corresponding test directories for each example
  • Documentation in README.md and TERRAFORM-DOCS.md

See Module Structure and Module Policies for detailed requirements.

πŸ§ͺ Testing Requirements

All modules must include comprehensive functional tests using the Terraform Terratest Framework:

  • Tests for each example implementation
  • Common tests that verify basic functionality
  • Tests that validate the module's core features
  • Tests that ensure inputs are properly processed

See Module Testing for detailed testing requirements and examples.

Configuration

Monorepo Configuration

All monorepo automation is configured through a single centralized file:

monorepo-config.json

This file defines module types, path patterns, policy directories, and other configuration used by all automation scripts. See Monorepo Configuration for details.

Module Automation with CPM

Individual Terraform modules use the Caylent Package Manager (CPM) for standardized automation tasks. CPM provides:

  • Versioned Automation: Pin exact versions of testing, linting, and validation tasks
  • Consistent Tooling: Same automation across all modules without code duplication
  • Single Source of Truth: Centralized Make targets managed via the cpm-terraform-modules-monorepo package
  • Ephemeral Dependencies: All CPM packages are synced to .packages/ and .repo/ (git-ignored, never committed)

Each module contains:

  • Makefile - CPM orchestration with cpm-configure target (static, rarely changes)
  • .cpmenv - CPM configuration (versions, URLs, settings)

How it works:

  1. The base CPM Makefile provides the cpm-configure target
  2. Running make cpm-configure syncs the cpm-terraform-modules-monorepo package to .packages/
  3. This package provides all module automation tasks (test, lint, format, docs, security)
  4. Tasks are only available after make cpm-configure has been run

See CPM Documentation for complete details on how CPM works.

πŸš€ Getting Started

Follow these steps to get up and running as a contributor or consumer:

Prerequisites

This repository uses ASDF v0.15.0 to manage tool versions:

# Install required tools for the monorepo
make install-tools

Development Workflow

  1. Clone the repository
  2. Install required tools: make install-tools
  3. Configure the environment: make configure
  4. Create a new module from the skeleton: cp -r skeletons/generic-skeleton your/new/module
  5. Enter your module directory and configure CPM: cd your/new/module && make cpm-configure
    • This syncs the automation package to .packages/ and makes CPM tasks available
  6. Install module dependencies: make install
    • This installs Go modules and the tftest CLI tool
  7. Implement your module following the structure requirements
  8. Use CPM-provided automation tasks (from the module directory):
    • make test - Run all Terratest tests
    • make test-common - Run common tests only
    • make tf-format - Check Terraform formatting
    • make tf-lint - Lint Terraform files
    • make tf-docs - Generate documentation
    • make tf-security - Run security scans
    • make go-lint - Lint Go test files
    • make go-format - Format Go test files
    • make clean - Clean Terraform state
  9. Validate your module from repo root:
    • make module-validate MODULE_PATH=your/new/module MODULE_TYPE=module_type
  10. Test all non-Terraform code: make test-all-non-tf-module-code (from repo root)
  11. Submit a PR

Note: Module automation tasks are provided by the cpm-terraform-modules-monorepo package and are only available after running make cpm-configure followed by make install. The base CPM Makefile only provides cpm-configure and related CPM management targets.

πŸ§ͺ Workflow Development and Testing

For developers working on the main validation workflow (.github/workflows/main-validation.yml):

# Test all 6 merge approval job variations in dry run mode
make test-main-validation-workflow

This comprehensive test triggers all possible merge approval scenarios to validate workflow changes before deployment. See Main Validation Script Documentation for details.

βœ… Repository Health Checks

For repository maintainers, a comprehensive test suite is available to validate all Terraform modules:

# Test all Terraform modules (runs weekly via GitHub Actions)
make test-all-terraform-modules

This task runs the full validation suite (documentation, formatting, linting, OPA policies, planning, security, and tests) across all modules in parallel. It's designed for CI/CD use and not required for regular development.

For detailed contribution guidelines, see docs/CONTRIBUTING.md.

πŸ” CI/CD Workflows Overview

This repository uses a multi-stage, automated CI/CD pipeline to ensure code quality, security, and compliance for all contributions. The workflows support both production and dry run (safe testing) modes.

Main Workflows

  • PR Validation (pr-validation.yml): Entry point for all pull requests. Detects contributor type (internal/external), enforces workflow file protection, and routes PRs to the correct validation workflow based on whether Terraform modules or non-Terraform code are changed.
  • Main Validation (main-validation.yml): Core workflow for PR approval, merge decisions, and release orchestration. Handles both Terraform and non-Terraform changes, supports dry run mode, and manages merge approval routing.
  • Release (release.yml): Handles both Terraform and non-Terraform releases. Uses custom logic for module versioning and python-semantic-release for non-Terraform code. Automates changelog generation and tagging.
  • CodeQL Analysis (codeql-analysis.yml): Runs automated security scanning on all pushes and PRs.
  • Weekly Module Health Check (weekly-module-health-check.yml): Runs comprehensive tests on all Terraform modules weekly and on demand.

Security Features

  • Workflow File Protection: External contributors cannot modify workflow files. Internal contributors must follow the SDLC process for workflow changes.
  • Automated Security Scanning: CodeQL analysis runs on all PRs and pushes.
  • Manual Approval Gates: Maintainers must approve PRs and test execution for external contributors.
  • Environment Isolation: Tests for external contributors run in protected environments.
  • Action Allowlist: Only SHA-pinned, pre-approved GitHub Actions are permitted.

Pull Request Flow

  1. Security Check: Validates contributor type and workflow file changes.
  2. Change Detection: Determines if the PR changes a Terraform module or only non-module files.
  3. Validation: Runs comprehensive policy, linting, formatting, documentation, and security checks.
  4. Testing: Executes full test suite (automatic for internal, manual approval for external contributors).
  5. Approval & Merge: Maintainers review and approve. PRs are auto-merged after approval (never merge manually).
  6. Release: Automated versioning (based on PR title) and changelog for both Terraform and non-Terraform code.

See Workflow Logic and Main Validation SDLC Guide for full details.

πŸ§‘β€πŸ’» Contribution Process

For Terraform Code

  • Follow module structure requirements and module policies.
  • Implement comprehensive tests using Terraform Terratest Framework.
  • Validate and test locally before submitting a PR.
  • Format your PR title with conventional commit prefix (feat:, fix:, etc.) - this determines the version bump.
  • Never manually merge PRs - the pipeline automatically merges after approval.
  • Automated validation, testing, and release via CI/CD.

For Non-Terraform Code

  • Linting, tests, and policy checks as appropriate.
  • Format your PR title with conventional commit prefix (feat:, fix:, etc.) - this determines the version bump.
  • Never manually merge PRs - the pipeline automatically merges after approval.
  • Uses python-semantic-release for versioning and changelog.
  • Automated validation and release via CI/CD.

Internal vs External Contributors

  • Internal: Direct branch, push, and PR workflow. Tests run automatically.
  • External: Fork, branch, PR workflow. Cannot modify workflows. Tests require manual approval.

See docs/CONTRIBUTING.md for detailed instructions.

πŸ“š Documentation

Contributor Guides

  • Contributing Guidelines - How to contribute and SDLC process
  • PR Title-Based Versioning - How PR titles determine version bumps
  • Workflow Logic Documentation - Detailed CI/CD flow explanation
  • Main Validation SDLC Guide - SDLC process for workflow maintenance
  • AWS Authentication Integration - How AWS authentication works with GitHub Actions for module testing

Technical Documentation

  • Terraform Module Structure
  • Terraform Module Policies
  • Terraform Module Testing
  • Module Validation
  • Monorepo Configuration

Scripts Documentation

  • Scripts Documentation Index - Complete index of all scripts
  • GitHub Actions Security Scripts - Secure GitHub Actions management
  • Detect Proposed Git Repo Changes
  • Go Format
  • Go Lint
  • Go Unit Test
  • Install Tools
  • Main Validation - End-to-end workflow testing
  • Module Type Validator
  • Module Validator
  • Rego Unit Test
  • Terraform File Collector

About

Reusable AWS Terraform module library

Resources

Readme
Apache-2.0 license

Contributing

Contributing
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 β€” GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800Γ—600. No cookies required.