Azure VM Example with Terraform
This folder contains a compact Azure example that provisions the full chain needed for a basic virtual machine: a resource group, virtual network, subnet, public IP, network security group, NIC, and Linux VM.
What this example teaches
- How the
azurermprovider models Azure infrastructure in Terraform. - How network resources depend on each other before a VM can be created.
- How to expose SSH and HTTP with an NSG.
- How to bootstrap a VM using
custom_data.
Files to inspect
main.tf: the end-to-end Azure deployment in one file.
Suggested workflow
- Read the resource dependency chain from top to bottom.
- Run
terraform initto install the Azure provider. - Run
terraform planand confirm the resource graph makes sense before applying. - Replace hardcoded secrets and credentials before using this in a real environment.
Notes before reuse
- The sample uses a plaintext admin password, which is fine for learning but not for production.
- In a real project, move repeated values into variables and store state remotely.
- Split networking and compute into modules once the single-file layout is clear.