Fixes to `compute-vm` module
This commit is contained in:
parent
143249d726
commit
2bef92da57
|
@ -9,6 +9,11 @@ All notable changes to this project will be documented in this file.
|
|||
- depend views on tables in bigquery dataset module
|
||||
- bring back logging options for firewall rules in `net-vpc-firewall` module
|
||||
- removed interpolation-only expressions causing terraform warnings
|
||||
- **incompatible change** simplify alias IP specification in `compute-vm`. We now use a map (alias range name to list of IPs) instead of a list of maps.
|
||||
- allow using alias IPs with `instance_count` in `compute-vm`
|
||||
- add support for virtual displays in `compute-vm`
|
||||
- add examples of alias IPs in `compute-vm` module
|
||||
- fix support for creating disks from images in `compute-vm`
|
||||
|
||||
## [3.4.0] - 2020-09-24
|
||||
|
||||
|
|
|
@ -76,6 +76,34 @@ module "kms-vm-example" {
|
|||
}
|
||||
```
|
||||
|
||||
### Using Alias IPs
|
||||
|
||||
This example shows how add additional [Alias IPs](https://cloud.google.com/vpc/docs/alias-ip) to your VM.
|
||||
|
||||
```hcl
|
||||
module "vm-with-alias-ips" {
|
||||
source = "../modules/compute-vm"
|
||||
project_id = "my-project"
|
||||
region = "europe-west1"
|
||||
name = "test"
|
||||
network_interfaces = [{
|
||||
network = local.network_self_link
|
||||
subnetwork = local.subnet_self_link
|
||||
nat = false
|
||||
addresses = null
|
||||
alias_ips = {
|
||||
alias1 = [
|
||||
"10.16.0.10/32", # alias1 IP for first instance
|
||||
"10.16.0.11/32", # alias1 IP for second instance
|
||||
"10.16.0.12/32", # alias1 IP for third instance
|
||||
]
|
||||
}
|
||||
}]
|
||||
service_account_create = true
|
||||
instance_count = 3
|
||||
}
|
||||
```
|
||||
|
||||
### Instance template
|
||||
|
||||
This example shows how to use the module to manage an instance template that defines an additional attached disk for each instance, and overrides defaults for the boot disk image and service account.
|
||||
|
|
|
@ -69,10 +69,14 @@ resource "google_compute_disk" "disks" {
|
|||
name = each.key
|
||||
type = local.attached_disks[each.value.disk_name].options.type
|
||||
size = local.attached_disks[each.value.disk_name].size
|
||||
image = local.attached_disks[each.value.disk_name].image
|
||||
labels = merge(var.labels, {
|
||||
disk_name = local.attached_disks[each.value.disk_name].name
|
||||
disk_type = local.attached_disks[each.value.disk_name].options.type
|
||||
image = local.attached_disks[each.value.disk_name].image
|
||||
|
||||
# Disk images usually have slashes, which is against label
|
||||
# restrictions
|
||||
# image = local.attached_disks[each.value.disk_name].image
|
||||
})
|
||||
dynamic disk_encryption_key {
|
||||
for_each = var.encryption != null ? [""] : []
|
||||
|
@ -97,6 +101,7 @@ resource "google_compute_instance" "default" {
|
|||
can_ip_forward = var.can_ip_forward
|
||||
allow_stopping_for_update = var.options.allow_stopping_for_update
|
||||
deletion_protection = var.options.deletion_protection
|
||||
enable_display = var.enable_display
|
||||
labels = var.labels
|
||||
metadata = merge(
|
||||
var.metadata, try(element(var.metadata_list, each.value), {})
|
||||
|
@ -146,11 +151,11 @@ resource "google_compute_instance" "default" {
|
|||
}
|
||||
}
|
||||
dynamic alias_ip_range {
|
||||
for_each = config.value.alias_ips != null ? config.value.alias_ips : []
|
||||
for_each = config.value.alias_ips != null ? config.value.alias_ips : {}
|
||||
iterator = alias_ips
|
||||
content {
|
||||
ip_cidr_range = alias_ips.value.ip_cidr_range
|
||||
subnetwork_range_name = alias_ips.value.subnetwork_range_name
|
||||
subnetwork_range_name = alias_ips.key
|
||||
ip_cidr_range = alias_ips.value[each.value]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -153,10 +153,7 @@ variable "network_interfaces" {
|
|||
internal = list(string)
|
||||
external = list(string)
|
||||
})
|
||||
alias_ips = list(object({
|
||||
ip_cidr_range = string
|
||||
subnetwork_range_name = string
|
||||
}))
|
||||
alias_ips = map(list(string))
|
||||
}))
|
||||
}
|
||||
|
||||
|
@ -243,3 +240,9 @@ variable "shielded_config" {
|
|||
})
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "enable_display" {
|
||||
description = "Enable virtual display on the instances"
|
||||
type = bool
|
||||
default = false
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue