Course outlines for learning terraform.
| expected time | requirements |
|---|---|
| 60 minutes | a computer |
Goal: Experiment with a Google Compute Autoscaler.
A compute autoscaler allow you to treat a set of machines as one resource. Typically a load balancer sends traffic to healthy members of a compute autoscaler.
A compute autoscaler 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 compute autoscaler.
A computer autoscaler can also manage it’s own capacity (that’s the number if instances) using a autoscale_policy.
Have a look at the terraform documentation on compute autoscalers.
There are quite some parameters to set; you may need to search for a few examples.
See this gcp computer autoscaler 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.
min_replicas to 2.max_replicas to 5.yes > /dev/null. This generates load.cpu_utilization.target is above 70% and new instances are stared.Bonus:
count parameter for resources. Instead of a google_compute_autoscaler, you could also just add count to a google_compute_instance resource. What are the benefits of a scale-set?google_compute_autoscaler has generated?