» google_compute_region_per_instance_config

A config defined for a single managed instance that belongs to an instance group manager. It preserves the instance name across instance group manager operations and can define stateful disks or metadata that are unique to the instance. This resource works with regional instance group managers.

To get more information about RegionPerInstanceConfig, see:

» Example Usage - Stateful Rigm

data "google_compute_image" "my_image" {
  family  = "debian-9"
  project = "debian-cloud"
}

resource "google_compute_instance_template" "igm-basic" {
  name           = "my-template"
  machine_type   = "n1-standard-1"
  can_ip_forward = false
  tags           = ["foo", "bar"]

  disk {
    source_image = data.google_compute_image.my_image.self_link
    auto_delete  = true
    boot         = true
  }

  network_interface {
    network = "default"
  }

  service_account {
    scopes = ["userinfo-email", "compute-ro", "storage-ro"]
  }
}

resource "google_compute_region_instance_group_manager" "rigm" {
  description = "Terraform test instance group manager"
  name        = "my-rigm"

  version {
    name              = "prod"
    instance_template = google_compute_instance_template.igm-basic.self_link
  }

  base_instance_name = "rigm"
  region             = "us-central1"
  target_size        = 2
}

resource "google_compute_disk" "default" {
  name  = "test-disk-%{random_suffix}"
  type  = "pd-ssd"
  zone  = "us-central1-a"
  image = "debian-9-stretch-v20200805"
  physical_block_size_bytes = 4096
}

resource "google_compute_region_per_instance_config" "with_disk" {
  region = google_compute_instance_group_manager.igm.region
  region_instance_group_manager = google_compute_region_instance_group_manager.rigm.name
  name = "instance-1"
  preserved_state {
    metadata = {
      foo = "bar"
    }

    disk {
      device_name = "my-stateful-disk"
      source      = google_compute_disk.default.id
      mode        = "READ_ONLY"
    }
  }
}

» Argument Reference

The following arguments are supported:

  • name - (Required) The name for this per-instance config and its corresponding instance.

  • region - (Required) Region where the containing instance group manager is located

  • region_instance_group_manager - (Required) The region instance group manager this instance config is part of.


  • preserved_state - (Optional) The preserved state for this instance. Structure is documented below.

  • project - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

  • minimal_action - (Optional) The minimal action to perform on the instance during an update. Default is NONE. Possible values are:

  • REPLACE

  • RESTART

  • REFRESH

  • NONE

  • most_disruptive_allowed_action - (Optional) The most disruptive action to perform on the instance during an update. Default is REPLACE. Possible values are:

  • REPLACE

  • RESTART

  • REFRESH

  • NONE

  • remove_instance_state_on_destroy - (Optional) When true, deleting this config will immediately remove any specified state from the underlying instance. When false, deleting this config will not immediately remove any state from the underlying instance. State will be removed on the next instance recreation or update.

The preserved_state block supports:

  • metadata - (Optional) Preserved metadata defined for this instance. This is a list of key->value pairs.

  • disk - (Optional) Stateful disks for the instance. Structure is documented below.

The disk block supports:

  • device_name - (Required) A unique device name that is reflected into the /dev/ tree of a Linux operating system running within the instance.

  • source - (Required) The URI of an existing persistent disk to attach under the specified device-name in the format projects/project-id/zones/zone/disks/disk-name.

  • mode - (Optional) The mode of the disk. Default value is READ_WRITE. Possible values are READ_ONLY and READ_WRITE.

  • delete_rule - (Optional) A value that prescribes what should happen to the stateful disk when the VM instance is deleted. The available options are NEVER and ON_PERMANENT_INSTANCE_DELETION. NEVER detatch the disk when the VM is deleted, but not delete the disk. ON_PERMANENT_INSTANCE_DELETION will delete the stateful disk when the VM is permanently deleted from the instance group. Default value is NEVER. Possible values are NEVER and ON_PERMANENT_INSTANCE_DELETION.

» Attributes Reference

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

  • id - an identifier for the resource with format {{project}}/{{region}}/{{region_instance_group_manager}}/{{name}}

» Timeouts

This resource provides the following Timeouts configuration options:

  • create - Default is 15 minutes.
  • update - Default is 6 minutes.
  • delete - Default is 15 minutes.

» Import

RegionPerInstanceConfig can be imported using any of these accepted formats:

$ terraform import google_compute_region_per_instance_config.default projects/{{project}}/regions/{{region}}/instanceGroupManagers/{{region_instance_group_manager}}/{{name}}
$ terraform import google_compute_region_per_instance_config.default {{project}}/{{region}}/{{region_instance_group_manager}}/{{name}}
$ terraform import google_compute_region_per_instance_config.default {{region}}/{{region_instance_group_manager}}/{{name}}
$ terraform import google_compute_region_per_instance_config.default {{region_instance_group_manager}}/{{name}}

» User Project Overrides

This resource supports User Project Overrides.