Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support setting nic_type of primary network interface #334

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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