This repository provides infrastructure as code (IaC) using Terraform to deploy a simple Node.js app on an Azure Virtual Machine (VM). Docker is used for containerization, making it easy to deploy and manage the application. The instructions below will guide you through the process of setting up and deploying the infrastructure.
Before you begin, ensure you have the following tools installed:
- Terraform - Install Terraform
- Azure CLI - Install Azure CLI
- Docker - Install Docker
-
Azure Login:
-
Open your terminal and run the following command to log in to your Azure account:
az login
-
-
Set Azure Subscription:
-
If you have multiple subscriptions, set the desired subscription using the subscription name or ID:
az account set --subscription <name or id>
-
-
Initialize Terraform:
-
Navigate to the root directory of the Terraform configuration and run:
terraform init
-
-
Terraform Plan:
-
Generate and review an execution plan for the infrastructure changes:
terraform plan
-
-
Terraform Apply:
-
Apply the Terraform configuration to create the Azure resources:
terraform apply
-
-
Deploy Dockerized Node.js App:
- Once the infrastructure is created, deploy the Node.js app using Docker:
-
Access the App:
- Open a web browser and navigate to
http://<VM-Public-IP>:80to view the running Node.js app.
- Open a web browser and navigate to
-
Terraform Destroy (Optional):
-
When done, you can destroy the infrastructure to avoid incurring charges:
terraform destroy
-
- Ensure that the Azure resource group, virtual network, and other resources are appropriately configured in the Terraform files.
- Customize the Node.js app in the 'app' directory based on your requirements.