Creating the required infrastructure with Terraform
As our goal was to build a scalable LAMP stack, we will define a VM scale set using the apache-webserver image we created and a single Virtual Machine with the mysql-dbserver image. A VM scale set is an autoscaling group of Virtual Machines that will scale out and scale back horizontally based on traffic, similar to how we did with containers on Kubernetes.
We will create the following resources:
- A new resource group called
lamp-rg - A virtual network with a resource group called
lampvnet - A subnet within
lampvnetcalledlampsub - Within the subnet, we create a NIC for the database called
db-nicthat contains the following:– A network security group called
db-nsg– A Virtual Machine called
dbthat uses the custommysql-dbserverimage - We then create a VM scale set that includes the following:
–A network profile called
webnp– A backend address pool
– A load balancer called
web-lb...