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.
Table of Contents:
- Usage Guide β Start here
- Project Status
- Repository Structure
- Information About This Project
- Provider Summaries
- Contributing Guidelines
- Documentation
- License
| Provider | CI Status |
|---|---|
| AWS | |
| Azure | |
| GCP | |
| DigitalOcean | |
| Oracle Cloud | |
| Kubernetes | |
| Security Scan |
All provider workflows run
terraform init+terraform validateon push/PR to their respective directories, ensuring code is always syntactically valid without requiring cloud credentials.
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)
- 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
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 applyThe 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 applyThe 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 applyThe 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 applyThe 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>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 applyThe 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 commandThe 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 applyThe 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 testThe 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 |
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 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_nameand Enter yourtf file pathon which you want to run the workflow - Check if the workflow is passing or not. Fix the issue in case of failure.
- Please install
terraform-docsCLI 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 .
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
π» Happy contributing to the Community!!
Repo contributors profile link
