This repository provides a complete, production-ready Infrastructure as Code (IaC) setup for deploying a Windows Virtual Machine on Azure. It is designed with security and automation as a priority.
The deployment includes the following Azure resources:
- Resource Group: Centralized management for all lab components.
- Networking: A secure VNet with isolated subnets for workloads and the management layer.
- Security:
- Network Security Groups (NSGs): Dynamic rules for controlled inbound/outbound traffic.
- Azure Key Vault: Stores VM credentials securely (Usernames/Passwords).
- Compute: Windows Server 2022 VM (Standard_B2s, Premium SSD).
- Access: Azure Bastion host for secure, browser-based RDP access to the VM.
- Optimization: Automated daily shutdown schedule at 20:00 (GTB time).
├── bootstrap/ # Initial setup for remote state storage
│ └── main.tf # Creates the Storage Account & Container
└── main/ # Core infrastructure deployment
└── main.tf # VNet, Bastion, Key Vault, VM, and NSGs
Ensure your Terraform state is stored securely in Azure:
- Navigate to
/bootstrap. - Run
terraform initandterraform apply.
This project uses GitHub Actions for automated deployments.
- Create a Feature Branch: Never work directly on
main. Create a new branch:git checkout -b feature-my-update. - Commit & Push: Make your changes to the
/maindirectory and push your branch to GitHub. - Open a Pull Request: Submit a Pull Request (PR) to merge your changes into
main. - Automated Validation: Once the PR is opened, the GitHub Actions pipeline will trigger a
terraform planto validate your changes. - Merge: Once approved and merged into
main, the pipeline will automatically executeterraform applyto deploy your infrastructure.
Sensitive data such as VM admin credentials are managed via Azure Key Vault. This setup ensures that secrets are not exposed in plaintext and are handled securely by the Service Principal during deployment.
This repository is protected. All changes must be submitted via Pull Requests.
Direct pushes to the main branch are blocked. Please create a feature branch, submit your changes, and request a review before merging.