Skip to content

Commit

Permalink
feat: support setting nic_type of instance_template primary network i…
Browse files Browse the repository at this point in the history
…nterface
  • Loading branch information
tpdownes committed Sep 7, 2023
1 parent 4dc9d57 commit e1478ec
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
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 \"GVNIC\", \"VIRTIO_NET\" or null to accept API default behavior."
}
}

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
2 changes: 1 addition & 1 deletion modules/umig/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ See the [simple](https://github.com/terraform-google-modules/terraform-google-vm
| static\_ips | List of static IPs for VM instances | `list(string)` | `[]` | no |
| subnetwork | Subnet to deploy to. Only one of network or subnetwork should be specified. | `string` | `""` | no |
| subnetwork\_project | The project that subnetwork belongs to | `string` | `""` | no |
| zones | Override the availability zones list to create the resources in. | `list(string)` | `[]` | no |
| zones | (Optional) List of availability zones to create VM instances in | `list(string)` | `[]` | no |

## Outputs

Expand Down

0 comments on commit e1478ec

Please sign in to comment.