diff --git a/modules/compute_instance/README.md b/modules/compute_instance/README.md index 7f4670cf..a2b8b3f6 100644 --- a/modules/compute_instance/README.md +++ b/modules/compute_instance/README.md @@ -17,6 +17,7 @@ See the [simple](https://github.com/terraform-google-modules/terraform-google-vm |------|-------------|------|---------|:--------:| | access\_config | Access configurations, i.e. IPs via which the VM instance can be accessed via the Internet. |
list(object({
nat_ip = string
network_tier = string
}))
| `[]` | no | | add\_hostname\_suffix | Adds a suffix to the hostname | `bool` | `true` | no | +| alias\_ip\_ranges | (Optional) An array of alias IP ranges for this network interface. Can only be specified for network interfaces on subnet-mode networks. |
list(object({
ip_cidr_range = string
subnetwork_range_name = string
}))
| `[]` | no | | deletion\_protection | Enable deletion protection on this instance. Note: you must disable deletion protection before removing the resource, or the instance cannot be deleted and the Terraform run will not complete successfully. | `bool` | `false` | 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 | diff --git a/modules/compute_instance/main.tf b/modules/compute_instance/main.tf index 29a7d70e..2a427140 100644 --- a/modules/compute_instance/main.tf +++ b/modules/compute_instance/main.tf @@ -67,6 +67,13 @@ resource "google_compute_instance_from_template" "compute_instance" { } } } + dynamic "alias_ip_range" { + for_each = var.alias_ip_ranges + content { + ip_cidr_range = alias_ip_range.value.ip_cidr_range + subnetwork_range_name = alias_ip_range.value.subnetwork_range_name + } + } } source_instance_template = var.instance_template diff --git a/modules/compute_instance/variables.tf b/modules/compute_instance/variables.tf index d66f0bd5..1b9623f0 100644 --- a/modules/compute_instance/variables.tf +++ b/modules/compute_instance/variables.tf @@ -86,3 +86,12 @@ variable "deletion_protection" { description = "Enable deletion protection on this instance. Note: you must disable deletion protection before removing the resource, or the instance cannot be deleted and the Terraform run will not complete successfully." default = false } + +variable "alias_ip_ranges" { + description = "(Optional) An array of alias IP ranges for this network interface. Can only be specified for network interfaces on subnet-mode networks." + type = list(object({ + ip_cidr_range = string + subnetwork_range_name = string + })) + default = [] +}