README.md

June 10, 2026 ยท View on GitHub

Description

This modules create a resource policy for compute engines. This policy can be passed to a gke-node-pool module to apply the policy on the node-pool's nodes.

Note: By default, you can't apply compact placement policies with a max distance value to A3 VMs. To request access to this feature, contact your Technical Account Manager (TAM) or the Sales team.

Example

The following example creates a group placement resource policy and applies it to a gke-node-pool.

  - id: group_placement_1
    source: modules/compute/resource-policy
    settings:
      name: gp-np-1
      group_placement_max_distance: 2

  - id: node_pool_1
    source: modules/compute/gke-node-pool
    use: [group_placement_1]
    settings:
      machine_type: e2-standard-8
    outputs: [instructions]

Copyright 2026 Google LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Requirements

NameVersion
terraform>= 1.12.2
google-beta>= 7.24.0
random~> 3.0

Providers

NameVersion
google-beta>= 7.24.0
random~> 3.0

Modules

No modules.

Resources

NameType
google-beta_google_compute_resource_policy.policyresource
random_id.resource_name_suffixresource

Inputs

NameDescriptionTypeDefaultRequired
group_placement_max_distanceThe max distance for group placement policy to use for the node pool's nodes. If set it will add a compact group placement policy.
Note: Placement policies have the following restrictions.
number0no
nameThe resource policy's name.stringn/ayes
project_idThe project ID for the resource policy.stringn/ayes
regionThe region for the the resource policy.stringn/ayes
workload_policyDescribes the workload policy
object({
type = optional(string, null)
max_topology_distance = optional(string, null)
accelerator_topology = optional(string, null)
accelerator_topology_mode = optional(string, null)
})
{
"accelerator_topology": null,
"accelerator_topology_mode": null,
"max_topology_distance": null,
"type": null
}
no

Outputs

NameDescription
accelerator_topology_modeThe accelerator topology mode for the resource policy.
placement_policyGroup placement policy to use for placing VMs or GKE nodes placement. COMPACT is the only supported value for type currently. name is the name of the placement policy.
It is assumed that the specified policy exists. To create a placement policy refer to https://cloud.google.com/sdk/gcloud/reference/compute/resource-policies/create/group-placement.
Note: Placement policies have the following restrictions.
The value tpu_topology is only used for TPU node pools. The gke-node-pool module ensures it is configured appropriately for only TPUs during placement policy mapping.