Skip to content

Commit

Permalink
feat: support nic_type of primary network interface in instance_template
Browse files Browse the repository at this point in the history
  • Loading branch information
tpdownes committed Sep 7, 2023
1 parent f3e0232 commit 6d3089c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions modules/instance_template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ See the [simple](../../examples/instance_template/simple) for a usage example.
| name\_prefix | Name prefix for the instance template | `string` | `"default-instance-template"` | no |
| network | The name or self\_link of the network to attach this interface to. Use network attribute for Legacy or Auto subnetted networks and subnetwork for custom subnetted networks. | `string` | `""` | no |
| network\_ip | Private IP address to assign to the instance if desired. | `string` | `""` | no |
| nic\_type | Valid values are "VIRTIO\_NET", "GVNIC" or set to null to accept API default behavior. | `string` | `null` | no |
| on\_host\_maintenance | Instance availability Policy | `string` | `"MIGRATE"` | no |
| preemptible | Allow the instance to be preempted | `bool` | `false` | no |
| project\_id | The GCP project ID | `string` | `null` | no |
Expand Down
1 change: 1 addition & 0 deletions modules/instance_template/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ resource "google_compute_instance_template" "tpl" {
subnetwork = var.subnetwork
subnetwork_project = var.subnetwork_project
network_ip = length(var.network_ip) > 0 ? var.network_ip : null
nic_type = var.nic_type
stack_type = var.stack_type
dynamic "access_config" {
for_each = var.access_config
Expand Down
11 changes: 11 additions & 0 deletions modules/instance_template/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,17 @@ variable "network_ip" {
default = ""
}

variable "nic_type" {
description = "Valid values are \"VIRTIO_NET\", \"GVNIC\" or set to null to accept API default behavior."
type = string
default = null

validation {
condition = var.nic_type == null || var.nic_type == "GVNIC" || var.nic_type == "VIRTIO_NET"
error_message = "The \"nic_type\" variable must be set to \"VIRTIO_NET\", \"GVNIC\", or null to allow API default selection."
}
}

variable "stack_type" {
description = "The stack type for this network interface to identify whether the IPv6 feature is enabled or not. Values are `IPV4_IPV6` or `IPV4_ONLY`. Default behavior is equivalent to IPV4_ONLY."
type = string
Expand Down

0 comments on commit 6d3089c

Please sign in to comment.