This repository contains a comprehensive Terraform configuration designed to provision the infrastructure required for a Todo List application on Microsoft Azure.
The project heavily emphasizes Terraform modularity and best practices, structuring the deployment into logical, reusable components.
The infrastructure is broken down into specific, purpose-built Terraform modules to ensure clean code, reusability, and easy maintainability.
The root directory serves as the main entry point for the infrastructure deployment.
main.tf: Orchestrates the execution of child modules and creates the base Azure Resource Group.variables.tf/terraform.tfvars: Centralized configuration for input parameters (locations, sizes, names).outputs.tf: Defines the essential outputs like the VM's Public IP to access the deployed application.backend.tf: Configures the remote state backend using Azure Blob Storage for secure state management and team collaboration.
Responsible for all networking components.
- Virtual Network (VNet) & Subnet: Creates the isolated network environment.
- Network Security Group (NSG): Implements security rules (e.g., allowing SSH and HTTP traffic).
- Public IP Address: Provisions a dynamically allocated Public IP with a custom DNS label.
Responsible for provisioning the virtual machine and bootstrapping the application.
- Network Interface (NIC): Attaches the VM to the created Subnet and Public IP.
- Virtual Machine: Provisions an Ubuntu 22.04 VM (
Standard_B1sby default) using SSH key authentication. - VM Extension (CustomScript): Automatically executes the
install-app.shscript during the VM creation phase to install dependencies and deploy the Todo List application without manual intervention.
Responsible for auxiliary storage requirements.
- Storage Account & Container: Provisions an Azure Storage Account and a specific container (
task-artifacts) which can be used for application backups, state files, or artifact storage.
- Terraform installed (v1.0+ recommended)
- Azure CLI installed and authenticated (
az login) - An active Azure Subscription
-
Clone the repository:
git clone <repository-url> cd Terraform_Azure_Module
-
Configure your variables: Review
variables.tfand customize the values interraform.tfvarsif necessary (e.g., provide yourssh_key_publiccontent). -
Initialize Terraform: This command downloads the required providers (like
azurerm) and initializes the remote backend.terraform init
-
Review the execution plan: See exactly what resources Terraform will create before actually making changes.
terraform plan
-
Apply the configuration: Provision the resources on Azure. Type
yeswhen prompted.terraform apply
-
Access the Application: Once applied, Terraform will output the Public IP address of the newly created VM. Open that IP in your web browser to access the Todo List application.
To avoid incurring unwanted charges, destroy the infrastructure when you are done:
terraform destroy