learn-terraform

Course outlines for learning terraform.

View the Project on GitHub robertdebock/learn-terraform

Build a virtual machine scale set

expected time requirements
60 minutes a computer

Goal: Experiment with a Virtual Machine Scale Set.

Explanation

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.

Howto

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.

Demo

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.

Assignment

Bonus: (Only if you have extra time)

Questions

  1. With Terraform, there is a 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?
  2. Imagine you need to troubleshoot the instances, how would you connect?