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

Add nic_type and stack_type network interfaces parameters in umig submodule #437

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion modules/umig/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@ See the [simple](https://github.com/terraform-google-modules/terraform-google-vm
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| access\_config | Access configurations, i.e. IPs via which the VM instance can be accessed via the Internet. | <pre>list(list(object({<br> nat_ip = string<br> network_tier = string<br> })))</pre> | `[]` | no |
| additional\_networks | Additional network interface details for GCE, if any. | <pre>list(object({<br> network = string<br> subnetwork = string<br> subnetwork_project = string<br> network_ip = string<br> access_config = list(object({<br> nat_ip = string<br> network_tier = string<br> }))<br> ipv6_access_config = list(object({<br> network_tier = string<br> }))<br> }))</pre> | `[]` | no |
| additional\_networks | Additional network interface details for GCE, if any. | <pre>list(object({<br> network = string<br> subnetwork = string<br> subnetwork_project = string<br> network_ip = string<br> nic_type = optional(string, null)<br> stack_type = optional(string, null)<br> access_config = list(object({<br> nat_ip = string<br> network_tier = string<br> }))<br> ipv6_access_config = list(object({<br> network_tier = string<br> }))<br> }))</pre> | `[]` | no |
| hostname | Hostname of instances | `string` | `""` | no |
| hostname\_suffix\_separator | Separator character to compose hostname when add\_hostname\_suffix is set to true. | `string` | `"-"` | no |
| instance\_template | Instance template self\_link used to create compute instances | `string` | n/a | yes |
| ipv6\_access\_config | IPv6 access configurations. Currently a max of 1 IPv6 access configuration is supported. If not specified, the instance will have no external IPv6 Internet access. | <pre>list(list(object({<br> network_tier = string<br> })))</pre> | `[]` | no |
| named\_ports | Named name and named port | <pre>list(object({<br> name = string<br> port = number<br> }))</pre> | `[]` | no |
| network | Network to deploy to. Only one of network or subnetwork should be specified. | `string` | `""` | no |
| nic\_type | Valid values are "VIRTIO\_NET", "GVNIC" or set to null to accept API default behavior. | `string` | `null` | no |
| num\_instances | Number of instances to create. This value is ignored if static\_ips is provided. | `string` | `"1"` | no |
| project\_id | The GCP project ID | `string` | `null` | no |
| region | The GCP region where the unmanaged instance group resides. | `string` | n/a | yes |
| stack\_type | 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. | `string` | `null` | no |
| 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 |
Expand Down
5 changes: 4 additions & 1 deletion modules/umig/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ resource "google_compute_instance_from_template" "compute_instance" {
subnetwork = var.subnetwork
subnetwork_project = var.subnetwork_project
network_ip = length(var.static_ips) == 0 ? "" : element(local.static_ips, count.index)

nic_type = var.nic_type
stack_type = var.stack_type
dynamic "access_config" {
# convert to map to use lookup function with default value
for_each = lookup({ for k, v in var.access_config : k => v }, count.index, [])
Expand All @@ -83,6 +84,8 @@ resource "google_compute_instance_from_template" "compute_instance" {
subnetwork = network_interface.value.subnetwork
subnetwork_project = network_interface.value.subnetwork_project
network_ip = length(network_interface.value.network_ip) > 0 ? network_interface.value.network_ip : null
nic_type = lookup(network_interface.value, "nic_type", null)
stack_type = lookup(network_interface.value, "stack_type", null)
dynamic "access_config" {
for_each = network_interface.value.access_config
content {
Expand Down
8 changes: 8 additions & 0 deletions modules/umig/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ spec:
subnetwork = string
subnetwork_project = string
network_ip = string
nic_type = optional(string, null)
stack_type = optional(string, null)
access_config = list(object({
nat_ip = string
network_tier = string
Expand Down Expand Up @@ -134,6 +136,9 @@ spec:
description: Network to deploy to. Only one of network or subnetwork should be specified.
varType: string
defaultValue: ""
- name: nic_type
description: Valid values are "VIRTIO_NET", "GVNIC" or set to null to accept API default behavior.
varType: string
- name: num_instances
description: Number of instances to create. This value is ignored if static_ips is provided.
varType: string
Expand All @@ -145,6 +150,9 @@ spec:
description: The GCP region where the unmanaged instance group resides.
varType: string
required: true
- name: 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.
varType: string
- name: static_ips
description: List of static IPs for VM instances
varType: list(string)
Expand Down
19 changes: 19 additions & 0 deletions modules/umig/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,23 @@ variable "subnetwork_project" {
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
default = null
}

variable "additional_networks" {
description = "Additional network interface details for GCE, if any."
default = []
Expand All @@ -51,6 +68,8 @@ variable "additional_networks" {
subnetwork = string
subnetwork_project = string
network_ip = string
nic_type = optional(string, null)
stack_type = optional(string, null)
access_config = list(object({
nat_ip = string
network_tier = string
Expand Down