Fixes related to boot_disk in compute-vm module

This commit is contained in:
Miren Esnaola 2023-03-16 14:30:05 +01:00
parent 79a6e9b191
commit 21fa6d1f13
19 changed files with 89 additions and 52 deletions

View File

@ -310,11 +310,13 @@ module "simple-vm-example" {
zone = "europe-west1-b" zone = "europe-west1-b"
name = "test" name = "test"
boot_disk = { boot_disk = {
initialize_params = {
image = "projects/debian-cloud/global/images/family/cos-97-lts" image = "projects/debian-cloud/global/images/family/cos-97-lts"
type = "pd-balanced" type = "pd-balanced"
size = 10 size = 10
} }
} }
}
``` ```
Where this results in objects with too many attributes, we usually split attributes between required and optional by adding a second level, as in this example where VM `attached_disks[].options` contains less used attributes and can be set to null if not needed. Where this results in objects with too many attributes, we usually split attributes between required and optional by adding a second level, as in this example where VM `attached_disks[].options` contains less used attributes and can be set to null if not needed.

View File

@ -30,10 +30,12 @@ module "mgmt_server" {
}] }]
service_account_create = true service_account_create = true
boot_disk = { boot_disk = {
initialize_params = {
image = var.mgmt_server_config.image image = var.mgmt_server_config.image
type = var.mgmt_server_config.disk_type type = var.mgmt_server_config.disk_type
size = var.mgmt_server_config.disk_size size = var.mgmt_server_config.disk_size
} }
}
metadata = { metadata = {
startup-script = <<EOT startup-script = <<EOT
#!/bin/bash #!/bin/bash

View File

@ -81,10 +81,12 @@ module "server" {
} }
service_account_create = true service_account_create = true
boot_disk = { boot_disk = {
initialize_params = {
image = var.image image = var.image
type = var.disk_type type = var.disk_type
size = var.disk_size size = var.disk_size
} }
}
group = { group = {
named_ports = { named_ports = {
https = 443 https = 443

View File

@ -234,10 +234,12 @@ module "test-vm" {
zone = "${var.region}-b" zone = "${var.region}-b"
name = "nginx-test" name = "nginx-test"
boot_disk = { boot_disk = {
initialize_params = {
image = "projects/cos-cloud/global/images/family/cos-stable" image = "projects/cos-cloud/global/images/family/cos-stable"
type = "pd-ssd" type = "pd-ssd"
size = 10 size = 10
} }
}
metadata = { metadata = {
user-data = module.cos-nginx.cloud_config user-data = module.cos-nginx.cloud_config
google-logging-enabled = true google-logging-enabled = true

View File

@ -46,10 +46,12 @@ module "test-vm" {
service_account = module.service-account-sql.email service_account = module.service-account-sql.email
service_account_scopes = ["https://www.googleapis.com/auth/cloud-platform"] service_account_scopes = ["https://www.googleapis.com/auth/cloud-platform"]
boot_disk = { boot_disk = {
initialize_params = {
image = "projects/debian-cloud/global/images/family/debian-10" image = "projects/debian-cloud/global/images/family/debian-10"
type = "pd-ssd" type = "pd-ssd"
size = 10 size = 10
} }
}
encryption = var.service_encryption_keys != null ? { encryption = var.service_encryption_keys != null ? {
encrypt_boot = true encrypt_boot = true
disk_encryption_key_raw = null disk_encryption_key_raw = null

View File

@ -134,10 +134,11 @@ module "vm_example" {
} }
] ]
boot_disk = { boot_disk = {
initialize_params = {
image = "projects/debian-cloud/global/images/family/debian-10" image = "projects/debian-cloud/global/images/family/debian-10"
type = "pd-ssd" type = "pd-ssd"
size = 10 size = 10
encrypt_disk = true }
} }
tags = ["ssh"] tags = ["ssh"]
encryption = { encryption = {

View File

@ -73,10 +73,12 @@ module "nodes" {
}] }]
boot_disk = { boot_disk = {
initialize_params = {
image = var.node_image image = var.node_image
type = "pd-ssd" type = "pd-ssd"
size = var.boot_disk_size size = var.boot_disk_size
} }
}
attached_disks = [{ attached_disks = [{
name = "${each.value}-datadisk" name = "${each.value}-datadisk"

View File

@ -32,9 +32,11 @@ module "mgmt_server" {
}] }]
service_account_create = true service_account_create = true
boot_disk = { boot_disk = {
initialize_params = {
image = var.mgmt_server_config.image image = var.mgmt_server_config.image
type = var.mgmt_server_config.disk_type type = var.mgmt_server_config.disk_type
size = var.mgmt_server_config.disk_size size = var.mgmt_server_config.disk_size
} }
}
tags = ["ssh"] tags = ["ssh"]
} }

View File

@ -30,9 +30,11 @@ module "mgmt_server" {
}] }]
service_account_create = true service_account_create = true
boot_disk = { boot_disk = {
initialize_params = {
image = var.mgmt_server_config.image image = var.mgmt_server_config.image
type = var.mgmt_server_config.disk_type type = var.mgmt_server_config.disk_type
size = var.mgmt_server_config.disk_size size = var.mgmt_server_config.disk_size
} }
} }
}

View File

@ -289,8 +289,10 @@ module "proxy-vm" {
subnetwork = module.vpc.subnet_self_links[format("%s/%s", var.region, var.subnetwork)] subnetwork = module.vpc.subnet_self_links[format("%s/%s", var.region, var.subnetwork)]
}] }]
boot_disk = { boot_disk = {
initialize_params = {
image = "projects/cos-cloud/global/images/family/cos-stable" image = "projects/cos-cloud/global/images/family/cos-stable"
} }
}
create_template = true create_template = true
metadata = { metadata = {
user-data = !var.tls ? module.cos-nginx.0.cloud_config : module.cos-nginx-tls.0.cloud_config user-data = !var.tls ? module.cos-nginx.0.cloud_config : module.cos-nginx-tls.0.cloud_config

View File

@ -302,8 +302,10 @@ module "vm-onprem" {
instance_type = "f1-micro" instance_type = "f1-micro"
name = "onprem" name = "onprem"
boot_disk = { boot_disk = {
initialize_params = {
image = "ubuntu-os-cloud/ubuntu-1804-lts" image = "ubuntu-os-cloud/ubuntu-1804-lts"
} }
}
metadata = { metadata = {
user-data = module.config-onprem.cloud_config user-data = module.config-onprem.cloud_config
} }

View File

@ -23,10 +23,12 @@ module "gw" {
instance_type = "f1-micro" instance_type = "f1-micro"
boot_disk = { boot_disk = {
initialize_params = {
image = "projects/ubuntu-os-cloud/global/images/family/ubuntu-2004-lts", image = "projects/ubuntu-os-cloud/global/images/family/ubuntu-2004-lts",
type = "pd-ssd", type = "pd-ssd",
size = 10 size = 10
} }
}
network_interfaces = [ network_interfaces = [
{ {

View File

@ -161,8 +161,10 @@ module "test-vm" {
name = "${var.name}-test" name = "${var.name}-test"
instance_type = "e2-micro" instance_type = "e2-micro"
boot_disk = { boot_disk = {
initialize_params = {
image = "projects/ubuntu-os-cloud/global/images/family/ubuntu-2104" image = "projects/ubuntu-os-cloud/global/images/family/ubuntu-2104"
} }
}
network_interfaces = [{ network_interfaces = [{
network = module.vpc-onprem.self_link network = module.vpc-onprem.self_link
subnetwork = module.vpc-onprem.subnet_self_links["${var.region}/${var.name}-onprem"] subnetwork = module.vpc-onprem.subnet_self_links["${var.region}/${var.name}-onprem"]

View File

@ -58,10 +58,12 @@ module "vm" {
google-logging-enabled = true google-logging-enabled = true
} }
boot_disk = { boot_disk = {
initialize_params = {
image = "projects/cos-cloud/global/images/family/cos-stable" image = "projects/cos-cloud/global/images/family/cos-stable"
type = "pd-ssd" type = "pd-ssd"
size = 10 size = 10
} }
}
tags = ["ssh"] tags = ["ssh"]
} }
# tftest skip # tftest skip

View File

@ -41,10 +41,12 @@ module "vm" {
google-logging-enabled = true google-logging-enabled = true
} }
boot_disk = { boot_disk = {
initialize_params = {
image = "projects/cos-cloud/global/images/family/cos-stable" image = "projects/cos-cloud/global/images/family/cos-stable"
type = "pd-ssd" type = "pd-ssd"
size = 10 size = 10
} }
}
tags = ["dns", "ssh"] tags = ["dns", "ssh"]
} }
# tftest modules=1 resources=1 # tftest modules=1 resources=1

View File

@ -25,10 +25,12 @@ module "vm-nginx-tls" {
google-logging-enabled = true google-logging-enabled = true
} }
boot_disk = { boot_disk = {
initialize_params = {
image = "projects/cos-cloud/global/images/family/cos-stable" image = "projects/cos-cloud/global/images/family/cos-stable"
type = "pd-ssd" type = "pd-ssd"
size = 10 size = 10
} }
}
tags = ["http-server", "https-server", "ssh"] tags = ["http-server", "https-server", "ssh"]
} }
# tftest modules=1 resources=1 # tftest modules=1 resources=1

View File

@ -41,10 +41,12 @@ module "vm-nginx-tls" {
google-logging-enabled = true google-logging-enabled = true
} }
boot_disk = { boot_disk = {
initialize_params = {
image = "projects/cos-cloud/global/images/family/cos-stable" image = "projects/cos-cloud/global/images/family/cos-stable"
type = "pd-ssd" type = "pd-ssd"
size = 10 size = 10
} }
}
tags = ["http-server", "ssh"] tags = ["http-server", "ssh"]
} }
# tftest modules=1 resources=1 # tftest modules=1 resources=1

View File

@ -54,10 +54,12 @@ module "vm" {
google-logging-enabled = true google-logging-enabled = true
} }
boot_disk = { boot_disk = {
initialize_params = {
image = "projects/cos-cloud/global/images/family/cos-stable" image = "projects/cos-cloud/global/images/family/cos-stable"
type = "pd-ssd" type = "pd-ssd"
size = 10 size = 10
} }
}
tags = ["nva", "ssh"] tags = ["nva", "ssh"]
} }
# tftest modules=1 resources=1 # tftest modules=1 resources=1

View File

@ -132,10 +132,12 @@ module "instance-group" {
addresses = null addresses = null
}] }]
boot_disk = { boot_disk = {
initialize_params = {
image = "projects/cos-cloud/global/images/family/cos-stable" image = "projects/cos-cloud/global/images/family/cos-stable"
type = "pd-ssd" type = "pd-ssd"
size = 10 size = 10
} }
}
tags = ["http-server", "ssh"] tags = ["http-server", "ssh"]
metadata = { metadata = {
user-data = module.cos-nginx.cloud_config user-data = module.cos-nginx.cloud_config