Modular Terraform-based Azure infrastructure deployment using best IaC practices.
Welcome to this Terraform project where we deploy a complete Azure infrastructure using a modular and reusable approach. This project is ideal for learning, production, or scaling large Azure environments efficiently.
This repository provisions the following Azure resources using Terraform:
- ✅ Resource Group
- 🌐 Virtual Network & Subnets
- 🔐 Key Vault & Secrets
- 🧠 SQL Server & Database
- 💻 Virtual Machines (Linux)
- 🌐 Public IP Address
- 🔌 Network Interfaces
- 🛡️ Network Security Groups
All of these are defined using individual Terraform modules to promote reusability, scalability, and clean structure.
📁 modules/
├── azurerm_key_vault/ # Key Vault module
├── azurerm_key_vault_secrets/ # Secrets for Key Vault
├── azurerm_linux_virtual_machine/ # Linux VM module
├── azurerm_network_interface/ # NICs for VMs
├── azurerm_network_security_group/ # NSGs
├── azurerm_public_ip/ # Public IPs
├── azurerm_resource_group/ # Resource group
├── azurerm_sql_database/ # SQL DB
├── azurerm_sql_server/ # SQL Server
├── azurerm_subnet/ # Subnets
├── azurerm_virtual_network/ # VNet
📁 todoapp/
├── main.tf # Parent file calling all modules
├── provider.tf # Azure provider config
├── variables.tf # Input variables for root module
├── terraform.tfvars # Variable values (default)
├── riteshcustom.tfvars # Custom values for deployment- Azure CLI installed (
az loginto authenticate) - Terraform installed
- A valid Azure subscription
git clone https://github.com/Riteshatri/modular-infra-azure-terraform.git
cd modular-infra-azure-terraform
terraform initterraform plan -var-file="riteshcustom.tfvars"terraform apply -var-file="riteshcustom.tfvars" -auto-approve✅ Resources will now be deployed to Azure.
- List all resources:
terraform state list- Inspect a specific resource:
terraform state show <resource_name>- ♻️ Reusability: Each module can be reused in other projects.
- 🔍 Separation of Concerns: Easy to debug and scale.
- 🧪 Test Individually: Each module can be tested independently.
variables.tf: All declared variablesterraform.tfvars: Default valuesriteshcustom.tfvars: Custom values for your environment
To use custom values:
terraform apply -var-file="riteshcustom.tfvars"Developed by Ritesh Sharma 💼 DevSecOps Engineer | Azure | Terraform Enthusiast | ADO | Docker | Kubernetes
This project is open-sourced under the MIT License.
⚠️ Tip: For production use, consider storing your state in a remote backend (like Azure Blob Storage) and use service principals for secure access.