| --- |
| # ---------------------------------------------------------------------------- |
| # |
| # *** AUTO GENERATED CODE *** Type: MMv1 *** |
| # |
| # ---------------------------------------------------------------------------- |
| # |
| # This file is automatically generated by Magic Modules and manual |
| # changes will be clobbered when the file is regenerated. |
| # |
| # Please read more about how to change this file in |
| # .github/CONTRIBUTING.md. |
| # |
| # ---------------------------------------------------------------------------- |
| subcategory: "Compute Engine" |
| description: |- |
| A config defined for a single managed instance that belongs to an instance group manager. |
| --- |
| |
| # 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: |
| |
| * [API documentation](https://cloud.google.com/compute/docs/reference/rest/v1/instanceGroupManagers) |
| * How-to Guides |
| * [Official Documentation](https://cloud.google.com/compute/docs/instance-groups/stateful-migs#per-instance_configs) |
| |
| ## Example Usage - Stateful Rigm |
| |
| |
| ```hcl |
| data "google_compute_image" "my_image" { |
| family = "debian-11" |
| project = "debian-cloud" |
| } |
| |
| resource "google_compute_instance_template" "igm-basic" { |
| name = "my-template" |
| machine_type = "e2-medium" |
| 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 |
| } |
| |
| update_policy { |
| type = "OPPORTUNISTIC" |
| instance_redistribution_type = "NONE" |
| minimal_action = "RESTART" |
| } |
| |
| base_instance_name = "rigm" |
| region = "us-central1" |
| target_size = 2 |
| } |
| |
| resource "google_compute_disk" "default" { |
| name = "my-disk-name" |
| type = "pd-ssd" |
| zone = "us-central1-a" |
| image = "debian-11-bullseye-v20220719" |
| physical_block_size_bytes = 4096 |
| } |
| |
| resource "google_compute_region_per_instance_config" "with_disk" { |
| region = google_compute_region_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" |
| // Adding a reference to the instance template used causes the stateful instance to update |
| // if the instance template changes. Otherwise there is no explicit dependency and template |
| // changes may not occur on the stateful instance |
| instance_template = google_compute_instance_template.igm-basic.self_link |
| } |
| |
| 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_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](#nested_preserved_state). |
| |
| * `region` - |
| (Optional) |
| Region where the containing instance group manager is located |
| |
| * `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_on_destroy` - (Optional) When true, deleting this config will immediately remove the underlying instance. |
| When false, deleting this config will use the behavior as determined by remove_instance_on_destroy. |
| |
| * `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. |
| |
| |
| <a name="nested_preserved_state"></a>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](#nested_disk). |
| |
| * `internal_ip` - |
| (Optional) |
| Preserved internal IPs defined for this instance. This map is keyed with the name of the network interface. |
| Structure is [documented below](#nested_internal_ip). |
| |
| * `external_ip` - |
| (Optional) |
| Preserved external IPs defined for this instance. This map is keyed with the name of the network interface. |
| Structure is [documented below](#nested_external_ip). |
| |
| |
| <a name="nested_disk"></a>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`, `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` - detach the disk when the VM is deleted, but do 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`, `ON_PERMANENT_INSTANCE_DELETION`. |
| |
| <a name="nested_internal_ip"></a>The `internal_ip` block supports: |
| |
| * `interface_name` - (Required) The identifier for this object. Format specified above. |
| |
| * `auto_delete` - |
| (Optional) |
| These stateful IPs will never be released during autohealing, update or VM instance recreate operations. This flag is used to configure if the IP reservation should be deleted after it is no longer used by the group, e.g. when the given instance or the whole group is deleted. |
| Default value is `NEVER`. |
| Possible values are: `NEVER`, `ON_PERMANENT_INSTANCE_DELETION`. |
| |
| * `ip_address` - |
| (Optional) |
| Ip address representation |
| Structure is [documented below](#nested_ip_address). |
| |
| |
| <a name="nested_ip_address"></a>The `ip_address` block supports: |
| |
| * `address` - |
| (Optional) |
| The URL of the reservation for this IP address. |
| |
| <a name="nested_external_ip"></a>The `external_ip` block supports: |
| |
| * `interface_name` - (Required) The identifier for this object. Format specified above. |
| |
| * `auto_delete` - |
| (Optional) |
| These stateful IPs will never be released during autohealing, update or VM instance recreate operations. This flag is used to configure if the IP reservation should be deleted after it is no longer used by the group, e.g. when the given instance or the whole group is deleted. |
| Default value is `NEVER`. |
| Possible values are: `NEVER`, `ON_PERMANENT_INSTANCE_DELETION`. |
| |
| * `ip_address` - |
| (Optional) |
| Ip address representation |
| Structure is [documented below](#nested_ip_address). |
| |
| |
| <a name="nested_ip_address"></a>The `ip_address` block supports: |
| |
| * `address` - |
| (Optional) |
| The URL of the reservation for this IP address. |
| |
| ## 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](https://developer.hashicorp.com/terraform/plugin/sdkv2/resources/retries-and-customizable-timeouts) configuration options: |
| |
| - `create` - Default is 20 minutes. |
| - `update` - Default is 20 minutes. |
| - `delete` - Default is 20 minutes. |
| |
| ## Import |
| |
| |
| RegionPerInstanceConfig can be imported using any of these accepted formats: |
| |
| * `projects/{{project}}/regions/{{region}}/instanceGroupManagers/{{region_instance_group_manager}}/{{name}}` |
| * `{{project}}/{{region}}/{{region_instance_group_manager}}/{{name}}` |
| * `{{region}}/{{region_instance_group_manager}}/{{name}}` |
| * `{{region_instance_group_manager}}/{{name}}` |
| |
| |
| In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import RegionPerInstanceConfig using one of the formats above. For example: |
| |
| ```tf |
| import { |
| id = "projects/{{project}}/regions/{{region}}/instanceGroupManagers/{{region_instance_group_manager}}/{{name}}" |
| to = google_compute_region_per_instance_config.default |
| } |
| ``` |
| |
| When using the [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import), RegionPerInstanceConfig can be imported using one of the formats above. For example: |
| |
| ``` |
| $ 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](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference#user_project_override). |