Introduction
Infrastructure as Code (IaC) helps automate cloud resource provisioning in a reliable and repeatable way. Terraform is one of the most widely used IaC tools for managing cloud infrastructure.
In this blog, you will learn how to create a Linux Virtual Machine in Microsoft Azure using Terraform, configure a remote backend for state management, and connect to the VM using SSH.
By the end of this guide, you will be able to:
1. Configure Azure provider in Terraform
2. Store Terraform state in Azure Storage Account
3. Create networking resources (VNet, Subnet, NSG, Public IP)
4. Deploy a Linux Virtual Machine
5. Connect securely to the machine
Prerequisite:
Before starting, ensure that you have:
-
An active Azure subscription
-
Terraform installed on your machine
-
An existing Azure Storage Account for Terraform state
-
An SSH key pair on your local system
To generate an SSH key (if not already available):
Project Structure
Create a new project directory and organize files as follows: