yandex_compute_instance_group (Resource)
- Example usage
- Schema
- Required
- Optional
- Read-Only
- Nested Schema for allocation_policy
- Nested Schema for allocation_policy.instance_tags_pool
- Nested Schema for deploy_policy
- Nested Schema for instance_template
- Nested Schema for instance_template.boot_disk
- Nested Schema for instance_template.boot_disk.initialize_params
- Nested Schema for instance_template.network_interface
- Nested Schema for instance_template.network_interface.dns_record
- Nested Schema for instance_template.network_interface.ipv6_dns_record
- Nested Schema for instance_template.network_interface.nat_dns_record
- Nested Schema for instance_template.resources
- Nested Schema for instance_template.filesystem
- Nested Schema for instance_template.metadata_options
- Nested Schema for instance_template.network_settings
- Nested Schema for instance_template.placement_policy
- Nested Schema for instance_template.scheduling_policy
- Nested Schema for instance_template.secondary_disk
- Nested Schema for instance_template.secondary_disk.initialize_params
- Nested Schema for scale_policy
- Nested Schema for scale_policy.auto_scale
- Nested Schema for scale_policy.auto_scale.custom_rule
- Nested Schema for scale_policy.fixed_scale
- Nested Schema for scale_policy.test_auto_scale
- Nested Schema for scale_policy.test_auto_scale.custom_rule
- Nested Schema for application_load_balancer
- Nested Schema for health_check
- Nested Schema for health_check.http_options
- Nested Schema for health_check.tcp_options
- Nested Schema for load_balancer
- Nested Schema for timeouts
- Nested Schema for instances
- Nested Schema for instances.network_interface
- Import
An Instance group resource. For more information, see the official documentation.
Example usage
//
// Create a new Compute Instance Group (IG)
//
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
deletion_protection = true
instance_template {
platform_id = "standard-v1"
resources {
memory = 2
cores = 2
}
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")}"
}
network_settings {
type = "STANDARD"
}
}
variables = {
test_key1 = "test_value1"
test_key2 = "test_value2"
}
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
}
}
Schema
Required
allocation_policy(Block List, Min: 1, Max: 1) The allocation policy of the instance group by zone and region. (see below for nested schema)deploy_policy(Block List, Min: 1, Max: 1) The deployment policy of the instance group. (see below for nested schema)instance_template(Block List, Min: 1, Max: 1) The template for creating new instances. (see below for nested schema)scale_policy(Block List, Min: 1, Max: 1) The scaling policy of the instance group.
Важно
Either fixed_scale or auto_scale must be specified. (see below for nested schema)
service_account_id(String) Service account which linked to the resource.
Optional
application_load_balancer(Block List, Max: 1) Application Load balancing (L7) specifications. (see below for nested schema)deletion_protection(Boolean) Thetruevalue means that resource is protected from accidental deletion.description(String) The resource description.folder_id(String) The folder identifier that resource belongs to. If it is not provided, the default providerfolder-idis used.health_check(Block List) Health check specifications. (see below for nested schema)labels(Map of String) A set of key/value label pairs which assigned to resource.load_balancer(Block List, Max: 1) Load balancing specifications. (see below for nested schema)max_checking_health_duration(Number) Timeout for waiting for the VM to become healthy. If the timeout is exceeded, the VM will be turned off based on the deployment policy. Specified in seconds.name(String) The resource name.timeouts(Block, Optional) (see below for nested schema)variables(Map of String) A set of key/value variables pairs to assign to the instance group.
Read-Only
created_at(String) The creation timestamp of the resource.id(String) The ID of this resource.instances(List of Object) Instances block. (see below for nested schema)status(String) The status of the instance.
Nested Schema for allocation_policy
Required:
zones(Set of String) A list of availability zones.
Optional:
instance_tags_pool(Block List) Array of availability zone IDs with list of instance tags. (see below for nested schema)
Nested Schema for allocation_policy.instance_tags_pool
Required:
tags(List of String) List of tags for instances in zone.zone(String) Availability zone.
Nested Schema for deploy_policy
Required:
max_expansion(Number) The maximum number of instances that can be temporarily allocated above the group's target size during the update process.max_unavailable(Number) The maximum number of running instances that can be taken offline (stopped or deleted) at the same time during the update process.
Optional:
max_creating(Number) The maximum number of instances that can be created at the same time.max_deleting(Number) The maximum number of instances that can be deleted at the same time.startup_duration(Number) 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.strategy(String) Affects the lifecycle of the instance during deployment. If set toproactive(default), Instance Groups can forcefully stop a running instance. Ifopportunistic, Instance Groups does not stop a running instance. Instead, it will wait until the instance stops itself or becomes unhealthy.
Nested Schema for instance_template
Required:
boot_disk(Block List, Min: 1, Max: 1) Boot disk specifications for the instance. (see below for nested schema)network_interface(Block List, Min: 1) Network specifications for the instance. This can be used multiple times for adding multiple interfaces. (see below for nested schema)resources(Block List, Min: 1, Max: 1) Compute resource specifications for the instance. (see below for nested schema)
Optional:
description(String) A description of the instance.filesystem(Block Set) List of filesystems to attach to the instance. (see below for nested schema)hostname(String) Hostname template for the instance. This field is used to generate the FQDN value of instance. Thehostnamemust be unique within the network and region. If not specified, the hostname will be equal toidof the instance and FQDN will be<id>.auto.internal. Otherwise FQDN will be<hostname>.<region_id>.internal.
In order to be unique it must contain at least on of instance unique placeholders:
{instance.short_id}- combination of
{instance.zone_id}and{instance.index_in_zone}
Example:my-instance-{instance.index}. If hostname is not set,namevalue will be used. It may also contain another placeholders, seemetadatadoc for full list.
labels(Map of String) A set of key/value label pairs to assign to the instance.metadata(Map of String) A set of metadata key/value pairs to make available from within the instance.metadata_options(Block List, Max: 1) Options allow user to configure access to managed instances metadata (see below for nested schema)name(String) Name template of the instance.
In order to be unique it must contain at least one of instance unique placeholders:*{instance.short_id}
{instance.index}- combination of
{instance.zone_id}and{instance.index_in_zone}.
Example:my-instance-{instance.index}.
If not set, default name is used:{instance_group.id}-{instance.short_id}. It may also contain another placeholders, seemetadatadoc for full list.
network_settings(Block List) Network acceleration type for instance. (see below for nested schema)placement_policy(Block List, Max: 1) The placement policy configuration. (see below for nested schema)platform_id(String) The ID of the hardware platform configuration for the instance.scheduling_policy(Block List, Max: 1) The scheduling policy configuration. (see below for nested schema)secondary_disk(Block List) A list of disks to attach to the instance. (see below for nested schema)service_account_id(String) The ID of the service account authorized for this instance.
Nested Schema for instance_template.boot_disk
Optional:
device_name(String) This value can be used to reference the device under/dev/disk/by-id/.disk_id(String) The ID of the existing disk (such as those managed by yandex_compute_disk) to attach as a boot disk.initialize_params(Block List, Max: 1) Parameters for creating a disk alongside the instance.
Важно
image_id or snapshot_id must be specified. (see below for nested schema)
mode(String) The access mode to the disk resource. By default a disk is attached inREAD_WRITEmode.name(String) When set can be later used to change DiskSpec of actual disk.
Nested Schema for instance_template.boot_disk.initialize_params
Optional:
description(String) A description of the boot disk.image_id(String) The disk image to initialize this disk from.size(Number) The size of the disk in GB.snapshot_id(String) The snapshot to initialize this disk from.type(String) The disk type.
Nested Schema for instance_template.network_interface
Optional:
dns_record(Block List) List of DNS records. (see below for nested schema)ip_address(String) Manual set static IP address.ipv4(Boolean) Allocate an IPv4 address for the interface. The default value istrue.ipv6(Boolean) Iftrue, allocate an IPv6 address for the interface. The address will be automatically assigned from the specified subnet.ipv6_address(String) Manual set static IPv6 address.ipv6_dns_record(Block List) List of IPv6 DNS records. (see below for nested schema)nat(Boolean) Flag for using NAT.nat_dns_record(Block List) List of NAT DNS records. (see below for nested schema)nat_ip_address(String) A public address that can be used to access the internet over NAT. Usevariablesto set.network_id(String) The ID of the network.security_group_ids(Set of String) Security group (SG)IDsfor network interface.subnet_ids(Set of String) The ID of the subnets to attach this interface to.
Nested Schema for instance_template.network_interface.dns_record
Required:
fqdn(String) DNS record FQDN (must have dot at the end).
Optional:
dns_zone_id(String) DNS zone id (if not set, private zone used).ptr(Boolean) When set totrue, also create PTR DNS record.ttl(Number) DNS record TTL.
Nested Schema for instance_template.network_interface.ipv6_dns_record
Required:
fqdn(String) DNS record FQDN (must have dot at the end).
Optional:
dns_zone_id(String) DNS zone id (if not set, private zone used).ptr(Boolean) When set totrue, also create PTR DNS record.ttl(Number) DNS record TTL.
Nested Schema for instance_template.network_interface.nat_dns_record
Required:
fqdn(String) DNS record FQDN (must have dot at the end).
Optional:
dns_zone_id(String) DNS zone id (if not set, private zone used).ptr(Boolean) When set totrue, also create PTR DNS record.ttl(Number) DNS record TTL.
Nested Schema for instance_template.resources
Required:
cores(Number) The number of CPU cores for the instance.memory(Number) The memory size in GB.
Optional:
core_fraction(Number) If provided, specifies baseline core performance as a percent.gpus(Number) If provided, specifies the number of GPU devices for the instance.
Nested Schema for instance_template.filesystem
Required:
filesystem_id(String) ID of the filesystem that should be attached.
Optional:
device_name(String) Name of the device representing the filesystem on the instance.mode(String) Mode of access to the filesystem that should be attached. By default, filesystem is attached inREAD_WRITEmode.
Nested Schema for instance_template.metadata_options
Optional:
aws_v1_http_endpoint(Number) Enables access to AWS flavored metadata (IMDSv1). Possible values:0,1forenabledand2fordisabled.aws_v1_http_token(Number) Enables access to IAM credentials with AWS flavored metadata (IMDSv1). Possible values:0,1forenabledand2fordisabled.gce_http_endpoint(Number) Enables access to GCE flavored metadata. Possible values:0,1forenabledand2fordisabled.gce_http_token(Number) Enables access to IAM credentials with GCE flavored metadata. Possible values:0,1forenabledand2fordisabled.
Nested Schema for instance_template.network_settings
Optional:
type(String) Network acceleration type. By default a network is inSTANDARDmode.
Nested Schema for instance_template.placement_policy
Required:
placement_group_id(String) Specifies the id of the Placement Group to assign to the instances.
Nested Schema for instance_template.scheduling_policy
Optional:
preemptible(Boolean) Specifies if the instance is preemptible. Defaults tofalse.
Nested Schema for instance_template.secondary_disk
Optional:
device_name(String) This value can be used to reference the device under/dev/disk/by-id/.disk_id(String) ID of the existing disk. To set use variables.initialize_params(Block List, Max: 1) Parameters used for creating a disk alongside the instance.
Важно
image_id or snapshot_id must be specified. (see below for nested schema)
mode(String) The access mode to the disk resource. By default a disk is attached inREAD_WRITEmode.name(String) When set can be later used to change DiskSpec of actual disk.
Nested Schema for instance_template.secondary_disk.initialize_params
Optional:
description(String) A description of the boot disk.image_id(String) The disk image to initialize this disk from.size(Number) The size of the disk in GB.snapshot_id(String) The snapshot to initialize this disk from.type(String) The disk type.
Nested Schema for scale_policy
Optional:
auto_scale(Block List, Max: 1) The auto scaling policy of the instance group. (see below for nested schema)fixed_scale(Block List, Max: 1) The fixed scaling policy of the instance group. (see below for nested schema)test_auto_scale(Block List, Max: 1) The test auto scaling policy of the instance group. Use it to test how the auto scale works. (see below for nested schema)
Nested Schema for scale_policy.auto_scale
Required:
initial_size(Number) The initial number of instances in the instance group.measurement_duration(Number) The amount of time, in seconds, that metrics are averaged for. If the average value at the end of the interval is higher than thecpu_utilization_target, the instance group will increase the number of virtual machines in the group.
Optional:
auto_scale_type(String) Autoscale type, can beZONALorREGIONAL. By defaultZONALtype is used.cpu_utilization_target(Number) Target CPU load level.custom_rule(Block List) A list of custom rules. (see below for nested schema)max_size(Number) The maximum number of virtual machines in the group.min_zone_size(Number) The minimum number of virtual machines in a single availability zone.stabilization_duration(Number) The minimum time interval, in seconds, to monitor the load before an instance group can reduce the number of virtual machines in the group. During this time, the group will not decrease even if the average load falls below the value ofcpu_utilization_target.warmup_duration(Number) The warm-up time of the virtual machine, in seconds. During this time, traffic is fed to the virtual machine, but load metrics are not taken into account.
Nested Schema for scale_policy.auto_scale.custom_rule
Required:
metric_name(String) Name of the metric in Monitoring.metric_type(String) Type of metric, can beGAUGEorCOUNTER.GAUGEmetric reflects the value at particular time point.COUNTERmetric exhibits a monotonous growth over time.rule_type(String) The metric rule type (UTILIZATION, WORKLOAD). UTILIZATION for metrics describing resource utilization per VM instance. WORKLOAD for metrics describing total workload on all VM instances.target(Number) Target metric value by which Instance Groups calculates the number of required VM instances.
Optional:
folder_id(String) If specified, sets the folder id to fetch metrics from. By default, it is the ID of the folder the group belongs to.labels(Map of String) Metrics labels from Monitoring.service(String) If specified, sets the service name to fetch metrics. The default value iscustom. You can use a label to specify service metrics, e.g.,servicewith thecomputevalue for Compute Cloud.
Nested Schema for scale_policy.fixed_scale
Required:
size(Number) The number of instances in the instance group.
Nested Schema for scale_policy.test_auto_scale
Required:
initial_size(Number) The initial number of instances in the instance group.measurement_duration(Number) The amount of time, in seconds, that metrics are averaged for. If the average value at the end of the interval is higher than thecpu_utilization_target, the instance group will increase the number of virtual machines in the group.
Optional:
auto_scale_type(String) Autoscale type, can beZONALorREGIONAL. By defaultZONALtype is used.cpu_utilization_target(Number) Target CPU load level.custom_rule(Block List) A list of custom rules. (see below for nested schema)max_size(Number) The maximum number of virtual machines in the group.min_zone_size(Number) The minimum number of virtual machines in a single availability zone.stabilization_duration(Number) The minimum time interval, in seconds, to monitor the load before an instance group can reduce the number of virtual machines in the group. During this time, the group will not decrease even if the average load falls below the value ofcpu_utilization_target.warmup_duration(Number) The warm-up time of the virtual machine, in seconds. During this time, traffic is fed to the virtual machine, but load metrics are not taken into account.
Nested Schema for scale_policy.test_auto_scale.custom_rule
Required:
metric_name(String) The name of metric.metric_type(String) Metric type,GAUGEorCOUNTER.rule_type(String) Rule type:UTILIZATION- This type means that the metric applies to one instance. First, Instance Groups calculates the average metric value for each instance, then averages the values for instances in one availability zone. This type of metric must have theinstance_idlabel.WORKLOAD- This type means that the metric applies to instances in one availability zone. This type of metric must have thezone_idlabel.target(Number) Target metric value level.
Optional:
folder_id(String) Folder ID of custom metric in Yandex Monitoring that should be used for scaling.labels(Map of String) A map of labels of metric.service(String) Service of custom metric in Yandex Monitoring that should be used for scaling.
Nested Schema for application_load_balancer
Optional:
ignore_health_checks(Boolean) Do not wait load balancer health checks.max_opening_traffic_duration(Number) Timeout for waiting for the VM to be checked by the load balancer. If the timeout is exceeded, the VM will be turned off based on the deployment policy. Specified in seconds.target_group_description(String) A description of the target group.target_group_labels(Map of String) A set of key/value label pairs.target_group_name(String) The name of the target group.
Read-Only:
status_message(String) The status message of the instance.target_group_id(String) The ID of the target group.
Nested Schema for health_check
Optional:
healthy_threshold(Number) The number of successful health checks before the managed instance is declared healthy.http_options(Block List, Max: 1) HTTP check options. (see below for nested schema)interval(Number) The interval to wait between health checks in seconds.tcp_options(Block List, Max: 1) TCP check options. (see below for nested schema)timeout(Number) The length of time to wait for a response before the health check times out in seconds.unhealthy_threshold(Number) The number of failed health checks before the managed instance is declared unhealthy.
Nested Schema for health_check.http_options
Required:
path(String) The URL path used for health check requests.port(Number) The port used for HTTP health checks.
Nested Schema for health_check.tcp_options
Required:
port(Number) The port used for TCP health checks.
Nested Schema for load_balancer
Optional:
ignore_health_checks(Boolean) Do not wait load balancer health checks.max_opening_traffic_duration(Number) Timeout for waiting for the VM to be checked by the load balancer. If the timeout is exceeded, the VM will be turned off based on the deployment policy. Specified in seconds.target_group_description(String) A description of the target group.target_group_labels(Map of String) A set of key/value label pairs.target_group_name(String) The name of the target group.
Read-Only:
status_message(String) The status message of the target group.target_group_id(String) The ID of the target group.
Nested Schema for timeouts
Optional:
create(String) A string that can be parsed as a duration consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).delete(String) A string that can be parsed as a duration consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours). Setting a timeout for a Delete operation is only applicable if changes are saved into state before the destroy operation occurs.update(String) A string that can be parsed as a duration consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).
Nested Schema for instances
Read-Only:
fqdn(String)instance_id(String)instance_tag(String)name(String)network_interface(List of Object) (see below for nested schema)status(String)status_changed_at(String)status_message(String)zone_id(String)
Nested Schema for instances.network_interface
Read-Only:
index(Number)ip_address(String)ipv4(Boolean)ipv6(Boolean)ipv6_address(String)mac_address(String)nat(Boolean)nat_ip_address(String)nat_ip_version(String)subnet_id(String)
Import
The resource can be imported by using their resource ID. For getting the resource ID you can use Yandex Cloud Web Console
# terraform import yandex_compute_instance_group.<resource Name> <resource Id>
terraform import yandex_compute_instance_group.my_ig1 cl1jh**********u4275