| --- |
| # ---------------------------------------------------------------------------- |
| # |
| # *** 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: |- |
| Represents a NodeGroup resource to manage a group of sole-tenant nodes. |
| --- |
| |
| # google_compute_node_group |
| |
| Represents a NodeGroup resource to manage a group of sole-tenant nodes. |
| |
| |
| To get more information about NodeGroup, see: |
| |
| * [API documentation](https://cloud.google.com/compute/docs/reference/rest/v1/nodeGroups) |
| * How-to Guides |
| * [Sole-Tenant Nodes](https://cloud.google.com/compute/docs/nodes/) |
| |
| <div class = "oics-button" style="float: right; margin: 0 0 -15px"> |
| <a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_image=gcr.io%2Fcloudshell-images%2Fcloudshell%3Alatest&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md&cloudshell_working_dir=node_group_basic&open_in_editor=main.tf" target="_blank"> |
| <img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;"> |
| </a> |
| </div> |
| ## Example Usage - Node Group Basic |
| |
| |
| ```hcl |
| resource "google_compute_node_template" "soletenant-tmpl" { |
| name = "soletenant-tmpl" |
| region = "us-central1" |
| node_type = "n1-node-96-624" |
| } |
| |
| resource "google_compute_node_group" "nodes" { |
| name = "soletenant-group" |
| zone = "us-central1-f" |
| description = "example google_compute_node_group for Terraform Google Provider" |
| |
| initial_size = 1 |
| node_template = google_compute_node_template.soletenant-tmpl.id |
| } |
| ``` |
| <div class = "oics-button" style="float: right; margin: 0 0 -15px"> |
| <a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_image=gcr.io%2Fcloudshell-images%2Fcloudshell%3Alatest&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md&cloudshell_working_dir=node_group_maintenance_interval&open_in_editor=main.tf" target="_blank"> |
| <img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;"> |
| </a> |
| </div> |
| ## Example Usage - Node Group Maintenance Interval |
| |
| |
| ```hcl |
| resource "google_compute_node_template" "soletenant-tmpl" { |
| provider = google-beta |
| name = "soletenant-tmpl" |
| region = "us-central1" |
| node_type = "c2-node-60-240" |
| } |
| |
| resource "google_compute_node_group" "nodes" { |
| provider = google-beta |
| name = "soletenant-group" |
| zone = "us-central1-a" |
| description = "example google_compute_node_group for Terraform Google Provider" |
| |
| initial_size = 1 |
| node_template = google_compute_node_template.soletenant-tmpl.id |
| |
| maintenance_interval = "RECURRENT" |
| } |
| ``` |
| <div class = "oics-button" style="float: right; margin: 0 0 -15px"> |
| <a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_image=gcr.io%2Fcloudshell-images%2Fcloudshell%3Alatest&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md&cloudshell_working_dir=node_group_autoscaling_policy&open_in_editor=main.tf" target="_blank"> |
| <img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;"> |
| </a> |
| </div> |
| ## Example Usage - Node Group Autoscaling Policy |
| |
| |
| ```hcl |
| resource "google_compute_node_template" "soletenant-tmpl" { |
| name = "soletenant-tmpl" |
| region = "us-central1" |
| node_type = "n1-node-96-624" |
| } |
| |
| resource "google_compute_node_group" "nodes" { |
| name = "soletenant-group" |
| zone = "us-central1-f" |
| description = "example google_compute_node_group for Terraform Google Provider" |
| maintenance_policy = "RESTART_IN_PLACE" |
| maintenance_window { |
| start_time = "08:00" |
| } |
| initial_size = 1 |
| node_template = google_compute_node_template.soletenant-tmpl.id |
| autoscaling_policy { |
| mode = "ONLY_SCALE_OUT" |
| min_nodes = 1 |
| max_nodes = 10 |
| } |
| } |
| ``` |
| ## Example Usage - Node Group Share Settings |
| |
| |
| ```hcl |
| resource "google_project" "guest_project" { |
| project_id = "project-id" |
| name = "project-name" |
| org_id = "123456789" |
| deletion_policy = "DELETE" |
| } |
| |
| resource "google_compute_node_template" "soletenant-tmpl" { |
| name = "soletenant-tmpl" |
| region = "us-central1" |
| node_type = "n1-node-96-624" |
| } |
| |
| resource "google_compute_node_group" "nodes" { |
| name = "soletenant-group" |
| zone = "us-central1-f" |
| description = "example google_compute_node_group for Terraform Google Provider" |
| |
| initial_size = 1 |
| node_template = google_compute_node_template.soletenant-tmpl.id |
| |
| share_settings { |
| share_type = "SPECIFIC_PROJECTS" |
| project_map { |
| id = google_project.guest_project.project_id |
| project_id = google_project.guest_project.project_id |
| } |
| } |
| } |
| ``` |
| |
| ## Argument Reference |
| |
| The following arguments are supported: |
| |
| |
| * `node_template` - |
| (Required) |
| The URL of the node template to which this node group belongs. |
| |
| |
| - - - |
| |
| |
| * `description` - |
| (Optional) |
| An optional textual description of the resource. |
| |
| * `name` - |
| (Optional) |
| Name of the resource. |
| |
| * `initial_size` - |
| (Optional) |
| The initial number of nodes in the node group. One of `initial_size` or `autoscaling_policy` must be configured on resource creation. |
| |
| * `maintenance_policy` - |
| (Optional) |
| Specifies how to handle instances when a node in the group undergoes maintenance. Set to one of: DEFAULT, RESTART_IN_PLACE, or MIGRATE_WITHIN_NODE_GROUP. The default value is DEFAULT. |
| |
| * `maintenance_window` - |
| (Optional) |
| contains properties for the timeframe of maintenance |
| Structure is [documented below](#nested_maintenance_window). |
| |
| * `autoscaling_policy` - |
| (Optional) |
| If you use sole-tenant nodes for your workloads, you can use the node |
| group autoscaler to automatically manage the sizes of your node groups. |
| One of `initial_size` or `autoscaling_policy` must be configured on resource creation. |
| Structure is [documented below](#nested_autoscaling_policy). |
| |
| * `share_settings` - |
| (Optional) |
| Share settings for the node group. |
| Structure is [documented below](#nested_share_settings). |
| |
| * `maintenance_interval` - |
| (Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html)) |
| Specifies the frequency of planned maintenance events. Set to one of the following: |
| - AS_NEEDED: Hosts are eligible to receive infrastructure and hypervisor updates as they become available. |
| - RECURRENT: Hosts receive planned infrastructure and hypervisor updates on a periodic basis, but not more frequently than every 28 days. This minimizes the number of planned maintenance operations on individual hosts and reduces the frequency of disruptions, both live migrations and terminations, on individual VMs. |
| Possible values are: `AS_NEEDED`, `RECURRENT`. |
| |
| * `zone` - |
| (Optional) |
| Zone where this node group is located |
| |
| * `project` - (Optional) The ID of the project in which the resource belongs. |
| If it is not provided, the provider project is used. |
| |
| |
| <a name="nested_maintenance_window"></a>The `maintenance_window` block supports: |
| |
| * `start_time` - |
| (Required) |
| instances.start time of the window. This must be in UTC format that resolves to one of 00:00, 04:00, 08:00, 12:00, 16:00, or 20:00. For example, both 13:00-5 and 08:00 are valid. |
| |
| <a name="nested_autoscaling_policy"></a>The `autoscaling_policy` block supports: |
| |
| * `mode` - |
| (Required) |
| The autoscaling mode. Set to one of the following: |
| - OFF: Disables the autoscaler. |
| - ON: Enables scaling in and scaling out. |
| - ONLY_SCALE_OUT: Enables only scaling out. |
| You must use this mode if your node groups are configured to |
| restart their hosted VMs on minimal servers. |
| Possible values are: `OFF`, `ON`, `ONLY_SCALE_OUT`. |
| |
| * `min_nodes` - |
| (Optional) |
| Minimum size of the node group. Must be less |
| than or equal to max-nodes. The default value is 0. |
| |
| * `max_nodes` - |
| (Required) |
| Maximum size of the node group. Set to a value less than or equal |
| to 100 and greater than or equal to min-nodes. |
| |
| <a name="nested_share_settings"></a>The `share_settings` block supports: |
| |
| * `share_type` - |
| (Required) |
| Node group sharing type. |
| Possible values are: `ORGANIZATION`, `SPECIFIC_PROJECTS`, `LOCAL`. |
| |
| * `project_map` - |
| (Optional) |
| A map of project id and project config. This is only valid when shareType's value is SPECIFIC_PROJECTS. |
| Structure is [documented below](#nested_project_map). |
| |
| |
| <a name="nested_project_map"></a>The `project_map` block supports: |
| |
| * `id` - (Required) The identifier for this object. Format specified above. |
| |
| * `project_id` - |
| (Required) |
| The project id/number should be the same as the key of this project config in the project map. |
| |
| ## Attributes Reference |
| |
| In addition to the arguments listed above, the following computed attributes are exported: |
| |
| * `id` - an identifier for the resource with format `projects/{{project}}/zones/{{zone}}/nodeGroups/{{name}}` |
| |
| * `creation_timestamp` - |
| Creation timestamp in RFC3339 text format. |
| |
| * `size` - |
| The total number of nodes in the node group. |
| * `self_link` - The URI of the created resource. |
| |
| |
| ## 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 |
| |
| |
| NodeGroup can be imported using any of these accepted formats: |
| |
| * `projects/{{project}}/zones/{{zone}}/nodeGroups/{{name}}` |
| * `{{project}}/{{zone}}/{{name}}` |
| * `{{zone}}/{{name}}` |
| * `{{name}}` |
| |
| |
| In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import NodeGroup using one of the formats above. For example: |
| |
| ```tf |
| import { |
| id = "projects/{{project}}/zones/{{zone}}/nodeGroups/{{name}}" |
| to = google_compute_node_group.default |
| } |
| ``` |
| |
| When using the [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import), NodeGroup can be imported using one of the formats above. For example: |
| |
| ``` |
| $ terraform import google_compute_node_group.default projects/{{project}}/zones/{{zone}}/nodeGroups/{{name}} |
| $ terraform import google_compute_node_group.default {{project}}/{{zone}}/{{name}} |
| $ terraform import google_compute_node_group.default {{zone}}/{{name}} |
| $ terraform import google_compute_node_group.default {{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). |