» yandex_compute_instance_group

An Instance group resource. For more information, see the official documentation.

» Example Usage

resource "yandex_compute_instance_group" "group1" {
  name               = "test-ig"
  folder_id          = "${data.yandex_resourcemanager_folder.test_folder.id}"
  service_account_id = "${yandex_iam_service_account.test_account.id}"
  instance_template {
    platform_id = "standard-v1"
    resources {
      memory = 1
      cores  = 1
    }
    boot_disk {
      mode = "READ_WRITE"
      initialize_params {
        image_id = "${data.yandex_compute_image.ubuntu.id}"
        size     = 4
      }
    }
    network_interface {
      network_id = "${yandex_vpc_network.my-inst-group-network.id}"
      subnet_ids = ["${yandex_vpc_subnet.my-inst-group-subnet.id}"]
    }
    labels = {
      label1 = "label1-value"
      label2 = "label2-value"
    }
    metadata = {
      foo      = "bar"
      ssh-keys = "ubuntu:${file("~/.ssh/id_rsa.pub")}"
    }
  }

  scale_policy {
    fixed_scale {
      size = 3
    }
  }

  allocation_policy {
    zones = ["ru-central1-a"]
  }

  deploy_policy {
    max_unavailable = 2
    max_creating    = 2
    max_expansion   = 2
    max_deleting    = 2
  }
}

» Argument Reference

The following arguments are supported:

  • folder_id - (Required) The ID of the folder that the resources belong to.

  • scale_policy - (Required) The scaling policy of the instance group. The structure is documented below.

  • deploy_policy - (Required) The deployment policy of the instance group. The structure is documented below.

  • service_account_id - (Required) The ID of the service account authorized for this instance group.

  • instance_template - (Required) The template for creating new instances. The structure is documented below.

  • allocation_policy - (Required) The allocation policy of the instance group by zone and region. The structure is documented below.


  • name - (Optional) The name of the instance group.

  • health_check - (Optional) Health check specifications. The structure is documented below.

  • load_balancer - (Optional) Load balancing specifications. The structure is documented below.

  • description - (Optional) A description of the instance group.

  • labels - (Optional) A set of key/value label pairs to assign to the instance group.


The load_balancer block supports:


The health_check block supports:

  • interval - (Optional) The interval to wait between health checks in seconds.

  • timeout - (Optional) The length of time to wait for a response before the health check times out in seconds.

  • healthy_threshold - (Optional) The number of successful health checks before the managed instance is declared healthy.

  • unhealthy_threshold - (Optional) The number of failed health checks before the managed instance is declared unhealthy.

  • tcp_options - (Optional) TCP check options. The structure is documented below.

  • http_options - (Optional) HTTP check options. The structure is documented below.


The http_options block supports:

  • port - (Required) The port used for HTTP health checks.

  • path - (Required) The URL path used for health check requests.


The tcp_options block supports:

  • port - (Required) The port used for TCP health checks.

The allocation_policy block supports:

  • zones - (Required) A list of availability zones.

The instance_template block supports:

  • boot_disk - (Required) Boot disk specifications for the instance. The structure is documented below.

  • resources - (Required) Compute resource specifications for the instance. The structure is documented below.

  • network_interface - (Required) Network specifications for the instance. This can be used multiple times for adding multiple interfaces. The structure is documented below.


  • scheduling_policy - (Optional) The scheduling policy configuration. The structure is documented below.

  • description - (Optional) A description of the instance.

  • metadata - (Optional) A set of metadata key/value pairs to make available from within the instance.

  • labels - (Optional) A set of key/value label pairs to assign to the instance.

  • platform_id - (Optional) The ID of the hardware platform configuration for the instance. The default is 'standard-v1'.

  • secondary_disk - (Optional) A list of disks to attach to the instance. The structure is documented below.

  • service_account_id - (Optional) The ID of the service account authorized for this instance.


The secondary_disk block supports:

  • mode - (Required) The access mode to the disk resource. By default a disk is attached in READ_WRITE mode.

  • initialize_params - (Required) Parameters used for creating a disk alongside the instance. The structure is documented below.


  • device_name - (Optional) This value can be used to reference the device under /dev/disk/by-id/.

The initialize_params block supports:

  • description - (Optional) A description of the boot disk.

  • size - (Optional) The size of the disk in GB.

  • type - (Optional) The disk type.

  • image_id - (Optional) The disk image to initialize this disk from.

  • snapshot_id - (Optional) The snapshot to initialize this disk from.


The scheduling_policy block supports:

  • preemptible - (Optional) Specifies if the instance is preemptible. Defaults to false.

The network_interface block supports:

  • network_id - (Optional) The ID of the network.

  • subnet_ids - (Optional) The ID of the subnets to attach this interface to.

  • nat - (Optional) A public address that can be used to access the internet over NAT.


The resources block supports:

  • memory - (Required) The memory size in GB.

  • cores - (Required) The number of CPU cores for the instance.


  • core_fraction - (Optional) If provided, specifies baseline core performance as a percent.

The boot_disk block supports:

  • mode - (Required) The access mode to the disk resource. By default a disk is attached in READ_WRITE mode.

  • initialize_params - (Required) Parameters for creating a disk alongside the instance. The structure is documented below.


  • device_name - (Optional) This value can be used to reference the device under /dev/disk/by-id/.

The initialize_params block supports:

  • description - (Optional) A description of the boot disk.

  • size - (Optional) The size of the disk in GB.

  • type - (Optional) The disk type.

  • image_id - (Optional) The disk image to initialize this disk from.

  • snapshot_id - (Optional) The snapshot to initialize this disk from.


The deploy_policy block supports:

  • max_unavailable - (Required) The maximum number of running instances that can be taken offline (stopped or deleted) at the same time during the update process.

  • max_expansion - (Required) The maximum number of instances that can be temporarily allocated above the group's target size during the update process.


  • max_deleting - (Optional) The maximum number of instances that can be deleted at the same time.

  • max_creating - (Optional) The maximum number of instances that can be created at the same time.

  • startup_duration - (Optional) The amount of time in seconds to allow for an instance to start. Instance will be considered up and running (and start receiving traffic) only after the startup_duration has elapsed and all health checks are passed.


The scale_policy block supports:

  • fixed_scale - (Optional) The fixed scaling policy of the instance group. The structure is documented below.

The fixed_scale block supports:

  • size - (Required) The number of instances in the instance group.

» Attributes Reference

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