Skip to content

chefgs/terraform_repo

Terraform IaC Repository – Multi-Cloud & HashiCorp Tools

A senior-engineer-level collection of Terraform Infrastructure-as-Code examples covering major cloud providers, IaC best practices, HashiCorp toolchain, and Terraform version references.

πŸ“– New here? Read the Usage Guide to get up and running fast.


Terraform Multi-Cloud Diagram


Table of Contents:

Project Status

Provider CI Status
AWS Terraform AWS Validate
Azure Terraform Azure Validate
GCP Terraform GCP Validate
DigitalOcean Terraform DigitalOcean Validate
Oracle Cloud Terraform Oracle Cloud Validate
Kubernetes Kubernetes Workflow
Security Scan Checkov Security Scan

All provider workflows run terraform init + terraform validate on push/PR to their respective directories, ensuring code is always syntactically valid without requiring cloud credentials.

Repository Structure

terraform_repo/
β”‚
β”œβ”€β”€ aws/                    # ☁️  AWS Terraform examples (EC2, EKS, CloudFront, S3, etc.)
β”œβ”€β”€ azure/                  # ☁️  Azure Terraform examples (VMs, networking)
β”œβ”€β”€ gcp/                    # ☁️  GCP Terraform examples (compute, VPC)
β”œβ”€β”€ digitalocean/           # ☁️  DigitalOcean examples (Droplets, App Platform)
β”‚   β”œβ”€β”€ create-vm/          #    └── Droplet (VM) creation
β”‚   └── app-platform/       #    └── App Platform deployment from Git repository
β”œβ”€β”€ oraclecloud/            # ☁️  Oracle Cloud examples (VCN, Compute)
β”‚   β”œβ”€β”€ create-vcn/         #    └── Virtual Cloud Network creation
β”‚   └── compute/            #    └── Full networking stack + compute instance
β”‚
β”œβ”€β”€ nvidia/                 # πŸ€–  NVIDIA – RAG application on GPU infrastructure
β”‚   β”œβ”€β”€ rag-application/    #    └── Python RAG assistant (PDF/TXT/DOCX + NVIDIA NIM)
β”‚   └── terraform/          #    └── AWS GPU EC2 + VPC + S3 + NVIDIA NGC provider stub
β”‚
β”œβ”€β”€ kubernetes/             # ⎈  Kubernetes resource management via Terraform
β”‚
β”œβ”€β”€ hashicorp-tools/        # πŸ”§  HashiCorp tool stack for 2-tier AWS app
β”‚   β”œβ”€β”€ packer/             #    └── Golden AMI builder (web & app tier)
β”‚   β”œβ”€β”€ vault/              #    └── Secrets management (dynamic creds, PKI)
β”‚   β”œβ”€β”€ consul/             #    └── Service discovery & health checks
β”‚   └── boundary/           #    └── Zero-trust access control
β”‚
β”œβ”€β”€ custom-providers/       # πŸ”¨  Custom Terraform provider development (Go)
β”‚   β”œβ”€β”€ basic/
β”‚   β”œβ”€β”€ sdk-v2/
β”‚   └── hashicups-pf/       #    └── Plugin Framework (recommended)
β”‚
β”œβ”€β”€ iac-best-practices/     # πŸ“˜  IaC best practices reference
β”‚   β”œβ”€β”€ modules/            #    └── Modular resource creation patterns
β”‚   β”œβ”€β”€ variables/          #    └── Variable templatization & locals
β”‚   β”œβ”€β”€ testing/            #    └── Terraform native tests (.tftest.hcl)
β”‚   └── lock-file-management/ #  └── Lock file strategy & multi-platform
β”‚
β”œβ”€β”€ terraform-versions/     # πŸ“‹  Version history & feature reference (v1.0–v1.14)
β”‚
β”œβ”€β”€ tfc-getting-started/    # 🏒  Terraform Cloud – getting started (pinned at root)
β”œβ”€β”€ tfcloud_samples/        # 🏒  Terraform Cloud workflows & best practices (pinned at root)
β”‚
└── docs/                   # πŸ“š  Documentation site (GitHub Pages / Jekyll)

Information about this project

  • Idea for this open source repository is to collate the Terraform Resource Creation code for Major Cloud Providers, categorised by cloud provider, IaC concepts, and HashiCorp tools
  • Includes examples for AWS, Azure, GCP, DigitalOcean, and Oracle Cloud Infrastructure
  • Features a NVIDIA RAG application example β€” a Python document assistant powered by NVIDIA NIM LLM endpoints, deployed on AWS GPU infrastructure with full Terraform IaC (including a stubbed NVIDIA NGC provider)
  • Demonstrates Terraform best practices: modular design, variable templatization, native testing, and lock file management
  • Contains HashiCorp full-stack examples: Packer + Vault + Consul + Boundary for a production 2-tier AWS application
  • Provides a Terraform version reference guide (v1.0–v1.14, latest: v1.14.7 Mar 2026) with code examples for every major release
  • Also has sample code for How to develop Terraform Custom Provider
  • Feel free to explore the repo content, and add ⭐ or fork if you like the content
  • Repo is open for contributions and if you want to contribute please read the important notice for contribution guidelines

Provider Summaries

NVIDIA RAG Application Highlight

The nvidia/ directory provides a self-contained example of deploying a Retrieval-Augmented Generation (RAG) document assistant on NVIDIA GPU infrastructure:

Component Description
Python RAG App Interactive CLI that loads PDF, TXT, or DOCX files and answers questions using NVIDIA NIM LLMs
NVIDIA NIM Inference microservices for LLM (meta/llama-3.1-8b-instruct) and embeddings (nv-embedqa-e5-v5)
FAISS Vector Store Local CPU/GPU vector index for fast similarity search
Terraform IaC AWS VPC + GPU EC2 instance (g4dn.xlarge) + S3 bucket + IAM β€” all managed via Terraform
NVIDIA NGC Provider Commented stub blocks ready to activate for NGC registry and NIM endpoint management
# Run the RAG assistant locally
export NVIDIA_API_KEY="nvapi-..."
python nvidia/rag-application/app/main.py --file my-document.pdf
# Deploy the GPU infrastructure to AWS
cd nvidia/terraform && terraform init && terraform apply

AWS Examples

The aws/ directory contains a wide range of Amazon Web Services infrastructure examples:

Directory Description
create-ec2/ Simple EC2 instance creation
web-tier/ Web tier with VPC, subnets, and security groups
web-tier-samples/ Additional web tier variations
cloudfront/ CloudFront CDN distribution
s3-dynamodb/ S3 + DynamoDB remote state backend pattern
eks-samples/ EKS cluster (self-managed & Fargate)
eks-module-demo/ EKS using the official AWS module
ec2-with-modules/ EC2 with reusable modules pattern
elasticsearch/ Elasticsearch / OpenSearch deployment
iac-101/ IaC fundamentals with AWS
# Example: deploy a simple EC2 instance
export AWS_DEFAULT_REGION="us-east-1"
cd aws/create-ec2/
terraform init && terraform apply

Azure Examples

The azure/ directory contains Microsoft Azure infrastructure examples:

Directory Description
create-vm/ Create an Azure Virtual Machine with configurable size and networking
# Authenticate with Azure CLI
az login
cd azure/create-vm/
terraform init && terraform apply

GCP Examples

The gcp/ directory contains Google Cloud Platform infrastructure examples:

Directory Description
resources/ GCP resource creation β€” VPC, compute instances, and storage
# Authenticate with GCP
gcloud auth application-default login
cd gcp/resources/
terraform init && terraform apply

Kubernetes Examples

The kubernetes/ directory demonstrates managing Kubernetes resources with Terraform using the Kubernetes provider:

File / Resource Description
kubernetes_namespace Create and label a Kubernetes namespace
kubernetes_resource_quota Enforce namespace-wide CPU, memory, and pod limits
kubernetes_limit_range Set default resource requests/limits for containers
kubernetes_deployment Deploy a containerized app with health checks and security context
kubernetes_service Expose the deployment as a ClusterIP service
# Prerequisites: running cluster with kubeconfig configured (e.g., Minikube)
cd kubernetes/
terraform init && terraform apply
kubectl get ns && kubectl get deployment -n <namespace>

DigitalOcean Examples

The digitalocean/ directory contains two examples:

Directory Description
create-vm/ Create a DigitalOcean Droplet (VM) with configurable size, region, and OS image
app-platform/ Deploy an application from a Git repository using App Platform, with project-level Git variable support for secret injection
# Deploy the App Platform example
export TF_VAR_do_token="dop_v1_..."
cd digitalocean/app-platform/
cp terraform.tfvars.example terraform.tfvars
terraform init && terraform apply

Oracle Cloud Infrastructure Examples

The oraclecloud/ directory contains two examples:

Directory Description
create-vcn/ Create an OCI Virtual Cloud Network (VCN) with subnets and routing
compute/ Full free-tier infrastructure stack β€” VCN, internet gateway, route table, security list, and a flexible compute instance (VM.Standard.E4.Flex)
# Deploy the OCI compute example
oci setup config          # configure OCI CLI and API key
cd oraclecloud/compute/
cp terraform.tfvars.example terraform.tfvars
terraform init && terraform apply
terraform output ssh_command   # get the ready-to-use SSH command

πŸ”§ HashiCorp Tools Examples

The hashicorp-tools/ directory demonstrates the full HashiCorp stack for a production 2-tier AWS application:

Directory Description
terraform/ Core AWS infrastructure β€” VPC, ALB, Auto Scaling Groups, and RDS PostgreSQL
packer/ Golden AMI builder for web and app tiers
vault/ Secrets management β€” dynamic credentials, PKI certificates, DB credentials
consul/ Service discovery, health checks, and KV store
boundary/ Zero-trust access control to private resources
# Deploy in order: Packer β†’ Terraform β†’ Vault β†’ Consul β†’ Boundary
cd hashicorp-tools/packer/ && packer build web-tier.pkr.hcl
cd ../terraform/           && terraform init && terraform apply

πŸ”¨ Custom Terraform Providers

The custom-providers/ directory contains examples for developing custom Terraform providers in Go:

Directory Description
basic/ Basic custom provider using the original SDK style
sdk-v2/ Provider using Terraform Plugin SDK v2
hashicups-pf/ HashiCups provider using the Terraform Plugin Framework (recommended)
example-provider/ Production-quality example provider with tests and documentation
# Build and test the Plugin Framework example
cd custom-providers/hashicups-pf/
go mod download
make build && make test

πŸ“˜ IaC Best Practices

The iac-best-practices/ directory is a reference collection covering key Terraform engineering patterns:

Directory Topic
modules/ Modular, reusable, and composable resource creation patterns
variables/ Variable templatization β€” types, validation blocks, and locals
testing/ Terraform native tests using .tftest.hcl (requires Terraform v1.6+)
lock-file-management/ Lock file strategy and multi-platform provider locking

🏒 Terraform Cloud Examples

The repository includes two Terraform Cloud directories pinned at the root:

Directory Description
tfc-getting-started/ Introductory example for connecting a local configuration to a Terraform Cloud workspace
tfcloud_samples/ Terraform Cloud workflow patterns β€” remote runs, variable sets, and workspace best practices
# Authenticate with Terraform Cloud
terraform login
cd tfc-getting-started/
terraform init && terraform apply

Read before you start contributing to this repo

  • Read Contribution Guidelines before contributing to this repository!

  • Read GitHub Code Of Conduct guidelinesbefore contributing to this repository!

  • Feel free to pick up any of the open Issues or create new issue using the template!

  • This repo also has GitHub action Terraform AWS workflow to check the Terraform AWS resource code is valid and works fine. Please utilize it for checking the terraform code you're creating. All you've to do is,

    • Open Workflow in "Actions" Tab
    • Click on Run Workflow
    • Choose you branch_name and Enter your tf file path on which you want to run the workflow
    • Check if the workflow is passing or not. Fix the issue in case of failure.

Good to Have: Create documentation to list down resources/modules/providers/output

  • Please install terraform-docs CLI utility to generate documentation for Terraform Code.
  • After installing the utility, please run the below command to create markdown document
terraform-docs markdown table --output-file TF_README.md --output-mode inject <your-terraform-code-directory>
  • Please use below command for generating docs recursively for all the Terraform code modules
~/go/bin/terraform-docs markdown table --output-file TF_README.md --recursive --recursive-path "<terraform-code-module-path>" --output-mode inject .

Note:

I've renamed the default branch from master to main. So If you've cloned my repo locally, then please follow the steps mentioned in this document to rename your local repo from master to main

  • Feel free to browse through the branch and post any questions to me.
  • LinkedIn - Saravanan Gnanaguru

πŸ’» Happy contributing to the Community!!

Repo contributors profile link