google_compute_instance_group_manager

The Google Compute Engine Instance Group Manager API creates and manages pools of homogeneous Compute Engine virtual machine instances from a common instance template. For more information, see the official documentation and API

Example Usage with top level instance template (google provider)

resource "google_compute_health_check" "autohealing" {
  name                = "autohealing-health-check"
  check_interval_sec  = 5
  timeout_sec         = 5
  healthy_threshold   = 2
  unhealthy_threshold = 10 # 50 seconds

  http_health_check {
    request_path = "/healthz"
    port         = "8080"
  }
}

resource "google_compute_instance_group_manager" "appserver" {
  name = "appserver-igm"

  base_instance_name = "app"
  zone               = "us-central1-a"

  version {
    instance_template  = google_compute_instance_template.appserver.self_link_unique
  }

  all_instances_config {
    metadata = {
      metadata_key = "metadata_value"
    }
    labels = {
      label_key = "label_value"
    }
  }

  target_pools = [google_compute_target_pool.appserver.id]
  target_size  = 2

  named_port {
    name = "customhttp"
    port = 8888
  }

  auto_healing_policies {
    health_check      = google_compute_health_check.autohealing.id
    initial_delay_sec = 300
  }
}

Example Usage with multiple versions (google-beta provider)

resource "google_compute_instance_group_manager" "appserver" {
  provider = google-beta
  name     = "appserver-igm"

  base_instance_name = "app"
  zone               = "us-central1-a"

  target_size = 5

  version {
    name              = "appserver"
    instance_template = google_compute_instance_template.appserver.self_link_unique
  }

  version {
    name              = "appserver-canary"
    instance_template = google_compute_instance_template.appserver-canary.self_link_unique
    target_size {
      fixed = 1
    }
  }
}

Argument Reference

The following arguments are supported:




The update_policy block supports:

update_policy {
  type                           = "PROACTIVE"
  minimal_action                 = "REPLACE"
  most_disruptive_allowed_action = "REPLACE"
  max_surge_fixed                = 0
  max_unavailable_fixed          = 2
  min_ready_sec                  = 50
  replacement_method             = "RECREATE"
}

The instance_lifecycle_policy block supports:

instance_lifecycle_policy {
  force_update_on_repair    = "YES"
  default_action_on_failure = "DO_NOTHING"
}

The all_instances_config block supports:

all_instances_config {
  metadata = {
    metadata_key = "metadata_value"
  }
  labels = {
    label_key = "label_Value"
  }
}

The named_port block supports: (Include a named_port block for each named-port required).


The auto_healing_policies block supports:

The version block supports:

version {
  name              = "appserver-canary"
  instance_template = google_compute_instance_template.appserver-canary.self_link_unique

  target_size {
    fixed = 1
  }
}
version {
  name              = "appserver-canary"
  instance_template = google_compute_instance_template.appserver-canary.self_link_unique

  target_size {
    percent = 20
  }
}

The target_size block supports:

The stateful_disk block supports: (Include a stateful_disk block for each stateful disk required).

The stateful_internal_ip block supports:

The stateful_external_ip block supports:

The params block supports:

params{
  resource_manager_tags = {
    "tagKeys/123": "tagValues/123"
  }
}

Attributes Reference

In addition to the arguments listed above, the following computed attributes are exported:

The status block holds:

The version_target block holds:

The all_instances_config block holds:

The stateful block holds:

The per_instance_configs block holds:

Timeouts

This resource provides the following Timeouts configuration options: configuration options:

Import

Instance group managers can be imported using any of these accepted formats:

* `projects/{{project}}/zones/{{zone}}/instanceGroupManagers/{{name}}`
* `{{project}}/{{zone}}/{{name}}`
* `{{project}}/{{name}}`
* `{{name}}`

In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import instance group managers using one of the formats above. For example:

```tf
import {
  id = "projects/{{project}}/zones/{{zone}}/instanceGroupManagers/{{name}}"
  to = google_compute_instance_group_manager.default
}

When using the terraform import command, instance group managers can be imported using one of the formats above. For example:

$ terraform import google_compute_instance_group_manager.default projects/{{project}}/zones/{{zone}}/instanceGroupManagers/{{name}}
$ terraform import google_compute_instance_group_manager.default {{project}}/{{zone}}/{{name}}
$ terraform import google_compute_instance_group_manager.default {{project}}/{{name}}
$ terraform import google_compute_instance_group_manager.default {{name}}