Course outlines for learning terraform.
expected time | requirements |
---|---|
60 minutes | a computer |
Goal: Experiment with a Virtual Machine Scale Set.
A scale set allow you to treat a set of machines as one resource. Typically a load balancer sends traffic to healthy members of a scale set.
A scaleset is easier to maintain than individual VM’s, for example; a single number (instances
) can scale up (or down) the amount of machines in a scale set.
A scaleset can also manage it’s own capacity (number of instances in the scale set) using a monitoring_autoscale_setting
resource.
Have a look at the terraform documentation on scale sets.
There are quite some parameters to set; you may need to search for a few examples.
See this azure linux virtual machine example.
A nice feature of the code above is that it uses cloud-init to customize the instance. An alternative would be to make an image using a tool as packer.
Bonus: (Only if you have extra time)
count
parameter for resources. Instead of a linux_virtual_machine_scaleset, you could also just add count
to a linux_virtual_machine resource. What are the benefits of a scale-set?