Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

Managed Instance Group (MIG)

This module is used to create a google_compute_region_instance_group_manager, and optionally, an autoscaler and healthchecks.

Usage

See the simple example for a usage example.

Upgrading

The current version is 2.X. The following guides are available to assist with upgrades:

Inputs

Name Description Type Default Required
autoscaler_name Autoscaler name. When variable is empty, name will be derived from var.hostname. string "" no
autoscaling_cpu Autoscaling, cpu utilization policy block as single element array. https://www.terraform.io/docs/providers/google/r/compute_autoscaler.html#cpu_utilization list(map(number)) [] no
autoscaling_enabled Creates an autoscaler for the managed instance group string "false" no
autoscaling_lb Autoscaling, load balancing utilization policy block as single element array. https://www.terraform.io/docs/providers/google/r/compute_autoscaler.html#load_balancing_utilization list(map(number)) [] no
autoscaling_metric Autoscaling, metric policy block as single element array. https://www.terraform.io/docs/providers/google/r/compute_autoscaler.html#metric
list(object({
name = string
target = number
type = string
}))
[] no
autoscaling_mode Operating mode of the autoscaling policy. If omitted, the default value is ON. https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_autoscaler#mode string null no
autoscaling_scale_in_control Autoscaling, scale-in control block. https://www.terraform.io/docs/providers/google/r/compute_autoscaler.html#scale_in_control
object({
fixed_replicas = number
percent_replicas = number
time_window_sec = number
})
{
"fixed_replicas": null,
"percent_replicas": null,
"time_window_sec": null
}
no
cooldown_period The number of seconds that the autoscaler should wait before it starts collecting information from a new instance. number 60 no
distribution_policy_zones The distribution policy, i.e. which zone(s) should instances be create in. Default is all zones in given region. list(string) [] no
health_check Health check to determine whether instances are responsive and able to do work
object({
type = string
initial_delay_sec = number
check_interval_sec = number
healthy_threshold = number
timeout_sec = number
unhealthy_threshold = number
response = string
proxy_header = string
port = number
request = string
request_path = string
host = string
})
{
"check_interval_sec": 30,
"healthy_threshold": 1,
"host": "",
"initial_delay_sec": 30,
"port": 80,
"proxy_header": "NONE",
"request": "",
"request_path": "/",
"response": "",
"timeout_sec": 10,
"type": "",
"unhealthy_threshold": 5
}
no
health_check_name Health check name. When variable is empty, name will be derived from var.hostname. string "" no
hostname Hostname prefix for instances string "default" no
instance_template Instance template self_link used to create compute instances any n/a yes
max_replicas The maximum number of instances that the autoscaler can scale up to. This is required when creating or updating an autoscaler. The maximum number of replicas should not be lower than minimal number of replicas. number 10 no
mig_name Managed instance group name. When variable is empty, name will be derived from var.hostname. string "" no
mig_timeouts Times for creation, deleting and updating the MIG resources. Can be helpful when using wait_for_instances to allow a longer VM startup time.
object({
create = string
update = string
delete = string
})
{
"create": "5m",
"delete": "15m",
"update": "5m"
}
no
min_replicas The minimum number of replicas that the autoscaler can scale down to. This cannot be less than 0. number 2 no
named_ports Named name and named port. https://cloud.google.com/load-balancing/docs/backend-service#named_ports
list(object({
name = string
port = number
}))
[] no
network Network to deploy to. Only one of network or subnetwork should be specified. string "" no
project_id The GCP project ID string null no
region The GCP region where the managed instance group resides. any n/a yes
stateful_disks Disks created on the instances that will be preserved on instance delete. https://cloud.google.com/compute/docs/instance-groups/configuring-stateful-disks-in-migs
list(object({
device_name = string
delete_rule = string
}))
[] no
subnetwork Subnet to deploy to. Only one of network or subnetwork should be specified. string "" no
subnetwork_project The project that subnetwork belongs to string "" no
target_pools The target load balancing pools to assign this group to. list(string) [] no
target_size The target number of running instances for this managed instance group. This value should always be explicitly set unless this resource is attached to an autoscaler, in which case it should never be set. number 1 no
update_policy The rolling update policy. https://www.terraform.io/docs/providers/google/r/compute_region_instance_group_manager.html#rolling_update_policy
list(object({
max_surge_fixed = number
instance_redistribution_type = string
max_surge_percent = number
max_unavailable_fixed = number
max_unavailable_percent = number
min_ready_sec = number
replacement_method = string
minimal_action = string
type = string
}))
[] no
wait_for_instances Whether to wait for all instances to be created/updated before returning. Note that if this is set to true and the operation does not succeed, Terraform will continue trying until it times out. string "false" no

Outputs

Name Description
health_check_self_links All self_links of healthchecks created for the instance group.
instance_group Instance-group url of managed instance group
instance_group_manager An instance of google_compute_region_instance_group_manager of the instance group.
self_link Self-link of managed instance group