This module allows creating a managed instance group supporting one or more application versions via instance templates. A health check and an autoscaler can also be optionally created.
This module can be coupled with the [`compute-vm`](../compute-vm) module which can manage instance templates, and the [`net-ilb`](../net-ilb) module to assign the MIG to a backend wired to an Internal Load Balancer. The first use case is shown in the examples below.
## Examples
This example shows how to manage a simple MIG that leverages the `compute-vm` module to manage the underlying instance template. The following sub-examples will only show how to enable specific features of this module, and won't replicate the combined setup.
If multiple versions are desired, use more `compute-vm` instances for the additional templates used in each version (not shown here), and reference them like this:
The module can create and manage an autoscaler associated with the MIG. When using autoscaling do not set the `target_size` variable or set it to `null`. Here we show a CPU utilization autoscaler, the other available modes are load balancing utilization and custom metric, like the underlying autoscaler resource.
| *health_check_config* | Optional auto-created health check configuration, use the output self-link to set it in the auto healing policy. Refer to examples for usage. | <codetitle="object({ type = string # http https tcp ssl http2 check = map(any) # actual health check block attributes config = map(number) # interval, thresholds, timeout logging = bool })">object({...})</code> | | <codetitle="">null</code> |
| *regional* | Use regional instance group. When set, `location` should be set to the region. | <codetitle="">bool</code> | | <codetitle="">false</code> |
| *target_pools* | Optional list of URLs for target pools to which new instances in the group are added. | <codetitle="list(string)">list(string)</code> | | <codetitle="">[]</code> |
| *target_size* | Group target size, leave null when using an autoscaler. | <codetitle="">number</code> | | <codetitle="">null</code> |
| *update_policy* | Update policy. Type can be 'OPPORTUNISTIC' or 'PROACTIVE', action 'REPLACE' or 'restart', surge type 'fixed' or 'percent'. | <codetitle="object({ type = string # OPPORTUNISTIC | PROACTIVE minimal_action = string # REPLACE | RESTART min_ready_sec = number max_surge_type = string # fixed | percent max_surge = number max_unavailable_type = string max_unavailable = number })">object({...})</code> | | <codetitle="">null</code> |
| *versions* | Additional application versions, target_type is either 'fixed' or 'percent'. | <codetitle="map(object({ instance_template = string target_type = string # fixed | percent target_size = number }))">map(object({...}))</code> | | <codetitle="">null</code> |
| *wait_for_instances* | Wait for all instances to be created/updated before returning. | <codetitle="">bool</code> | | <codetitle="">null</code> |