Creating the required infrastructure with Terraform
Our goal was to build a scalable LAMP stack, so we will define a VM scale set using the apache-webserver
image we created and a single VM with the mysql-dbserver
image. A VM scale set is an autoscaling group of VMs 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 within the resource group called
lampvnet
- A subnet within
lampvnet
calledlampsub
- Within the subnet, we create a Network Interface Card (NIC) for the database called
db-nic
that contains the following:- A network security group called
db-nsg
- A VM called
db
that uses the custommysql-dbserver
image
- A network security group called
- 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
- A public IP address attached to
web-lb
- An HTTP probe that...
- A network profile called