Files

Shared Terraform Modules

Purpose: Reusable Terraform modules for infrastructure provisioning Last Updated: 2025-01-27


Overview

This directory contains shared Terraform modules that can be used across all projects to ensure consistency and reduce duplication.


Module Structure

modules/
├── azure/              # Azure-specific modules
│   ├── networking/     # Virtual networks, subnets, NSGs
│   ├── kubernetes/     # AKS clusters
│   ├── keyvault/       # Key Vault with RBAC
│   ├── storage/        # Storage accounts
│   └── monitoring/     # Monitoring resources
├── kubernetes/         # Kubernetes modules (multi-cloud)
│   ├── namespace/      # Namespace creation
│   ├── ingress/        # Ingress configuration
│   └── service/        # Service configuration
└── monitoring/          # Monitoring modules
    ├── prometheus/     # Prometheus deployment
    ├── grafana/        # Grafana deployment
    └── loki/           # Loki deployment

Usage

Example: Using Azure Networking Module

module "networking" {
  source = "../../modules/azure/networking"

  resource_group_name = "rg-example"
  location           = "eastus"
  vnet_name          = "vnet-example"
  address_space      = ["10.0.0.0/16"]

  subnets = [
    {
      name           = "subnet-1"
      address_prefix = "10.0.1.0/24"
    }
  ]
}

Example: Using Kubernetes Namespace Module

module "namespace" {
  source = "../../modules/kubernetes/namespace"

  name        = "example-namespace"
  labels      = {
    environment = "production"
    project     = "example"
  }
  annotations = {}
}

Module Development Guidelines

1. Standard Structure

Each module should follow this structure:

module-name/
├── main.tf          # Main resources
├── variables.tf    # Input variables
├── outputs.tf      # Output values
├── README.md       # Module documentation
└── versions.tf     # Provider versions

2. Documentation

Each module must include:

  • Purpose and use cases
  • Input variables documentation
  • Output values documentation
  • Usage examples
  • Requirements

3. Versioning

  • Use semantic versioning (v1.0.0, v1.1.0, etc.)
  • Tag releases in git
  • Document breaking changes

Available Modules

Azure Modules

networking

Purpose: Create virtual networks, subnets, and network security groups Status: 🚧 Planned

kubernetes

Purpose: Deploy AKS clusters Status: 🚧 Planned

keyvault

Purpose: Create Key Vault with RBAC Status: 🚧 Planned

storage

Purpose: Create storage accounts and containers Status: 🚧 Planned

Kubernetes Modules

namespace

Purpose: Create Kubernetes namespaces Status: 🚧 Planned

ingress

Purpose: Configure ingress controllers Status: 🚧 Planned

Monitoring Modules

prometheus

Purpose: Deploy Prometheus Status: 🚧 Planned

grafana

Purpose: Deploy Grafana Status: 🚧 Planned


Migration Plan

See TERRAFORM_MODULES_CONSOLIDATION.md for detailed migration plan.


Last Updated: 2025-01-27